Skip to content

Execute client side command #430

Open
@henryju

Description

@henryju

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions