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

feat: add support for new LSP config API in Neovim 0.11+

Open umutondersu opened this issue 8 months ago • 31 comments

Summary

  • Added support for the new LSP configuration API introduced in Neovim 0.11+
  • Updated Mason version to v2

umutondersu avatar Apr 16 '25 17:04 umutondersu

Kickstart.nvim targets only the latest 'stable' and latest 'nightly' of Neovim.

Do we really need backward compatibility with Neovim 0 10? I'd consider going with a lighter, happy-path solution. Since the project mainly targets newcomers and servers educational purposes, they'd likely prefer to avoid dealing with legacy approaches.

ro0gr avatar Apr 17 '25 10:04 ro0gr

I think that would be the right approach as well. The reason I intended to maintain backwards compatibility is that some parts of the code is still trying to maintain 0.10 like the client_supports_method. Depending on the others reaction I would also be in favor of removing it.

umutondersu avatar Apr 17 '25 11:04 umutondersu

There is also the problem new syntax not supporting all lsp configs. For example tailwindcss requires the old setup. Could be a good idea to delay this until most lsp configs migrate.

umutondersu avatar Apr 17 '25 12:04 umutondersu

Hey everyone 👋 I remember a few related conversations that happen lately on this topic, let me share them here

https://github.com/nvim-lua/kickstart.nvim/issues/1458 https://github.com/nvim-lua/kickstart.nvim/issues/1331

I hope they can be useful, cheers ✌️

nickgnd avatar Apr 17 '25 13:04 nickgnd

Hey everyone 👋 I remember a few related conversations that happen lately on this topic, let me share them here

#1458 #1331

I hope they can be useful, cheers ✌️

  • This setup config does not clash with blink.cmp so in that sense It should be okay.
  • I would be able to support this in an ongoing basis
  • I think using the native way would provide a better experience for newbies but that's up to debate

umutondersu avatar Apr 17 '25 15:04 umutondersu

In my opinion, we shouldn't bother with backwards compatibility since Kickstart is mostly aimed at beginners who will download the latest version of Neovim as per the instructions in the repo readme

kaezrr avatar Apr 20 '25 04:04 kaezrr

I have removed backwards compatibility and added useful comments for LSPs that still require the old setup

umutondersu avatar Apr 20 '25 11:04 umutondersu

Messing around with this and found that this will not respect the lsp_format = "fallback" option in the conform.nvim config. To replicate:

  1. comment out the stylua formatter line from conform.nvim config
  2. save and reload neovim
  3. overindent a line or any other formatting change
  4. write file

For me it did not fallback on the lua_ls server for formatting.

iton0 avatar Apr 24 '25 06:04 iton0

Messing around with this and found that this will not respect the lsp_format = "fallback" option in the conform.nvim config. To replicate:

1. comment out the stylua formatter line from conform.nvim config

2. save and reload neovim

3. overindent a line or any other formatting change

4. write file

For me it did not fallback on the lua_ls server for formatting.

I couldn't replicate the issue. I do not think it would be related to these changes as conform.nvim does not use an LSP. In any case If you could check your conform logs by using :ConformInfo It could reveal more info about the issue.

umutondersu avatar Apr 24 '25 10:04 umutondersu

Messing around with this and found that this will not respect the lsp_format = "fallback" option in the conform.nvim config. To replicate:

1. comment out the stylua formatter line from conform.nvim config

2. save and reload neovim

3. overindent a line or any other formatting change

4. write file

For me it did not fallback on the lua_ls server for formatting.

I couldn't replicate the issue. I do not think it would be related to these changes as conform.nvim does not use an LSP. In any case If you could check your conform logs by using :ConformInfo It could reveal more info about the issue.

Accidentally commented out my lua_ls server lol. No longer issue

iton0 avatar Apr 24 '25 16:04 iton0

AFAIK mason-lspconfig setting's handler is a no-op. (PR) LSP settings are moved to after/lsp/<lang_server_name>.lua (credit; in JP) lsp-config doc also explains the config is merged with the default.

Note: The merge semantics of configurations follow the behaviour of vim.tbl_deep_extend().

I've been updating my old neovim configs with the latest kickstart but the LSP settings weren't reflected in :LspInfo, but after following the above, LSP correctly reads them

pandar00 avatar May 10 '25 08:05 pandar00

AFAIK mason-lspconfig setting's handler is a no-op. (PR) LSP settings are moved to after/lsp/<lang_server_name>.lua (credit; in JP) lsp-config doc also explains the config is merged with the default.

Note: The merge semantics of configurations follow the behaviour of vim.tbl_deep_extend().

I've been updating my old neovim configs with the latest kickstart but the LSP settings weren't reflected in :LspInfo, but after following the above, LSP correctly reads them

If we were to move LSP configs to their own file, I don't know how mason-tool-installer would work without the servers table maybe by iterating over file names?

In your config I see that you still have the servers table. If It is still gonna be preset wouldn't be better to use vim.lsp.config with a loop (like my first hunk) rather than having 2 separate places for LSP servers?

umutondersu avatar May 10 '25 17:05 umutondersu

As mentioned in previous conversations, Mason v2 has started introducing a significant delay during startup. For now, I’ve pinned the Mason version to avoid this issue.

From my testing, the problem appears to be related to mason-tool-installer; without it, I don’t experience any delays. It would be helpful to hear from someone with more insight into this before proceeding further with Mason v2.

umutondersu avatar May 10 '25 17:05 umutondersu

My personal temporary solution is to set debounce_hours in mason-tool-installer, to 24 in my case.

shv187 avatar May 10 '25 19:05 shv187

After the recent updates mason-tool-installer seems to not have this issue anymore. I will commit a change for Mason V2

umutondersu avatar May 11 '25 13:05 umutondersu

Currently I'm using the handlers in mason-lspconfig like this:

                handlers = {
                    function(server_name)
                        if server_name == "standardrb" or server_name == "rubocop" then
                            local personal_path = vim.fn.expand("~") .. "/programming/me"
                            local current_dir = vim.fn.getcwd()
                            local in_personal_project = string.find(current_dir, "^" .. personal_path) ~= nil

                            if
                                (server_name == "standardrb" and not in_personal_project)
                                or (server_name == "rubocop" and in_personal_project)
                            then
                                return
                            end
                        end

                        local server = servers[server_name] or {}

                        server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
                        require("lspconfig")[server_name].setup(server)
                    end,
                },

The purpose is to load standardrb only in personal projects and rubocop on others. How can I migrate this into new version?

tienbg-zigexn avatar May 12 '25 11:05 tienbg-zigexn

Currently I'm using the handlers in mason-lspconfig like this:

                handlers = {
                    function(server_name)
                        if server_name == "standardrb" or server_name == "rubocop" then
                            local personal_path = vim.fn.expand("~") .. "/programming/me"
                            local current_dir = vim.fn.getcwd()
                            local in_personal_project = string.find(current_dir, "^" .. personal_path) ~= nil

                            if
                                (server_name == "standardrb" and not in_personal_project)
                                or (server_name == "rubocop" and in_personal_project)
                            then
                                return
                            end
                        end

                        local server = servers[server_name] or {}

                        server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
                        require("lspconfig")[server_name].setup(server)
                    end,
                },

The purpose is to load standardrb only in personal projects and rubocop on others. How can I migrate this into new version?

Mason-lspconfig enables all installed LSPs by default, You can disable individual LSPs with vim.lsp.enable(server_name,enable) instead of returning.

umutondersu avatar May 12 '25 15:05 umutondersu

My config was broken until I added the changes from this PR. As far as I understand Mason v2 doesn't support the handler approach that was being used before, so none of my LSP configuration was actually being applied.

Graeme22 avatar May 27 '25 17:05 Graeme22

If this PR aims to only support nvim 0.11+, then it maybe also should remove the client_supports_method function?

Mithrandir2k18 avatar May 30 '25 18:05 Mithrandir2k18

Also, maybe I'm just blind, I didn't checkout the PR, but this name variable seems undefined?

Edit: my bad, I thought I was on the forks commit list, not on the PRs, where the commit order is inverted.

Mithrandir2k18 avatar May 30 '25 18:05 Mithrandir2k18

@Mithrandir2k18

If this PR aims to only support nvim 0.11+, then it maybe also should remove the client_supports_method function?

I started the PR supporting older versions as well, However most people thought it wasn't necessary because kickstart only support the latest neovim version and having cleaner code would be better for beginners.

I didn't touch the clients_supports_method as this pr is only focused on the new LSP API of neovim

Also, maybe I'm just blind, I didn't checkout the PR, but this name variable seems undefined?

It has been fixed. You are looking at an older version of the branch

umutondersu avatar May 30 '25 21:05 umutondersu

Kickstart.nvim targets only the latest 'stable' and latest 'nightly' of Neovim.

Do we really need backward compatibility with Neovim 0 10? I'd consider going with a lighter, happy-path solution. Since the project mainly targets newcomers and servers educational purposes, they'd likely prefer to avoid dealing with legacy approaches.

I personally love to keep the code free of legacy dependencies, but Ubuntu, Debian and some Fedoras don't yet have 0.11 , maybe someone familiar with the code could contribute an upgrade to the most common distros?

https://packages.ubuntu.com/search?keywords=neovim&searchon=names&suite=plucky&section=all

https://packages.debian.org/search?keywords=neovim&searchon=names&suite=stable&section=all

https://packages.fedoraproject.org/pkgs/neovim/neovim/

spundun avatar Jun 01 '25 08:06 spundun

Hi @spundun ,

Neovim also provides a prebuilt package: AppImage and tarball. We don't have to build Neovim for the distrubution. Please check out this link: https://github.com/neovim/neovim/releases/tag/v0.11.2

guru245 avatar Jun 01 '25 14:06 guru245

Hi @guru245 , Thanks for the response. That's a cool new thing I learned today :).

The README.md just says "If you are experiencing issues, please make sure you have the latest versions.". Since kickstart puts priority on being new-user-friendly, I'd suggest you add more detailed guidelines there. To many users, "make sure you have the latest version" might just mean making sure you have all the latest software updates from your package manager, especially if you're on the latest version of some standard OS.

Maybe adding detailed instructions along the lines... if nvim --version reports a version lower than the Required version then here are the instructions on how to install it in the user-file-system and set it as your editor before you begin.

spundun avatar Jun 01 '25 17:06 spundun

I spent way too long trying to figure out why inlay hints wouldn't appear anywhere! Turns out my LSP settings weren't even being loaded. I'm super glad I found this PR!

mybuddymichael avatar Jul 01 '25 17:07 mybuddymichael

any updates on this pr? the current implementation of mson-lspconfig doesn't work, handlers was removed in V2.

Ktsierra avatar Jul 23 '25 17:07 Ktsierra

I recommend #1663 over this PR.

It states clearly what it does, it does it correctly and stays to the point.

This one is actually dealing with mason-lspconfig 2.0, rather than nvim 0.11, does more than it says and pushes authors preferences.

logrusx avatar Aug 03 '25 17:08 logrusx

Is there anything major preventing this from being merged? I merged this patchset into my personal config and everything works fine.

NaniNoni avatar Aug 13 '25 19:08 NaniNoni

I just went down a rabbit hole of issues.

I initially thought the svelte-language-server had a bug which prevented me from importing through $lib, but it turns out it all boiled down to my kickstart-modular.nvim fork including this deprecated configuration, which prevented the passing of all defined lsp settings to the actual server.

Is there anything holding this back? There seem to be a few PR's open all attempting to addres the same issue, so I think it's fair to say that it should probably get some priority by now.

I'd love for this PR to be merged so it can propagate down to kickstart-modular and eventually my fork.

codevogel avatar Oct 15 '25 11:10 codevogel

Is there anything holding this back?

This repo is in limbo, perhaps https://github.com/nvim-lua/kickstart.nvim/pull/1627 can clear the situation up for you.

yetyetanotherusername avatar Oct 15 '25 12:10 yetyetanotherusername