Skip to content

Commit 0a56d5d

Browse files
committed
updated config for mason to v2
add changes introduced by nvim-lua#1663 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 a08e89d commit 0a56d5d

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

lua/kickstart/plugins/lspconfig.lua

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@ return {
266266
},
267267
}
268268

269+
-- The following loop will configure each server with the capabilities we defined above.
270+
-- This will ensure that all servers have the same base configuration, but also
271+
-- allow for server-specific overrides.
272+
for server_name, server_config in pairs(servers) do
273+
server_config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server_config.capabilities or {})
274+
vim.lsp.config(server_name, server_config)
275+
vim.lsp.enable(server_name)
276+
end
277+
269278
-- Ensure the servers and tools above are installed
270279
--
271280
-- To check the current status of installed tools and/or manually install
@@ -284,21 +293,6 @@ return {
284293
'stylua', -- Used to format Lua code
285294
})
286295
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
287-
288-
require('mason-lspconfig').setup {
289-
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
290-
automatic_installation = false,
291-
handlers = {
292-
function(server_name)
293-
local server = servers[server_name] or {}
294-
-- This handles overriding only values explicitly passed
295-
-- by the server configuration above. Useful when disabling
296-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
297-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
298-
require('lspconfig')[server_name].setup(server)
299-
end,
300-
},
301-
}
302296
end,
303297
},
304298
}

0 commit comments

Comments
 (0)