-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: allow list of client ids or config names in LspRestart and LspStop #3438
Conversation
61b13d5
to
6439aca
Compare
local clients = vim.tbl_map(function(client) | ||
return ('%d:%s'):format(client.id, client.name) | ||
return ('%s'):format(client.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove id ? if there are multiple servers which does not support workspace folders, it will be difficult to distinguish which one want to stop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are saying that its possible to receive multiple entries like:
- 1 lua_ls
- 2 lua_ls
If that is the case than I will revert this.
Is there a way to show the completion with the id and name but on complete only pass the id so the user
only needs to hit enter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert . if you want complete with input id need imporve current custom complete and split cmdline content to get id then complete with server name
## Problems: - `:LspStop` doesn't support list of client ids or config names. - `:LspRestart` doesn't support config names although supports list of client ids - Command completion uses ids and names, not allowing the user to hit enter immediately after finding the desired server ## Solution: - Unify `LspStop` and `LspRestart` implementation supporting lists of client ids and config names - Command completion only returns config names - Modify docs
6439aca
to
b55037d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing I found that lua_ls didn't close on first LspStop
or LspRestart
. Should LspRestart
use force=true ?
nvim-lspconfig/plugin/lspconfig.lua
Line 104 in b55037d
client.stop() |
end | ||
|
||
local err_msg = '' | ||
arg = arg:gsub('[%a-_]+', function(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this enough to match all valid config names ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope.. some server file name without underline..Because there has been no standard in the past of the server file name, the naming has become arbitrary. It is best to use xx_ls. This can be refactored later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this matches server names without underscore too so that is not a problem. I meant if there are characters that I'm currently not matching that should be included.
This comment was marked as resolved.
This comment was marked as resolved.
With these changes both LspRestart and LspStop use the same parsing function, simplifying the LspStop code (went from 47 to 25 loc), and adding the possibility to use config name for LspRestart and error logging. Overall the diff is around the same loc.
In terms of added complexity in the parsing function, only error logging and substitution from
This was what motivate me to also add the list, because if it works correctly it would be very fast to autocomplete two Lsp Do you have any pointers how to fix it ? I presume that I can insert some logic when accepting a completion so it uses the id. Edit:
I'm still confused on what the problem would be if only the config name is used in the completion, given that nvim-lspconfig/plugin/lspconfig.lua Lines 105 to 107 in b55037d
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's try it. Hoping @guilhas07 will followup on any bugs :)
Co-authored-by: Justin M. Keyes <[email protected]>
🫡 |
Problems:
:LspStop
doesn't support list of client ids or config names.:LspRestart
doesn't support config names although supports list of client idsfinding the desired server
Solution:
LspStop
andLspRestart
implementation supporting lists of client ids andconfig names