Skip to content

Commit 07ce20d

Browse files
committed
fix: Update lsp configuration method for new mason version
For the discussion nvim-lua#1475 and for the actual change nvim-lua#1743
1 parent 765fcb4 commit 07ce20d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

init.lua

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,14 @@ require('lazy').setup({
639639
},
640640
}
641641

642+
for name, config in pairs(servers) do
643+
local config = config or {}
644+
-- This handles overriding only values explicitly passed
645+
-- by the server configuration above. Useful when disabling
646+
-- certain features of an LSP (for example, turning off formatting for ts_ls)
647+
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
648+
vim.lsp.config(name, config)
649+
end
642650
-- Ensure the servers and tools above are installed
643651
--
644652
-- To check the current status of installed tools and/or manually install
@@ -661,16 +669,6 @@ require('lazy').setup({
661669
require('mason-lspconfig').setup {
662670
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
663671
automatic_installation = false,
664-
handlers = {
665-
function(server_name)
666-
local server = servers[server_name] or {}
667-
-- This handles overriding only values explicitly passed
668-
-- by the server configuration above. Useful when disabling
669-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
670-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
671-
require('lspconfig')[server_name].setup(server)
672-
end,
673-
},
674672
}
675673
end,
676674
},
@@ -887,4 +885,4 @@ require('lazy').setup({
887885
},
888886
})
889887
-- The line beneath this is called `modeline`. See `:help modeline`
890-
-- vim: ts=2 sts=2 sw=2 e
888+
-- vim: ts=2 sts=2 sw=2

0 commit comments

Comments
 (0)