-
-
Notifications
You must be signed in to change notification settings - Fork 893
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
Make LSP completions resolve capabilities more spec-compliant #4609
base: master
Are you sure you want to change the base?
Make LSP completions resolve capabilities more spec-compliant #4609
Conversation
What would be a way to do it ? How does VS Code extension for rust analyzer implement it ? |
Unfortunately, I have no good pointers at how VSCode does this, but in case of Zed we are doing a mixture of two approaches:
I believe VSCode follows the complexity path, by trying to cache as many menu items as possible while the user types, predicting what has to be edited: e.g. We went with a simpler thing by re-querying the completion lists always, which lead us to excessive resolve queries — and even for the simple cases those were not instant, so there were noticed situations when a user may type and ask for autocomplete, which will take extra, very visible, fractions of second to execute due to resolve request + potential docs parsing took a while.
So, after trying various resolves, we've ended up using VSCode's resolve set in Zed: we force LSP servers to send us everything needed for the menu to be colored and ready to complete something useful at the caret position instantly. The server is faster to compute these properties in bulk (instead of menu item height number of resolve requests to make each time) and the editor can complete things almost instantly, with the additional text edits applied in the background, asynchronously. Those are usually imports, so at least for Rust this works quite well. Sorry, I'm not a Lisp person and do not understand what is wrong with the tests. |
Thanks for the detailed explanation!
I guess with your change (in lsp-mode) we are still not resolving additional text edits ?
They are just Emacs snapshot tests that are failing (which is expected). @jcs090218 Probably worth disabling tests in snapshot ? |
I suspect some odd things may be there based on the issue comments, but I'm not familiar with the codebase enough to say that. It seems though, that r-a works in lsp-mode in cases when imports are added through autocompletion. |
We already support resolving additional text edits and also documentation property as well. Also, instead of disabling detail resolve, we can actually resolve it asynchronously without affecting the latency for candidate list to show up. |
Closes #4591
Closes #4607
Part of rust-lang/rust-analyzer#18504
rust-analyzer started to be more spec-compliant when it comes to completion resolve:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion
So, if the editor declares a completion resolve support for the
documentation
, rust-analyzer as a server can omit it in the initial response and now it does so.According to #4591
Before rust-analyzer's change, it sent back every possible property.
Now, it starts to send back only things that are not declared in the completion resolve capabilities, as by the spec, the rest should be possible to get resolved later by the editor.
Apparently, despite the resolve capabilities declaration, Emacs lsp-mode client cannot properly resolve these, hence the PR restores the status-quo by making rust-analyzer to return these properties immediately, as it had been before.
Later, a better resolve mechanism may be implemented to resolve these, if needed.