neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
9.98k stars 2.04k forks source link

fix: avoid overriding global default capabilities #3181

Closed frangio closed 1 month ago

frangio commented 1 month ago

A config's default_config acts as an override to the global default_config because of 'keep' here:

https://github.com/neovim/nvim-lspconfig/blob/38de86f82efd9ba0881203767d6a8e1815abca28/lua/lspconfig/configs.lua#L60

Some configs were providing the entire capabilities table in their default_config. This is not necessary because the global default_config already includes them, and it was causing any of the user's changes to be overridden.

https://github.com/neovim/nvim-lspconfig/blob/38de86f82efd9ba0881203767d6a8e1815abca28/lua/lspconfig/util.lua#L19

The specific issue I was facing was that globally setting snippetSupport = true was ignored for rust_analyzer.

glepnir commented 1 month ago

snippetSupport is true by default

frangio commented 1 month ago

That's not what I see. The return value of vim.lsp.protocol.make_client_capabilities says snippetSupport = false for me.

frangio commented 1 month ago

It was false until https://github.com/neovim/neovim/pull/27339 which was merged to master only yesterday.

glepnir commented 1 month ago

https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/protocol.lua#L741

I can't reproduce it show me true by default.

frangio commented 1 month ago

https://github.com/neovim/neovim/blob/v0.10.0/runtime/lua/vim/lsp/protocol.lua#L744

Snippet support is not the point of this PR. I want to be able to globally set the default config and have that apply to all providers. That isn't working for capabilities with some providers, and this PR fixes that.

glepnir commented 1 month ago

Snippet support is not the point of this PR.

? you said you set this but it overide.

and this will cause some default capabilities missing . there is not extend.

https://github.com/neovim/neovim/blob/7e44ab696a0488ad234b0915a8cf804fd6d79156/runtime/lua/vim/lsp/client.lua#L465

frangio commented 1 month ago

The default capabilities are set in util.lua: https://github.com/neovim/nvim-lspconfig/blob/b124ef3bd4435a6db7ff03ea2f5a23e1e0487552/lua/lspconfig/util.lua#L19

And they get combined with each config here: https://github.com/neovim/nvim-lspconfig/blob/b124ef3bd4435a6db7ff03ea2f5a23e1e0487552/lua/lspconfig/configs.lua#L60

So there shouldn't be any missing capabilities. As far as I could tell this is already how it's handled by most providers in lspconfig but the few included in this PR were not.

glepnir commented 1 month ago

thanks