-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Poor trigger characters for the language server #1894
Comments
Also:
|
This logic is built into getAutocompleteSelections! There is in fact autocomplete for these characters in language interface, which is used by both the language server and graphiql |
I don't quite understand what are you referencing here. :) Is this is some sort of developer note on how this could be fixed? |
Yes I will add notes. We need to add additionalTextItems or whatever they are called. I am planning a whole writeup on how to implement this for both language server and monaco and i think i have an issue already. The vscode-json-languageservice provides a great reference implementation |
Do note that this needs to be done carefully to avoid triggering completions too eagerly. For example it might not be the best idea to trigger on typing Unfortunately the LSP spec is not very flexible in that area since the triggers are only character-based. So it might not be that easy or even possible to define good triggers for completing fields, for example. |
additionalTextEdits is the answer I assure you. Please review the completion support in vscode-json-languageservice to see how they use this feature |
I have already gotten it working partially in experiments. Trigger characters setting does not do what you think. Additional text items is how we evaluate this on a per token basis |
For example, in monaco graphql this weekend i had an experiment where any time a user selected an object or list stype field from completion, it would automatically expand braces and insert the cursor in between the braces. That’s what you’re talking about in vscode right? see how the vscode-json-languageservice passes on these additional items in it’s completion to monaco-json and vscode differently. |
I'm a LSP client developer for ST so I "more or less" know how those things work.
When mentioning |
@rchl I think I understand better now what you mean. I thought you were talking about a different feature. What do you suggest we use for trigger characters? |
@rchl I would be happy to work with this on you! our language interface |
For example user types:
where the cursor is at I think it would make sense to have at least
But it should be tested in practice because it can get in a way if done for wrong characters. Here are some trigger characters set by other servers for reference: Of course which trigger characters fit depends on the syntax so I'm not suggesting to just copy any of those. |
I don't know how |
@rchl I was wrong that as per also, as per the unrelated discussion about |
|
|
I think most users seem happy with the current trigger characters. If you think of any others that aren't represented or are having issues with ones that are, please open a new ticket! |
Currently the only registered trigger character for the language server is
@
:graphiql/packages/graphql-language-service-server/src/MessageProcessor.ts
Line 168 in 65aa648
I think there are many cases when automatically triggering completions would be beneficial. For example when typing
{
to select fields of an object or when typing(
after field name to specify the arguments to pass). None of those currently trigger auto-completion which means that the user has to trigger it manually with a shortcut.The text was updated successfully, but these errors were encountered: