-
Notifications
You must be signed in to change notification settings - Fork 389
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
[Feature] Clarify the parameter of callback in source.resolve #1327
Comments
|
This is not relevant to LSP spec but a client side specific problem. I'll try to explain it in more details here. But what if So here is just a semantic problem of a nil item returned from callback. Whether it means:
Currently cmp assumes 1 and 2, but cannot handle 3. |
Oh. I didn't know the LSP spec supported cancellation from the server side. Hmm... I don't mind removing the ability to treat a "null response" as success. |
I'm not sure if changing the fallback behavior will break some sources since it's now the source's responsibility to specify the resolve is success or failure. But I also think this is more reasonable because cmp should not make any assumption about the success status of sources at all. |
At least, currently nvim-cmp defines the typing that |
…indow * upstream/main: (29 commits) Setting local window options does not trigger the "OptionSet" event (hrsh7th#1415) Disable sort_text by default Fix locality sorting keymap.lua: Fix duplicate keymap detection (hrsh7th#1379) Fix hrsh7th#1322 Round up width/height for windows (hrsh7th#1373) convert encoding of range instead of start / end (hrsh7th#1364) Delete FUNDING.yml fix(api): consider multibyte characters in get_screen_cursor (cmdline) (hrsh7th#1352) Docs: Use tree-sitter language injection (hrsh7th#1350) Fix hrsh7th#1327 Fix hrsh7th#1329 Improve a bit Refactor a bit Fix hrsh7th#1321 Fix hrsh7th#1315 Fix hrsh7th#1249 feat: added scrollbar option to window.completition ( hrsh7th#1087) (hrsh7th#1308) Add a rule to install stylua and use the local one for other rules (hrsh7th#1307) LSP 3.17 (hrsh7th#1306) fix: type annotation for enabled field in ConfigSchema (hrsh7th#1299) ...
Relevant source
nvim-cmp/lua/cmp/source.lua
Lines 371 to 381 in 4c05626
The
item
parameter ofcallback
could benil
, and cmp will fallback it to the original item.nvim-cmp/lua/cmp/entry.lua
Lines 487 to 498 in 4c05626
And in
entry.resolve
, the returnedcompletion_item
will be always truthy andself.resolved_completion_item
will be set to that value either.The problem
Whether
source.resolve
returns a truthy item or nil, cmp will always assume the item is resolved successfully and will never trigger resolution twice. Take cmp-nvim-lsp for example:no-twice-resolve.mp4
If I quickly navigate menu down to let some resolution skipped (source here) and navigate back, the item resolution will not trigger again and the document still displays as the previous one's.
Possible solution?
cancel
orreject
to let the source decide which to call. Then cmp can use this information to determine whether resolution could be re-triggered.nil
item returned from source. Sinceself.resolved_completion_item
is kept asnil
, cmp will re-triggersource.resolve
as is. But this might be a slight breaking change? I'm not sure about it.The text was updated successfully, but these errors were encountered: