Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of util.available_servers from public API in #3571 - recommended alternative? #3588

Closed
spanishpear opened this issue Jan 26, 2025 · 3 comments · Fixed by #3589
Closed
Labels
bug Something isn't working

Comments

@spanishpear
Copy link

Description

👋 Heya!

It seems that #3571 made util.available_servers a private function (as part of #2079), which is commonly used in user configurations to add capabilities to all servers.

For example - my configuration contains:

local language_servers = require("lspconfig").util.available_servers()
for _, ls in ipairs(language_servers) do
    require('lspconfig')[ls].setup({
        capabilities = capabilities, -- custom capabilities, excluded from snippet
        on_attach = on_attach, -- custom on_attach, excluded from snippet
        settings = servers[ls] -- map of settings per server , excluded from snippet
    })
end

Additionally - it's used/recommended in common community plugins - such as:

  • nvim-ufo minimal configuration here.
  • other examples from github search here

For now, I've migrated my personal config to simply use the private method, but is there a preferred alternative to achieve the same goal?
I may simply be missing an obvious API that allows me to do this - - so apologies if so :)

I've raised this as an issue, as the question template points to stack-overflow, which feels incorrect for a question for maintainers. Apologies if this is not the correct forum, I could not see a discussions tab.

Thank you!

@spanishpear spanishpear added the bug Something isn't working label Jan 26, 2025
@spanishpear spanishpear changed the title Removal of util. available_servers from public API in #3571 - recommended alternative? Removal of util.available_servers from public API in #3571 - recommended alternative? Jan 26, 2025
@dundargoc
Copy link
Member

Hmm, if this is useful enough it might warrant a core functionality. Or perhaps this is already possible to do with in core. @justinmk @gpanders any input?

@justinmk
Copy link
Member

justinmk commented Jan 26, 2025

Thanks for raising this, it helps to know what is actually being used.

(Side-note: available_servers is poorly named, it actually returns configs, which configure aspects of the client and the server.)

Nvim 0.11 advice

Starting with Nvim 0.11, the way to configure "all configs" is to use the special "*" name (see :help vim.lsp.config in Nvim 0.11):

vim.lsp.config('*', {
  capabilities = { … },
  settings = { … },
  on_attach = { … },
})

Nvim 0.10.x or older

  • We can restore the old name of util.available_servers() avoid disturbing people. Although by now most people may have already migrated, so renaming it again might be worse...
  • We should avoid breaking changes to lspconfig.util; instead, we want to ensure that it is 100% NOT needed for Nvim 0.11.
    • We are in the process of soft-deprecating the entire lspconfig.util module.
  • Years from now, when the minimum Nvim required for nvim-lspconfig is eventually increased to Nvim 0.11, then we can drop lspconfig.util.
  • Configs maintained in THIS repo must not use any part of lspconfig.util.

@justinmk
Copy link
Member

Additionally - it's used/recommended in common community plugins - such as:

  • nvim-ufo minimal configuration here.

Ok then we should restore the old name 😮‍💨

dundargoc added a commit to dundargoc/nvim-lspconfig that referenced this issue Jan 27, 2025
This reverts commit e118ce5.

It turns out `util.available_servers` is used more than anticipated, so
we revert the privatization for the time being.

Closes neovim#3588.
dundargoc added a commit to dundargoc/nvim-lspconfig that referenced this issue Jan 27, 2025
This reverts commit e118ce5.

It turns out `util.available_servers` is used more than anticipated, so
we revert the privatization for the time being.

Closes neovim#3588.
dundargoc added a commit to dundargoc/nvim-lspconfig that referenced this issue Jan 27, 2025
This reverts commit e118ce5.

It turns out `util.available_servers` is used more than anticipated, so
we revert the privatization for the time being.

Closes neovim#3588.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants