-
Notifications
You must be signed in to change notification settings - Fork 51
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
Respect vim.lsp.commands
, client.commands
, and server capabilities when executing CompletionItem.command
#73
base: main
Are you sure you want to change the base?
Conversation
I just noticed that cmp behaves weird in certain situations with this change applied. I'll keep this PR as a draft until I figure out why. |
Turns out that I actually had to copy and paste the logic inside the |
I think it's also worth talking about how I got here for the future googlers. The first symptom of this bug that this PR fixes was rust-analyzer flooding the LSP log file with this error message:
(and the manually formatted version for legibility:)
I found out that the Also, after this PR is applied, you'll probably see this warning when accepting a completion item from rust-analyzer (assuming you don't have the config discussed below), which I'm guessing will be googled in the future.
This is because the commands from completion items are now being handled properly and by default there's no handlers on the client (neovim) side for the vim.lsp.commands["rust-analyzer.triggerParameterHints"] = function()
vim.lsp.buf.signature_help()
end Alternatively, you can just do nothing and only get rid of the warning if you find the parameter hints annoying. vim.lsp.commands["rust-analyzer.triggerParameterHints"] = function() end If you don't want to modify the global command handlers, you can also put the handler in |
I understand your PR, but I'm not sure if the language server is returning If the language server sends a supported command without returning |
IMO, we should check |
Currently, when cmp-nvim-lsp receives a
CompletionItem
with aCommand
, it executes the command by directly making aworkspace/executeCommand
request.This behavior fails to respect the user-defined command handlers in
vim.lsp.commands
andclient.commands
, as well as whether the language server is capable of handling the command.This PR addresses this issue by using the
client:_exec_cmd()
method, which does respectvim.lsp.commands
,client.commands
, and server capabilities.I am aware that
client:_exec_cmd()
is probably meant to be a private method and that relying on it might become a problem in the future.However, I'm not sure if copying the whole method over to this plugin would be any better, and a quick search reveals that there are some plugins that do rely on
client:_exec_cmd()
.Please let me know if you have a better idea.