Skip to content

Commit b14c245

Browse files
committed
Patch PR nvim-lua#1475 from upstream for LSP configs
2 parents d58c0da + 82949b8 commit b14c245

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

init.lua

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,6 @@ require('lazy').setup({
701701
},
702702
}
703703

704-
-- LSP servers and clients are able to communicate to each other what features they support.
705-
-- By default, Neovim doesn't support everything that is in the LSP specification.
706-
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
707-
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
708-
local capabilities = require('blink.cmp').get_lsp_capabilities()
709-
710704
-- Enable the following language servers
711705
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
712706
--
@@ -768,6 +762,11 @@ require('lazy').setup({
768762
},
769763
},
770764
}
765+
---@type MasonLspconfigSettings
766+
---@diagnostic disable-next-line: missing-fields
767+
require('mason-lspconfig').setup {
768+
automatic_enable = vim.tbl_keys(servers or {}),
769+
}
771770

772771
-- Ensure the servers and tools above are installed
773772
--
@@ -794,20 +793,14 @@ require('lazy').setup({
794793
})
795794
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
796795

797-
require('mason-lspconfig').setup {
798-
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
799-
automatic_installation = false,
800-
handlers = {
801-
function(server_name)
802-
local server = servers[server_name] or {}
803-
-- This handles overriding only values explicitly passed
804-
-- by the server configuration above. Useful when disabling
805-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
806-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
807-
require('lspconfig')[server_name].setup(server)
808-
end,
809-
},
810-
}
796+
-- Installed LSPs are configured and enabled automatically with mason-lspconfig
797+
-- The loop below is for overriding the default configuration of LSPs with the ones in the servers table
798+
for server_name, config in pairs(servers) do
799+
vim.lsp.config(server_name, config)
800+
end
801+
802+
-- NOTE: Some servers may require an old setup until they are updated. For the full list refer here: https://github.com/neovim/nvim-lspconfig/issues/3705
803+
-- These servers will have to be manually set up with require("lspconfig").server_name.setup{}
811804
end,
812805
},
813806

0 commit comments

Comments
 (0)