kickstart.nvim icon indicating copy to clipboard operation
kickstart.nvim copied to clipboard

I don't think lspconfig setup handlers are being called

Open nnathan opened this issue 8 months ago • 7 comments

I have the following config form kickstart (a few lsps/formatters installed myself), when I set clang cmd to "xxx" or lua cmd to "xxx", everything appears to work fine, indicating that they're not processing those lsp setup handlers -- any idea what is going on, I specifically need to change the clangd command so that I can supply custom include directories:

			-- Enable the following language servers
			--  Feel free to add/remove any LSPs that you want here. They will automatically be installed.
			--
			--  Add any additional override configuration in the following tables. Available keys are:
			--  - cmd (table): Override the default command used to start the server
			--  - filetypes (table): Override the default list of associated filetypes for the server
			--  - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
			--  - settings (table): Override the default settings passed when initializing the server.
			--        For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
			local servers = {
				clangd = {
					cmd = {
						"clangd",
					},
				},
				gopls = {},
				rust_analyzer = {},
				ruff = {
					init_options = {
						settings = {},
					},
				},
				vimls = {},
				jdtls = {},

				lua_ls = {
					-- cmd = { ... },
					-- filetypes = { ... },
					-- capabilities = {},
					settings = {
						Lua = {
							completion = {
								callSnippet = "Replace",
							},
							-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
							-- diagnostics = { disable = { 'missing-fields' } },
						},
					},
				},
			}

			-- Ensure the servers and tools above are installed
			--
			-- To check the current status of installed tools and/or manually install
			-- other tools, you can run
			--    :Mason
			--
			-- You can press `g?` for help in this menu.
			--
			-- `mason` had to be setup earlier: to configure its options see the
			-- `dependencies` table for `nvim-lspconfig` above.
			--
			-- You can add other tools here that you want Mason to install
			-- for you, so that they are available from within Neovim.
			local ensure_installed = vim.tbl_keys(servers or {})
			vim.list_extend(ensure_installed, {
				"ruff",
				"stylua",
				"shellcheck",
				"gofumpt",
				"goimports",
				"rust-analyzer",
				"shfmt",
				"stylua",
				"google-java-format",
			})
			require("mason-tool-installer").setup({ ensure_installed = ensure_installed })

			require("mason-lspconfig").setup({
				ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
				automatic_installation = true,
				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,
				},
			})
		end,
	},

nnathan avatar Jun 11 '25 06:06 nnathan

There are pending PRs addressing this.

rivenirvana avatar Jun 11 '25 06:06 rivenirvana

#1475

SetsuikiHyoryu avatar Jun 11 '25 09:06 SetsuikiHyoryu

See: https://github.com/nvim-lua/kickstart.nvim/pull/1590 (that builds on top of https://github.com/nvim-lua/kickstart.nvim/pull/1475)

rajive avatar Jul 04 '25 00:07 rajive

#1590 works great for me.

For other people finding this.. mason-lspconfig removed those options: https://github.com/mason-org/mason-lspconfig.nvim/blob/7815740f4d0afb74ada00956c36e18ad695ed9e3/CHANGELOG.md?plain=1#L25-L30

positron avatar Jul 13 '25 08:07 positron

#1590 works great for me.

For other people finding this.. mason-lspconfig removed those options: https://github.com/mason-org/mason-lspconfig.nvim/blob/7815740f4d0afb74ada00956c36e18ad695ed9e3/CHANGELOG.md?plain=1#L25-L30

I was wondering why my filetypes were not propagating to the LSPs - this explains it :)

Thank you all for your efforts on this amazing project!

tclaff avatar Aug 16 '25 08:08 tclaff

#1590 works great for me.

For other people finding this.. mason-lspconfig removed those options: https://github.com/mason-org/mason-lspconfig.nvim/blob/7815740f4d0afb74ada00956c36e18ad695ed9e3/CHANGELOG.md?plain=1#L25-L30

Thanks a lot! I’ve been wondering why changing my configuration doesn’t make any difference. Works fine now.

reiherj avatar Aug 20 '25 07:08 reiherj

for me the following is working: Replace require('lspconfig')[server_name].setup(server) by vim.lsp.enable( server_name ) and add the following loop direct after require('mason-lspconfig').setup {}:

for name, config in pairs(servers) do
	vim.lsp.config(name, config)
end

Also see

feekApp avatar Sep 23 '25 18:09 feekApp