-
-
Notifications
You must be signed in to change notification settings - Fork 897
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
Declare labelDetailsSupport client capability #4644
Conversation
ac31b09
to
650e8c9
Compare
650e8c9
to
965e81e
Compare
Thanks! |
Here's an example of rust-analyzer's completions output:
The corresponding Company popup looks like this: Here's the same in VS Code: Could
That leaves the issue of not having the last part aligned to the right, but other than that it seems the author's intent that the most prominent note is about the package not having been imported yet. And when you pick that completion, the |
That's a bug in R-A under discussion in the zulip thread. They've reversed the detail and the description. On R-A stable, I guess you can turn off |
That might be true, but do you disagree that the RA popup's behavior in VS Code seems to make sense? The hint about the |
Yes and no. I see what they are trying to do, but the constraints of the LSP spec doesn't allow them cramp everything into the completion item structure. They are going to have to figure out some combination of appending to the label, detail and label details for the kind of things they want to achieve. Besides the types, they have package FQN, doc alias, traits, and snippet descriptions. There are probably more that I'm missing but trying to fit them all into 3 - 4 properties is going to be a challenge and they will have to make some tradeoffs. |
Sorry, I don't understand.
They use the extra two properties documented in CompletionItemLabelDetails, which VS Code picks up and shows. Why shouldn't we show them too? As of now, we never show the value contained in |
I've updated to #4625 to show it just a couple of hours ago. I'm testing with various servers, bear with me :) In short, even with the latest in #4625, it's not enough to show everything they want to show. They'll have to make some sacrifices in R-A. That's story for another day, or you can look at their code if you've got the time. |
Great! Thanks. |
not sure whether this is this change or something else, but at least for rust this is degression in usability. E.g. now, I see After partly reverting this patch (the which lists all possible Inspecting IO log shows that LSP server returns a full list: [Trace - 12:23:06 PM] Received response 'textDocument/completion - (478)' in 22ms.
Result: {
"isIncomplete": true,
"items": [
{
"label": "Result<…>",
"labelDetails": {
"detail": "(use clap::error::Result)"
},
...
{
"label": "Result",
"labelDetails": {
"detail": "(use std::fmt::Result)"
},
...
{
"label": "Result<…>",
"labelDetails": {
"detail": "(use std::io::Result)"
},
...
{
"label": "Result<…>",
"labelDetails": {
"detail": "(use std::thread::Result)"
},
...
{
"label": "Result<…>",
"labelDetails": {
"detail": "(use crate::Result)"
},
|
While #3495 claimed
labelDetails
was implemented, it really wasn't because the client capability was never declared, so AFAICT, servers do not send them down.Servers tested against:
labelDetails
)labelDetails
)labelDetails
)labelDetails
fully, spec compliant)labelDetails
, but theCompletionItemLabelDetails#description
property is never filled in, so it's a noop as far as lsp-mode is concerned, but still spec compliant)labelDetails
, but the signature is inCompletionItemLabelDetails#description
, not spec compliant)P.S. For jdtls, the annotation function will return a really long partly qualified method signature for
CompletionItem#detail
, concatenated to the return type, which is theCompletionItemLabelDetails#description
. To avoid this verbosity and duplication of information, the users are advised to do this:P.P.S rust-analyzer's implementation for
labelDetails
has always been wrong in all channels as of 2024-12-17, but wrong in a way that incidentally can alleviate #4591. If and when the R-A team decides to collectively sit down, study and implement the spec properly, we can see if there's any adjustment we need to do, but otherwise I assume the user can do their own adjustments similar to jdtls.