You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are providing some code actions, and some of them should be invoked on client side (like opening a new panel to display some guidelines about diagnostics).
The official workflow specified with protocol v3 is:
client invokes textDocument/codeAction
server returns an array of Command
user picks one command
client invokes workspace/executeCommand
So we end up on LS side, with no way to invoke a command on client side.
VSCode has a specific behavior. If a returned Command matches a command declared on VSCode side, it will not call workspace/executeCommand but instead directly invoke the client side command.
I find this very convenient, but this is not what is defined in protocol V3, and consequently not portable (Atom doesn't work like this for example, see atom/atom-languageclient#183).
Proposals:
officially support this behavior, but this maybe a bit too "magic" (what if client doesn't have a concept of command? can the LS be sure the command exists on client side?)
add a new executeCommand operation, in the direction LS -> client, allowing a server to explicitly request a client to execute a command (with proper capability declaration, error handling, ...)
to avoid extra round trip, maybe add a flag on the Command returned by textDocument/codeAction to precise if this is a client side or a server side command
Reacted by Shane Delmore, Alexey Alekhin, SPGoding, Fabio Zadrozny, Naoto Ono, Emil Valeev and Patt O'Brien
We have another use case where executing client-side commands would fill a gap. What we need is this bit of Julien HENRY (@henryju) 's proposal:
add a new executeCommand operation, in the direction LS -> client, allowing a server to explicitly request a client to execute a command (with proper capability declaration, error handling, ...)
Summary: what we are really after is mechanism for one language server process (i.e. eclipse.jdt.ls) to send a 'message' to another language server (i.e. sts4 spring-boot language server).
If the jdt.ls could execute a command on the client-side, and the sts4 language server registers itself as a handler for this command, this makes that kind of server <-> server communication possible.
to avoid extra round trip, maybe add a flag on the Command returned by textDocument/codeAction to precise if this is a client side or a server side command
I don't think this is necessary. In some sense all commands are 'client side' commands. But some client-side commands are implemented (on the client-side) by a handler that forwards them to a particular language server (because that server has registered itself as a handler for the command registerCapability). Therefore, I think the client knows exactly which commands exist (it contains the central command registry) and it also knows which commands it should handle locally itself and which it should forward to a particular server. So I think a flag to mark command as 'client-side' or 'server-side' explicitly is probably redundant.
There actually seems to be some disagreement around what is the correct way to interpret the spec. So all my talk above about commands being entered into some kind of 'central command registry' on the client side... This is maybe just my interpretation. Just an FYI. After becoming aware of the confusion, I raised ticket to try and get some clarification around the intended mechanics here: #432
Julien HENRY (@henryju) the commands returned from a code action or for example inside a code completion item must not necessarily be executed on the server. Only those commands are routed back to the server for which the server either return the id in the initialize response under executeCommandProvider or registered the command execution provider dynamically. All other commands can be handled on the client side. I am open to add a request from server -> client to trigger a command execution. Would be great to receive this as a PR following the guidelines here: https://github.com/Microsoft/language-server-protocol/blob/master/contributing.md
The clarification on #432 (= it is possible to execute any command from a code action, not only the one from the same server) are enough to me.
We currently don't have the need to run a command at a different moment (like Kris De Volder (@kdvolder) use case). So don't wait for me if you want to propose an addition to the protocol ;)
Activity
kdvolder commentedon Mar 21, 2018
We have another use case where executing client-side commands would fill a gap. What we need is this bit of Julien HENRY (@henryju) 's proposal:
See here for some details about our use case:
eclipse-jdtls/eclipse.jdt.ls#595
Summary: what we are really after is mechanism for one language server process (i.e.
eclipse.jdt.ls) to send a 'message' to another language server (i.e. sts4 spring-boot language server).If the jdt.ls could execute a command on the client-side, and the sts4 language server registers itself as a handler for this command, this makes that kind of server <-> server communication possible.
Some unrelated feedback on Julien HENRY (@henryju) proposals.
I don't think this is necessary. In some sense all commands are 'client side' commands. But some client-side commands are implemented (on the client-side) by a handler that forwards them to a particular language server (because that server has registered itself as a handler for the command registerCapability). Therefore, I think the client knows exactly which commands exist (it contains the central command registry) and it also knows which commands it should handle locally itself and which it should forward to a particular server. So I think a flag to mark command as 'client-side' or 'server-side' explicitly is probably redundant.
henryju commentedon Mar 22, 2018
I forgot the fact server was declaring commands he was able to handle, so indeed, no need for a special flag.
kdvolder commentedon Mar 22, 2018
There actually seems to be some disagreement around what is the correct way to interpret the spec. So all my talk above about commands being entered into some kind of 'central command registry' on the client side... This is maybe just my interpretation. Just an FYI. After becoming aware of the confusion, I raised ticket to try and get some clarification around the intended mechanics here: #432
dbaeumer commentedon Apr 9, 2018
Julien HENRY (@henryju) the commands returned from a code action or for example inside a code completion item must not necessarily be executed on the server. Only those commands are routed back to the server for which the server either return the id in the initialize response under
executeCommandProvideror registered the command execution provider dynamically. All other commands can be handled on the client side. I am open to add a request from server -> client to trigger a command execution. Would be great to receive this as a PR following the guidelines here: https://github.com/Microsoft/language-server-protocol/blob/master/contributing.mdSee also my comments in #432
henryju commentedon Apr 9, 2018
The clarification on #432 (= it is possible to execute any command from a code action, not only the one from the same server) are enough to me.
We currently don't have the need to run a command at a different moment (like Kris De Volder (@kdvolder) use case). So don't wait for me if you want to propose an addition to the protocol ;)