feat: add support for new LSP config API in Neovim 0.11+
This commit is contained in:
parent
d350db2449
commit
3f0cd75469
42
init.lua
42
init.lua
|
@ -711,20 +711,34 @@ require('lazy').setup({
|
|||
})
|
||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||
|
||||
require('mason-lspconfig').setup {
|
||||
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
|
||||
automatic_installation = false,
|
||||
handlers = {
|
||||
function(server_name)
|
||||
local server = servers[server_name] or {}
|
||||
-- This handles overriding only values explicitly passed
|
||||
-- by the server configuration above. Useful when disabling
|
||||
-- certain features of an LSP (for example, turning off formatting for ts_ls)
|
||||
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
||||
require('lspconfig')[server_name].setup(server)
|
||||
end,
|
||||
},
|
||||
}
|
||||
-- Handle lsp setups differently based on Neovim version
|
||||
-- See :help vim.lsp.config and :help vim.lsp.enable for Neovim 0.11+
|
||||
if vim.fn.has 'nvim-0.11' == 1 then
|
||||
for server, config in pairs(servers) do
|
||||
-- This handles overriding only values explicitly passed
|
||||
-- by the server configuration above. Useful when disabling
|
||||
-- certain features of an LSP (for example, turning off formatting for ts_ls)
|
||||
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
||||
vim.lsp.config(name, config)
|
||||
vim.lsp.enable(name)
|
||||
end
|
||||
else
|
||||
-- For Neovim 0.10 and below, use mason-lspconfig for setup
|
||||
require('mason-lspconfig').setup {
|
||||
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
|
||||
automatic_installation = false,
|
||||
handlers = {
|
||||
function(server_name)
|
||||
local server = servers[server_name] or {}
|
||||
-- This handles overriding only values explicitly passed
|
||||
-- by the server configuration above. Useful when disabling
|
||||
-- certain features of an LSP (for example, turning off formatting for ts_ls)
|
||||
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
||||
require('lspconfig')[server_name].setup(server)
|
||||
end,
|
||||
},
|
||||
}
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue