From 08297376a85a1719518507e54fca9de954d2376a Mon Sep 17 00:00:00 2001 From: Petri Hienonen Date: Thu, 23 May 2024 13:56:00 +0300 Subject: Agenix configuration --- home/nvim/lsp.lua | 305 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 305 insertions(+) create mode 100644 home/nvim/lsp.lua (limited to 'home/nvim/lsp.lua') diff --git a/home/nvim/lsp.lua b/home/nvim/lsp.lua new file mode 100644 index 0000000..07665bc --- /dev/null +++ b/home/nvim/lsp.lua @@ -0,0 +1,305 @@ +-- example configurations available https://github.com/neovim/nvim-lspconfig/tree/master/lsp +vim.lsp.set_log_level(vim.log.levels.WARN) +vim.lsp.log.set_format_func(vim.inspect) + +vim.diagnostic.config({ + virtual_text = true, + virtual_lines = { current_line = true }, + underline = true, + update_in_insert = false, + severity_sort = true, + float = { + border = "rounded", + source = true, + }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "󰅚 ", + [vim.diagnostic.severity.WARN] = "󰀪 ", + [vim.diagnostic.severity.INFO] = "󰋽 ", + [vim.diagnostic.severity.HINT] = "󰌶 ", + }, + numhl = { + [vim.diagnostic.severity.ERROR] = "ErrorMsg", + [vim.diagnostic.severity.WARN] = "WarningMsg", + }, + }, +}) + +local capabilities = vim.lsp.protocol.make_client_capabilities() + +capabilities = vim.tbl_deep_extend("force", capabilities, { + textDocument = { + inlayHint = { + dynamicRegistration = false, -- Static registration + resolveSupport = { + properties = { "textEdits", "tooltip", "label" }, -- Resolve additional hint details + }, + }, + synchronization = { + dynamicRegistration = false, -- Static registration + willSave = true, -- Notify server before saving + willSaveWaitUntil = true, -- Allow server to provide edits before saving + didSave = true, -- Notify server after saving + }, + hover = { + dynamicRegistration = false, -- Static registration + contentFormat = { "markdown", "plaintext" }, -- Prefer markdown, fallback to plaintext + }, + documentSymbol = { + dynamicRegistration = false, -- Static registration + hierarchicalDocumentSymbolSupport = true, -- Support nested symbols + symbolKind = { + valueSet = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + }, -- All standard symbol kinds (file, module, namespace, etc.) + }, + }, + completion = { + completionItem = { + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { "documentation", "detail", "additionalTextEdits" }, + }, + }, + }, + diagnostic = { + documentDiagnosticProvider = true, -- Enable document-level diagnostics + relatedInformation = true, -- Show related diagnostic information + tagSupport = { valueSet = { 1, 2 } }, -- Support deprecated (1) and unused (2) tags + dataSupport = true, -- Allow custom data in diagnostics + }, + semanticTokens = { + multilineTokenSupport = true, + overlappingTokenSupport = true, + augmentsSyntaxTokens = true, + }, + foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + }, + }, + workspace = { + configuration = true, + workspaceFolders = true, + didChangeWatchedFiles = { + dynamicRegistration = true, + }, + fileOperations = { + didRename = true, + willRename = true, + didDelete = true, + didCreate = true, + }, + symbol = { + dynamicRegistration = false, -- Static registration + symbolKind = { + valueSet = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + }, -- All standard symbol kinds + }, + }, + diagnostic = { + workspaceDiagnosticsProvider = true, -- Enable workspace-level diagnostics + }, + }, +}) + +vim.lsp.config("*", { + capabilities = capabilities, + root_markers = { ".git" }, +}) + +vim.lsp.config("lua_ls", { + cmd = { "lua-language-server" }, + filetypes = { "lua" }, + root_markers = { ".luarc.json", ".luarc.jsonc" }, + settings = { + Lua = { + format = { + enable = true, + defaultConfig = { + indent_style = "tab", + indent_size = 1, + quote_style = "double", + max_line_length = 120 + }, + }, + runtime = { version = "LuaJIT" }, + diagnostics = { globals = { "vim", "luassert" }, enable = true }, + workspace = { + checkThirdParty = true, + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { enable = false }, + hint = { + enable = true, + setType = true, + paramType = true, + paramName = "All", + }, + }, + }, +}) + +vim.lsp.config("nil_ls", { + cmd = { "nil" }, + root_markers = { "flake.nix" }, + filetypes = { "nix" }, + settings = { + ["nil"] = { + formatting = { command = { "nixfmt" } }, + }, + }, +}) + +vim.lsp.config("ts_ls", { + cmd = { "typescript-language-server", "--stdio" }, + root_markers = { ".editorconfig", "jsconfig.json" }, + filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "vue" }, + init_options = { + preferences = { + disableSuggestions = false, + includeCompletionsForModuleExports = true, + }, + }, + capabilities = { + textDocument = { + formatting = false, + }, + }, + on_attach = function(client, bufnr) + client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentRangeFormattingProvider = false + end, +}) + +vim.lsp.config("ruff", { + cmd = { "ruff", "server" }, + root_markers = { "pyproject.toml" }, + filetypes = { "python" }, + init_options = { + settings = { + configurationPreference = "filesystemFirst", + fixAll = true, + lineLength = 100, + lint = { enable = true }, + organizeImports = true, + }, + }, +}) + +vim.lsp.config("dprint", { + cmd = { "dprint", "lsp" }, + filetypes = { "toml", "yaml", "markdown", "css" }, + settings = {}, +}) + +vim.lsp.config("clangd", { + cmd = { "clangd" }, + filetypes = { "c", "cpp" }, + root_markers = { + ".clangd", ".git" + }, +}) + +vim.lsp.config("vale_ls", { + cmd = { "vale-ls" }, + filetypes = { "markdown", "text", "tex", "rst", "adoc", "asciidoc" }, + root_markers = { ".vale.ini" }, +}) + +vim.lsp.config("ty", { + cmd = { "ty", "server" }, + root_markers = { "pyproject.toml" }, + filetypes = { "python" }, + settings = { + ty = { + diagnosticMode = "workspace", + experimental = { + rename = true, + autoImport = true, + completions = true, + }, + }, + }, +}) + +vim.lsp.config("rust_analyzer", { + cmd = { "rust-analyzer" }, + root_markers = { "Cargo.toml" }, + filetypes = { "rust" }, + settings = { + ["rust-analyzer"] = { + check = { + command = "clippy", + }, + }, + }, +}) + +vim.lsp.config("biome", { + cmd = { "biome", "lsp-proxy" }, + workspace_required = true, + filetypes = { + "graphql", + "javascript", + "json", + "html" + }, + root_markers = { "biome.json" }, + capabilities = { + textDocument = { + formatting = { + dynamicRegistration = false, + }, + }, + }, + single_file_support = false +}) + +vim.lsp.config("gopls", { + cmd = { "gopls" }, + root_markers = { "go.mod" }, + filetypes = { "go", "gomod", "gowork", "gotmpl" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, +}) + +vim.lsp.config("bashls", { + cmd = { "bash-language-server", "start" }, + filetypes = { "sh" }, +}) + +vim.lsp.config("texlab", { + cmd = { "texlab" }, + filetypes = { "tex", "plaintex", "bib" }, +}) + +vim.lsp.enable({ + "bashls", + "biome", + "clangd", + "dprint", + "gopls", + "lua_ls", + "nil_ls", + "ruff", + "rust_analyzer", + "texlab", + "ts_ls", + "ty", + "vale_ls", +}) -- cgit v1.2.3-70-g09d2