-
Notifications
You must be signed in to change notification settings - Fork 846
Specification to open a second completion after apply a completion item #565
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
Comments
I think this can be covered by using placeholder and choices which are already specified for completion. |
Actually, as I'm thinking about it, I don't think we need the protocol to state something about it: if there is a placeholder, it's most likely that user will probably want to edit it, and if user wants to edit it, why wouldn't the client ask for another completion? |
There is a However, it's not clear how this could work with LSP since that command is VS Code-specific. I guess if you're implementing both the LSP server and the plugin the wraps it for an editor, you could send a custom command and then map it on to the appropriate thing for each editor, but it's messy. |
@tsmaeder told me that it exists a specification for snippet choice https://github.com/Microsoft/language-server-protocol/blob/master/snippetSyntax.md#choice @mickaelistria I'm not sure that LSP4e implement that ? I think it's a good idea for values which not require complex computing. For other case like Java completion apply, I think it should be better to call a command. We could have a syntax snippet like this:
|
There's already a |
Eclipse LSP4E implements snippet choice IIRC. But anyway, I still stand with my former command #565 (comment) : there is nothing preventing the client from invoking content assist at the location of placeholders and I don't think we need addition in LSP spec to do that. |
That's strange, I have tested with lsp4xml, but it doesn't work? Where is the supposed code which manages the open of the second completion popup with choice values? |
Sorry you're right. Eclipse LSP4E has support for linked regions but not yet for snippet proposals. Feel free to open a new bug to LSP4E for that (and even for re-triggering completion when on another region and no snippet proposal is found); but still I don't think the spec needs anything more. |
Looks like this doesn't need any addition in the spec. Any objection to close the issue? |
@dbaeumer Actually, I think my comment above may be incorrect. Thinking again, it's not clear whether the I assumed you could put Can you clarify which it is - is |
Actually, the spec does say this!
And the thing that decides which commands should be sent to the server versus executing in the client plugin is ExecuteCommandOptions. TL;DR - putting |
The server in some respect relies on capabilities on the client side. These are commands which are not handled by the server itself and settings (getConfiguration call send from the server to the client). The current advice is that a server specs these and that the client plugin needs to do these transformations (for example map the settings to their settings store). I am not a big fan of starting to spec editor commands since this can be very specific to a tool / UI. |
Yeah, I think what is there is fine now I understand it better. That said, I think there's still something ambiguous. The description of However, for CodeAction the text says:
It's not clear whether the client should send the command from the CodeAction to the server always, or whether it should handle it locally if it's not listed in |
@DanTup actually no. The idea of this sentence was to avoid to execute local editor commands. I will clarify this. |
@dbaeumer I'm not sure I follow - does this mean it's not allowed to execute local commands in code fixes? (If not, that somewhat throws a spanner in the works for the discussion on the "ask for user input" issue 😕) |
@DanTup if you expect the server to run in different clients then executing the command will very likely fails unless we standardize commands which I am actually not a fan of. Or do I misunderstand something? |
@dbaeumer No, that's right - but the spec already explicitly mentions this:
This is what #642 is about (ignoring the misleading title) - I think the client capabilities should include the command IDs the client extension supports, so the server can act appropriately. There's no need for LSP to standardise them, they should be documented by as LSP server as extra functionality that can be provided if the client provides the required local functionality. |
As commented on the other item this sentence was added when a server had no way to handle commands. I will change this to indicate that the best way is to execute a command on the server. |
I think I somewhat derailed this thread. I don't think the original request is resolved anymore, since the server shouldn't rely on being able to using |
I want to use something like this to implement "multi-stage autocompletion", for example: To record this gif I used the hack @DanTup suggested. It'd be nice to have a client-agnostic solution for this. |
To revive the discussion, I propose we add a new LSP snippet variable For example, say you have
Completing to
A problem arises if the user needs multiple completions to fill in a single argument. For example, they want to enter To be backwards compatible with clients that don't support COMPLETE, you can pass the existing placeholder value as the default value for the $COMPLETE variable. For example: |
Interesting idea. The only problem I see is that this makes the snippets deviate from TextMate snippets which we tried to avoid so far. I would suggest that we open a separate issue for the snippet idea since I see this independent from this request. I don't want to ask users to generate snippets if they want to trigger a second code completion call after inserting a completion item. |
When would the user need to generate a snippet? In my proposal the LSP server generates the snippets with $COMPLETE, not the user.
I was trying to propose a concrete way to implement the desired behavior. It seems natural to use snippets since otherwise it would be very clunky for a single completion item to control multiple completion triggers. |
I meant users of the library. |
One feature that I love when I write code is the completion apply which opens a second completion popup which suggests the values that you can insert after completion apply.
Here a Java demo which defines 2 int variables (i and j). When substring method completion is applied, it suggest completion popup for the substring parameters which are int.
There are other usecases like HTML/XML (when completion for attribute is applied, it suggest values for attribute values, etc).
It should be cool if LSP could specify a new protocol to manage that (by extending completionItem/resolve?)
The text was updated successfully, but these errors were encountered: