-
Notifications
You must be signed in to change notification settings - Fork 185
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
Set completion trigger from label detail if present #2002
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I believe it provides two completions on purpose since, depending on user's code, one might be preferred over another . I suppose it works the same in vs code. Also it seems to be a pretty new feature so maybe it isn't supported in all possible cases in tsserver. Just guessing. |
* main: Prevent failing to load all configs when one fails Refactor symbol and completion item kinds (#2000) Add Godot (GDScript) LSP instructions Add preview for resource files in LocationPicker
I'm not really convinced that this would be a good solution. There is already the CompletionItem.filterText (or CompletionItem.label if filterText doesn't exist) to be used for the "trigger" field of ST autocompletion items. I think the example with And what if next time someone creates an issue like
Another solution to have the label details in the "trigger" field for a particular server, would be to use the new AbstractPlugin.on_server_response_async method to just replace the CompletionItem.filterText with label + label details for each completion item in the server response. |
I'm not convinced yet that this is the proper solution (or that it's better than the old one) but if your main argument is that it affects filtering then it seems like it also does affect filtering in VSCode so maybe it's not that bad after all. I'd need to see some specific case where it actually is noticeably worse before I'm convinced. |
For the record here is another case. Two completions: {
"commitCharacters": [
".",
",",
"("
],
"data": {
"entryNames": [
"banner"
],
"file": "/usr/local/workspace/github/typescript-language-server/rollup.config.ts",
"line": 13,
"offset": 16
},
"filterText": "banner",
"insertText": "banner",
"kind": 5,
"label": "banner?",
"sortText": "12\u0000banner\u0000"
},
{
"commitCharacters": [
".",
",",
"("
],
"data": {
"entryNames": [
{
"name": "banner",
"source": "ObjectLiteralMethodSnippet/"
}
],
"file": "/usr/local/workspace/github/typescript-language-server/rollup.config.ts",
"line": 13,
"offset": 16
},
"filterText": "banner",
"insertText": "banner() {\n $0\n},",
"insertTextFormat": 2,
"kind": 5,
"label": "banner?",
"labelDetails": {
"detail": "()"
},
"sortText": "12\u0000banner\u00001"
}, VSCode shows them as:
ST with code in this PR as:
because it prefers (Note that having |
Yeah, that is my main point and it surprises me that VSCode uses the label details for matching/filtering. Not sure if that is intended or could even be considered to be a bug in VSCode. Maybe we should ask in https://github.com/microsoft/language-server-protocol/issues to clarify whether the At least I'm not the only one who is skeptical: #1924 (comment)
Hm.. maybe LSP should entirely ignore I've also noticed an inconvenience with Pyright, that seems to be caused by using As a Sidenote, I believe you can/should replace the |
I believe there might be something else going on [actually you've mentioned that later also...]. I think it actually uses a separate
But that's two ST users who haven't even properly tried such change in practice for a decent amount of time so I'm not convinced yet. :)
I suppose that we would have to see the effects of such change in practice while testing various servers.
👍
👍 👍 |
How about the following proposal:
|
Maybe I've lost some context but can you explain the reasoning for the |
I think that would be the closest to how VSCode handles it, and it would be a compromise between "show detailed information in the trigger" and "use sensible matching algorithm". VSCode indeed doesn't seem to use the label details for matching, but the In general a server would use "filterText", if it wants to give additional information how a particular completion item should be matched (otherwise it could just omit it and according to the specs the client can fallback to "label"). So if we know that the I'm a bit doubtful that it is a good way how the TypeScript server uses "filterText", by including the A more conservative (in regard to the current behavior) alternative could also be: 2. If there are But this one wouldn't show the label details from the D server in the "trigger". |
For more context on this matter: see #990 (comment) Also see: microsoft/language-server-protocol#898 (comment) My takeaway from this is that Sublime is fundamentally different from VSCode in that it shows what the user is matching, while VSCode hides what the user is matching. We can try using LSP-label as ST-trigger if the LSP-label starts with LSP-filterText. I don't see how we can "dim" the LSP-label-details though. |
Hm, okay that could work. But then I think we could do the same with the LSP-label-details = I've made some tests with it and how I would implement it is at jwortmann@e8f6928. In the mentioned case of LSP-label + LSP-label-details as "trigger", it will also use the LSP-label-description (if present) as the "annotation". This should yield better results with the D server #1924 (comment) and follows the specs in regard that it should be "rendered less prominently after" LSP-label-details. It's quite annoying that various servers seem to use some fields differently or in unexpected ways. For example the Julia server doesn't use the labelDetails, but puts the whole function body into the regular |
I do like how it works (after testing for 5 minutes, mind you). |
@jwortmann do you want to create a PR with your changes? Alternatively I could adopt those here. |
No description provided.