From a590ab6c8812ade054cf0f444ee53c1b0daa98a3 Mon Sep 17 00:00:00 2001 From: Umut Sahin Onder Date: Sun, 20 Apr 2025 12:58:24 +0200 Subject: [PATCH] fix(lsp): Remove backwards compatibility and add comments for lsp setup --- init.lua | 57 ++++++++++++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/init.lua b/init.lua index 39839617..bde5d4ff 100644 --- a/init.lua +++ b/init.lua @@ -647,12 +647,6 @@ require('lazy').setup({ }, } - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. - local capabilities = require('blink.cmp').get_lsp_capabilities() - -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- @@ -711,34 +705,31 @@ require('lazy').setup({ }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } - -- Handle lsp setups differently based on Neovim version - -- See :help vim.lsp.config and :help vim.lsp.enable for Neovim 0.11+ - if vim.fn.has 'nvim-0.11' == 1 then - for server, config in pairs(servers) do - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) - vim.lsp.config(server, config) - vim.lsp.enable(server) - end - else - -- For Neovim 0.10 and below, use mason-lspconfig for setup - require('mason-lspconfig').setup { - ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) - automatic_installation = false, - handlers = { - function(server_name) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } + -- Handle LSP setups + -- See :help vim.lsp.enable + for server, config in pairs(servers) do + vim.lsp.config(server, config) + vim.lsp.enable(server) end + -- NOTE: Some servers still require the nvim-lspconfig setup until they are updated + -- Use this template inside the for loop if you encounter issues with an lsp + -- + -- if server == 'example_server' or server == 'example_server2' then + -- -- This handles overriding only values explicitly passed + -- -- by the server configuration above. Useful when disabling + -- -- certain features of an LSP (for example, turning off formatting for ts_ls) + -- local capabilities = require('blink.cmp').get_lsp_capabilities() + -- config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {}) + -- require('mason-lspconfig')[server_name].setup(config) + -- else + -- vim.lsp.config(server, config) + -- vim.lsp.enable(server) + -- end + -- + -- LSP servers and clients are able to communicate to each other what features they support. + -- With nvim-lspconfig setup, Neovim doesn't support everything that is in the LSP specification. + -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. end, },