Skip to content

Commit cd8e53b

Browse files
committed
Fix lspconfig
Based on nvim-lua#1475
1 parent 3bbe11f commit cd8e53b

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

lua/kickstart/plugins/lspconfig.lua

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,6 @@ return {
203203
},
204204
}
205205

206-
-- LSP servers and clients are able to communicate to each other what features they support.
207-
-- By default, Neovim doesn't support everything that is in the LSP specification.
208-
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
209-
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
210-
local capabilities = require('blink.cmp').get_lsp_capabilities()
211-
212206
-- Enable the following language servers
213207
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
214208
--
@@ -251,12 +245,16 @@ return {
251245
-- rubocop = {},
252246
standardrb = {},
253247
ruby_lsp = {
254-
cmd = {
255-
'~/.asdf/shims/ruby-lsp',
256-
},
248+
cmd = { vim.fn.expand '~/.asdf/shims/ruby-lsp' },
257249
},
258250
}
259251

252+
---@type MasonLspconfigSettings
253+
---@diagnostic disable-next-line: missing-fields
254+
require('mason-lspconfig').setup {
255+
automatic_enable = vim.tbl_keys(servers or {}),
256+
}
257+
260258
-- Ensure the servers and tools above are installed
261259
--
262260
-- To check the current status of installed tools and/or manually install
@@ -276,20 +274,14 @@ return {
276274
})
277275
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
278276

279-
require('mason-lspconfig').setup {
280-
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
281-
automatic_installation = true,
282-
handlers = {
283-
function(server_name)
284-
local server = servers[server_name] or {}
285-
-- This handles overriding only values explicitly passed
286-
-- by the server configuration above. Useful when disabling
287-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
288-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
289-
require('lspconfig')[server_name].setup(server)
290-
end,
291-
},
292-
}
277+
-- Installed LSPs are configured and enabled automatically with mason-lspconfig
278+
-- The loop below is for overriding the default configuration of LSPs with the ones in the servers table
279+
for server_name, config in pairs(servers) do
280+
vim.lsp.config(server_name, config)
281+
end
282+
283+
-- 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
284+
-- These servers will have to be manually set up with require("lspconfig").server_name.setup{}
293285
end,
294286
},
295287
}

0 commit comments

Comments
 (0)