Skip to content

Commit ef49a17

Browse files
author
Ivan Ignatov
committed
Update to use new LSP configuration API in neovim v0.11+
Based off this kickstart.nvim PR: nvim-lua/kickstart.nvim#1475
1 parent 283a6b4 commit ef49a17

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

init.lua

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,6 @@ require("lazy").setup({
558558
end,
559559
})
560560

561-
-- LSP servers and clients are able to communicate to each other what features they support.
562-
-- By default, Neovim doesn't support everything that is in the LSP Specification.
563-
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
564-
-- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
565-
local capabilities = vim.lsp.protocol.make_client_capabilities()
566-
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
567-
568561
-- Enable the following language servers
569562
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
570563
--
@@ -598,8 +591,12 @@ require("lazy").setup({
598591
completion = {
599592
callSnippet = "Replace",
600593
},
601-
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
602-
-- diagnostics = { disable = { 'missing-fields' } },
594+
diagnostics = {
595+
-- Get the language server to recognize the `vim` global
596+
globals = { "vim" },
597+
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
598+
-- disable = { 'missing-fields' },
599+
},
603600
},
604601
},
605602
},
@@ -615,13 +612,20 @@ require("lazy").setup({
615612

616613
-- You can add other tools here that you want Mason to install
617614
-- for you, so that they are available from within Neovim.
618-
local ensure_installed = vim.tbl_keys(servers or {})
619-
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
615+
require("mason-tool-installer").setup({ ensure_installed = vim.tbl_keys(servers or {}) })
620616

621617
require("mason-lspconfig").setup({
622-
ensure_installed = ensure_installed,
623-
automatic_installation = true,
618+
automatic_enable = vim.tbl_keys(servers or {}),
624619
})
620+
621+
-- Installed LSPs are configured and enabled automatically with mason-lspconfig
622+
-- The loop below is for overriding the default configuration of LSPs with the ones in the servers table
623+
for server_name, config in pairs(servers) do
624+
vim.lsp.config(server_name, config)
625+
end
626+
627+
-- NOTE: Some servers may require an old setup until they are updated. For the full list refer here: https://github.com/neovim/nvim-lspconfig/issues/3705
628+
-- These servers will have to be manually set up with require("lspconfig").server_name.setup{}
625629
end,
626630
},
627631

0 commit comments

Comments
 (0)