Skip to content

Commit a590ab6

Browse files
committed
fix(lsp): Remove backwards compatibility and add comments for lsp setup
1 parent 5502cea commit a590ab6

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

init.lua

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,6 @@ require('lazy').setup({
647647
},
648648
}
649649

650-
-- LSP servers and clients are able to communicate to each other what features they support.
651-
-- By default, Neovim doesn't support everything that is in the LSP specification.
652-
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
653-
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
654-
local capabilities = require('blink.cmp').get_lsp_capabilities()
655-
656650
-- Enable the following language servers
657651
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
658652
--
@@ -711,34 +705,31 @@ require('lazy').setup({
711705
})
712706
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
713707

714-
-- Handle lsp setups differently based on Neovim version
715-
-- See :help vim.lsp.config and :help vim.lsp.enable for Neovim 0.11+
716-
if vim.fn.has 'nvim-0.11' == 1 then
717-
for server, config in pairs(servers) do
718-
-- This handles overriding only values explicitly passed
719-
-- by the server configuration above. Useful when disabling
720-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
721-
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
722-
vim.lsp.config(server, config)
723-
vim.lsp.enable(server)
724-
end
725-
else
726-
-- For Neovim 0.10 and below, use mason-lspconfig for setup
727-
require('mason-lspconfig').setup {
728-
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
729-
automatic_installation = false,
730-
handlers = {
731-
function(server_name)
732-
local server = servers[server_name] or {}
733-
-- This handles overriding only values explicitly passed
734-
-- by the server configuration above. Useful when disabling
735-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
736-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
737-
require('lspconfig')[server_name].setup(server)
738-
end,
739-
},
740-
}
708+
-- Handle LSP setups
709+
-- See :help vim.lsp.enable
710+
for server, config in pairs(servers) do
711+
vim.lsp.config(server, config)
712+
vim.lsp.enable(server)
741713
end
714+
-- NOTE: Some servers still require the nvim-lspconfig setup until they are updated
715+
-- Use this template inside the for loop if you encounter issues with an lsp
716+
--
717+
-- if server == 'example_server' or server == 'example_server2' then
718+
-- -- This handles overriding only values explicitly passed
719+
-- -- by the server configuration above. Useful when disabling
720+
-- -- certain features of an LSP (for example, turning off formatting for ts_ls)
721+
-- local capabilities = require('blink.cmp').get_lsp_capabilities()
722+
-- config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
723+
-- require('mason-lspconfig')[server_name].setup(config)
724+
-- else
725+
-- vim.lsp.config(server, config)
726+
-- vim.lsp.enable(server)
727+
-- end
728+
--
729+
-- LSP servers and clients are able to communicate to each other what features they support.
730+
-- With nvim-lspconfig setup, Neovim doesn't support everything that is in the LSP specification.
731+
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
732+
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
742733
end,
743734
},
744735

0 commit comments

Comments
 (0)