Skip to content

Commit e40b599

Browse files
committed
fix(lsp): updated config for mason to v2
The mason-lspconfig.nvim plugin removed the 'handlers' feature in its v2.0.0 release. This change adapts the LSP configuration to follow the new recommended setup and keeps using the nvim-lspconfig api to configure the servers
1 parent 3338d39 commit e40b599

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

init.lua

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,15 @@ require('lazy').setup({
700700
},
701701
}
702702

703+
-- The following loop will configure each server with the capabilities we defined above.
704+
-- This will ensure that all servers have the same base configuration, but also
705+
-- allow for server-specific overrides.
706+
for server_name, server_config in pairs(servers) do
707+
server_config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server_config.capabilities or {})
708+
vim.lsp.config(server_name, server_config)
709+
vim.lsp.enable(server_name)
710+
end
711+
703712
-- Ensure the servers and tools above are installed
704713
--
705714
-- To check the current status of installed tools and/or manually install
@@ -718,21 +727,6 @@ require('lazy').setup({
718727
'stylua', -- Used to format Lua code
719728
})
720729
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
721-
722-
require('mason-lspconfig').setup {
723-
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
724-
automatic_installation = false,
725-
handlers = {
726-
function(server_name)
727-
local server = servers[server_name] or {}
728-
-- This handles overriding only values explicitly passed
729-
-- by the server configuration above. Useful when disabling
730-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
731-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
732-
require('lspconfig')[server_name].setup(server)
733-
end,
734-
},
735-
}
736730
end,
737731
},
738732

0 commit comments

Comments
 (0)