-
Notifications
You must be signed in to change notification settings - Fork 201
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
Problems with executing LSP commands #1219
Comments
I'm really happy it's working well for you :) I've just pushed a fix that should pass the resolved item to the execute |
Thank you for the help :) I've added the call to custom client commands and skipping brackets for items with a command that needs to be executed (as either the custom command or the LSP command will complete the item), but I still have a problem with the resolved item. It seems that the item is still not complete (misses the command) only for the first item that has a command. This happens for the first accepted item with a command like 4 out of 5 times. After that, the item always contains the command and works. It still works after changing buffers. I've checked that the item is indeed resolved in general and contains the command (the transformed_item has it). Do you have any hunch as to why that might be the case? edit: I've also increased the resolve timeout ms to a huge value thinking that maybe the server is somehow slow to resolve the first item with a command, but that was not the case edit2: Actually I've increased it even further (to 10 seconds) and now it seems to work. I think that the problem is on the server side and it's just painfully slow on the first resolve with a command. I'll investigate a bit more just to be sure, sorry for bothering you :) Showcase example in case it's not clear what I mean: 2025-02-15_16-24-01.mp4 |
Rather than skipping the auto brackets if the item contains a command, we should allow sources to opt-out of auto brackets, and add a Would also be good to add a note to the code about dropping the client implementation check on the command when we switch to supporting only v0.11+ |
It seems we can just use exec_cmd from lsp client instead of manually sending the lsp request. This one does the check. It was available in <0.11 as a "private" method (although it was already used in other parts of core neovim as a public api). Execute could look something like this if it's acceptable, I've seen there are other places in the codebase which check the neovim version. function lsp:execute(source, item, callback)
local client = vim.lsp.get_client_by_id(item.client_id)
local command_data = item.command
if not (client and command_data) then
callback()
return
end
if vim.fn.has('nvim-0.11') == 1 then
client:exec_cmd(command_data, { bufnr = source.bufnr }, function() callback() end)
else
-- TODO: remove this once 0.11 is the minimum version
client:_exec_cmd(command_data, { bufnr = source.bufnr }, function() callback() end)
end
end
I'm not sure what you mean, do you mean disabling the brackets for the LSP in general? Because in the case for Roslyn the server doesn't actually complete the brackets. This was needed because when using autobrackets and you want to accept the a completion like: public override void _Dro // accept _DropData(Vector2 atPosition, Variant data) The command executes and it becomes public override void _DropData(Vector2 atPosition, Variant data)
{
base._DropData(atPosition, data);
}() // extra brackets here For normal scenarios, the autobrackets added are needed. The LSP specs indeed says |
Is this related? neovim/neovim@f20335a This feature was just merged into Neovim core. |
Make sure you have done the following
blink.cmp
<C-k>
on https://cmp.saghen.dev)Bug Description
Related to the recently added #1130
Context:
There are some LSPs that give you a completion item with a command to execute for the completion to work, same story as #1148 (comment) :). Well, that's actually not even the full story. In this exact case mentioned before, the server actually gives you the name of the client command that needs to be executed and is implemented by the ..client. This can be done in neovim by setting
vim.lsp.commands[COMMAND_NAME]
like in this example. The vscode implementation needs to be replicated inroslyn.nvim
for override completions to work.Problem 1:
Neovim does not check every workspace/executeCommand request for a client implementation, but only those originating from specific parts of the core code. I wrote more about this in a neovim issue, but only the new neovim 0.11 completion was fixed and I think it's up for each completion plugin to check for client implementations before calling executeCommand themselves. I've started working on adding this functionality in blink.cmp, but I got stuck with the following issue
Problem 2: (FIXED & Tested that the resolved command arrives)
The
item
that arrives inlsp:execute
is incomplete. In my case, theitem
that I have aftercompletionItem/resolve
contains thecommand
parameter, while the item I get inlsp:execute
does not. This is a problem even without considering implementing the previous issue. Example:This is my transformed_item which contains the command:
This is my item which does not contain the command
P.S: I've just migrated from a "bloated" nvim-cmp configuration and I can't believe how much faster it feels and how fast it was to migrate everything :). Thank you for your work.
Relevant configuration
neovim
versionNVIM v0.11.0-dev-1756+gc091bc3b9a
blink.cmp
versionv0.11.0
The text was updated successfully, but these errors were encountered: