diff options
Diffstat (limited to '.config/nvim/lua/lsp.lua')
-rw-r--r-- | .config/nvim/lua/lsp.lua | 148 |
1 files changed, 77 insertions, 71 deletions
diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index 07aeac2..2591a8b 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -1,6 +1,16 @@ --- Setup nvim-cmp. local cmp = require("cmp") +local lspconfig = require("lspconfig") +local cmplsp = require("cmp_nvim_lsp") +local lsp_inlayhints = require("lsp-inlayhints") +local lsp_signature = require("lsp_signature") +local dap = require("dap") +local dapui = require("dapui") +local omnisharp_extended = require("omnisharp_extended") +local deno_nvim = require("deno-nvim") +local lspkind = require("lspkind") +local cmp_types = require("cmp.types") +-- Setup nvim-cmp. cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine @@ -23,23 +33,20 @@ cmp.setup({ { name = "nvim_lsp"; entry_filter = function(entry) - return require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] ~= - "Text" + return cmp_types.lsp.CompletionItemKind[entry:get_kind()] ~= "Text" end; }; { name = "vsnip"; entry_filter = function(entry) - return require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] ~= - "Text" + return cmp_types.lsp.CompletionItemKind[entry:get_kind()] ~= "Text" end; }; }, { { name = "buffer"; entry_filter = function(entry) - return require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] ~= - "Text" + return cmp_types.lsp.CompletionItemKind[entry:get_kind()] ~= "Text" end; }; }); @@ -65,7 +72,6 @@ cmp.setup.cmdline(":", { }) -- Setup lspconfig. -local cmplsp = require("cmp_nvim_lsp") local capabilities = vim.lsp.protocol.make_client_capabilities() cmplsp.default_capabilities(vim.lsp.protocol.make_client_capabilities()) -- Enable (broadcasting) snippet capability for completion @@ -73,7 +79,7 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true cmp.setup({ formatting = { - format = require("lspkind").cmp_format({ + format = lspkind.cmp_format({ mode = "symbol"; -- show only symbol annotations maxwidth = 50; -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) @@ -87,10 +93,9 @@ cmp.setup({ local on_attach = function(client, bufnr) vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - local lsp_signature = require("lsp_signature") lsp_signature.on_attach({ bind = true }, bufnr) - require("lsp-inlayhints").setup() - require("lsp-inlayhints").on_attach(client, bufnr, false) + lsp_inlayhints.setup() + lsp_inlayhints.on_attach(client, bufnr, false) if client.server_capabilities.semanticTokensProvider then client.server_capabilities.semanticTokensProvider = nil end @@ -104,11 +109,10 @@ vim.api.nvim_create_autocmd("LspAttach", { local bufnr = args.buf local client = vim.lsp.get_client_by_id(args.data.client_id) - require("lsp-inlayhints").on_attach(client, bufnr, false) + lsp_inlayhints.on_attach(client, bufnr, false) end; }) -local lspconfig = require("lspconfig") local lsputils = lspconfig.util lspconfig.tsserver.setup({ @@ -140,26 +144,27 @@ lspconfig.tsserver.setup({ }; }) --- require("deno-nvim").setup({ --- server = { --- root_dir = vim.loop.cwd; --- capabilities = capabilities; --- on_attach = on_attach; --- settings = { --- deno = { --- unstable = true; --- inlayHints = { --- enumMemberValues = { enabled = true }; --- functionLikeReturnTypes = { enabled = true }; --- parameterNames = { enabled = "all" }; --- parameterTypes = { enabled = true }; --- propertyDeclarationTypes = { enabled = true }; --- variableTypes = { enabled = true; suppressWhenTypeMatchesName = false }; --- }; --- }; --- }; --- }; --- }); +deno_nvim.setup({ + server = { + -- Uncomment to allow all js/ts files, not just in a deno context + -- root_dir = vim.loop.cwd; + capabilities = capabilities; + on_attach = on_attach; + settings = { + deno = { + unstable = true; + inlayHints = { + enumMemberValues = { enabled = true }; + functionLikeReturnTypes = { enabled = true }; + parameterNames = { enabled = "all" }; + parameterTypes = { enabled = true }; + propertyDeclarationTypes = { enabled = true }; + variableTypes = { enabled = true; suppressWhenTypeMatchesName = false }; + }; + }; + }; + }; +}); lspconfig.rust_analyzer.setup({ capabilities = capabilities; @@ -169,9 +174,7 @@ lspconfig.rust_analyzer.setup({ lspconfig.omnisharp.setup({ cmd = { "omnisharp" }; - handlers = { - ["textDocument/definition"] = require("omnisharp_extended").handler; - }; + handlers = { ["textDocument/definition"] = omnisharp_extended.handler }; on_attach = on_attach; capabilities = capabilities; @@ -217,17 +220,18 @@ lspconfig.omnisharp.setup({ -- capabilities = capabilities; -- }) --- lspconfig.jsonls.setup({ --- capabilities = capabilities; --- cmd = { "vscode-json-language-server"; "--stdio" }; --- on_attach = on_attach; --- }) +lspconfig.jsonls.setup({ + capabilities = capabilities; + cmd = { "vscode-json-language-server"; "--stdio" }; + on_attach = on_attach; +}) --- lspconfig.html.setup({ --- capabilities = capabilities; --- cmd = { "vscode-html-language-server"; "--stdio" }; --- on_attach = on_attach; --- }) +lspconfig.html.setup({ + capabilities = capabilities; + cmd = { "vscode-html-language-server"; "--stdio" }; + on_attach = on_attach; + settings = { html = { format = { indentInnerHtml = true } } }; +}) -- lspconfig.cssls.setup({ capabilities = capabilities; on_attach = on_attach }) @@ -266,36 +270,38 @@ lspconfig.jdtls.setup({}) lspconfig.jedi_language_server.setup({}) -local null_ls = require("null-ls") - -null_ls.setup({ - sources = { - -- null_ls.builtins.diagnostics.eslint; - -- null_ls.builtins.formatting.eslint; - null_ls.builtins.formatting.lua_format; - -- null_ls.builtins.formatting.prettier; - null_ls.builtins.formatting.rustfmt; - -- null_ls.builtins.code_actions.shellcheck; - -- null_ls.builtins.completion.spell; - -- null_ls.builtins.diagnostics.tsc; - -- null_ls.builtins.formatting.deno_fmt; - -- null_ls.builtins.code_actions.gitsigns.with({ - -- config = { - -- filter_actions = function(title) - -- -- filter out blame actions - -- return title:lower():match("blame") == nil - -- end; - -- }; - -- }); - }; -}) +lspconfig.gopls.setup({}) + +-- Deprecated +-- local null_ls = require("null-ls") + +-- null_ls.setup({ +-- sources = { +-- -- null_ls.builtins.diagnostics.eslint; +-- -- null_ls.builtins.formatting.eslint; +-- null_ls.builtins.formatting.lua_format; +-- -- null_ls.builtins.formatting.prettier; +-- null_ls.builtins.formatting.rustfmt; +-- -- null_ls.builtins.code_actions.shellcheck; +-- -- null_ls.builtins.completion.spell; +-- -- null_ls.builtins.diagnostics.tsc; +-- -- null_ls.builtins.formatting.deno_fmt; +-- -- null_ls.builtins.code_actions.gitsigns.with({ +-- -- config = { +-- -- filter_actions = function(title) +-- -- -- filter out blame actions +-- -- return title:lower():match("blame") == nil +-- -- end; +-- -- }; +-- -- }); +-- }; +-- }) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded"; relative = "cursor" }) -- Debugging -local dap, dapui = require("dap"), require("dapui") dap.adapters.netcoredbg = { type = "executable"; command = "netcoredbg"; |