Skip to content

Commit e7827ae

Browse files
committed
Update LSP setup to use vim.lsp.config()
This fixes an issue where LSP configs were not being applied because the previous setup using `mason-lspconfig.nvim` was using the `handlers` setting, which has been removed in v2.0.0 in favor of the new native `vim.lsp.config()` API. Fix from nvim-lua/kickstart.nvim#1663
1 parent 140c74d commit e7827ae

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

dot_config/nvim/init.lua

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -639,20 +639,14 @@ require('lazy').setup({
639639
})
640640
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
641641

642-
require('mason-lspconfig').setup {
643-
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
644-
automatic_installation = false,
645-
handlers = {
646-
function(server_name)
647-
local server = servers[server_name] or {}
648-
-- This handles overriding only values explicitly passed
649-
-- by the server configuration above. Useful when disabling
650-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
651-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
652-
require('lspconfig')[server_name].setup(server)
653-
end,
654-
},
655-
}
642+
-- The following loop will configure each server with the capabilities we defined above.
643+
-- This will ensure that all servers have the same base configuration, but also
644+
-- allow for server-specific overrides.
645+
for server_name, server_config in pairs(servers) do
646+
server_config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server_config.capabilities or {})
647+
vim.lsp.config(server_name, server_config)
648+
vim.lsp.enable(server_name)
649+
end
656650
end,
657651
},
658652

0 commit comments

Comments
 (0)