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

fix: use lspconfig.util._available_servers #14

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

mimikun
Copy link
Contributor

@mimikun mimikun commented Jan 22, 2025

The lspconfig.util.available_servers has become a private function and it no longer works.
This PR will fix this.

ref: neovim/nvim-lspconfig@e118ce5
ref: folke/neoconf.nvim#105

@@ -7,7 +7,7 @@ return function()
return {}
end

local servers = lspconfig.util.available_servers()
local servers = lspconfig.util._available_servers()
Copy link
Owner

@creativenull creativenull Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks for the PR!

Would you be able to keep the previous function call and do a check for the new function?

Since this change is very recent (2 days ago from today) not many users would've updated the lspconfig plugin (like myself).

I think it's best to still keep the old function for some time before we rename it completely to the new _available_servers.

I'm thinking like the following conditional pseudocode:

  • If _available_servers is not nil then call it
  • Otherwise, call available_servers

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting an error where _available_servers is not available, If I'm in the older version of lspconfig.

image

I think it's best to compare if the function itself is defined instead of calling the function.

So check lspconfig.util._available_servers ~= nil (without the braces ())

Then servers = lspconfig.util._available_servers() (call the function) otherwise servers = lspconfig.util.available_servers()

@@ -7,7 +7,7 @@ return function()
return {}
end

local servers = lspconfig.util.available_servers()
local servers = lspconfig.util._available_servers()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting an error where _available_servers is not available, If I'm in the older version of lspconfig.

image

I think it's best to compare if the function itself is defined instead of calling the function.

So check lspconfig.util._available_servers ~= nil (without the braces ())

Then servers = lspconfig.util._available_servers() (call the function) otherwise servers = lspconfig.util.available_servers()

Copy link
Owner

@creativenull creativenull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the work you've done! o7

@creativenull creativenull merged commit 2062776 into creativenull:main Jan 27, 2025
@mimikun
Copy link
Contributor Author

mimikun commented Jan 28, 2025

I've been busy and haven't been able to comment.
Thank you for your review and advice.

@mimikun
Copy link
Contributor Author

mimikun commented Jan 28, 2025

This change was reverted in neovim/nvim-lspconfig#3589.
I think it's okay revert this commit itself, as in folke/neoconf.nvim#108.

@creativenull
Copy link
Owner

I think it's fine to leave as it is. Not sure if they will change their minds to go back to using the _ for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants