Skip to content

Add socket support to connect to LS #280

Closed

Description

@fbricon

Only stdio is supported at the moment, for connecting to an LS. Add socket support.

Activity

  1. added
    enhancement
    on May 6, 2024
  2. angelozerr commented on Nov 4, 2026

    @angelozerr
    Contributor

    @muescha @lagergren @d-biehl are you interested to work on this issue?

    The main idea is to implement a new StreamwConnectionProvider and for user defined add a port UI which can be set or generated by getting free port.

  3. lagergren commented on Nov 5, 2026

    @lagergren
    Collaborator

    @angelozerr I'm happy to take this one. The first part is up as #1870: a SocketStreamConnectionProvider for plugin developers.

    While looking at it, I found that language servers take a socket connection in three ways, so the provider covers all three:

    • connectTo(host, port): the server already runs and listens, as in a debugger (Add ability to connect via network (ip:port) #658) or inside another application.
    • startAndConnect(port, commandLine): LSP4IJ starts the server, which listens on the port. This is how our DAP support connects today.
    • startAndAccept(port, commandLine): LSP4IJ listens and starts the server, which connects back. This is VS Code's socket transport (--socket=<port>), which servers built on vscode-languageserver expect, so it's the mode most socket-capable servers need.

    A port of 0 picks a free port, and the command line is built for it. The server's output goes to the LSP console log. If the connection or the process ends, that goes through the existing unexpected-stop handling.

    Next, I'd do the user-defined part you described as a second PR:

    • a transport choice in the server tab (stdio / connect to host:port / start and connect / start and accept);
    • host and port fields, with a free-port option;
    • ${port} in the command line, as in DAP;
    • template support.

    Does that split work for you? Also, should the free-port and readiness code be shared between DAP and LSP, or kept separate for now?

  4. lagergren commented on Nov 5, 2026

    @lagergren
    Collaborator

    Update: I folded both parts into #1870, so it now covers the whole issue. It has the SocketStreamConnectionProvider for plugin developers, plus the user-defined part you described: a Transport field in the Server tab with host and port, ${port} in the command with 0 for a free port, and a "socket" object in templates. The socket modes are marked experimental. The screenshots are in the PR description. The DAP/LSP sharing question above still stands: for now, the provider has its own small readiness retry, and like DAP it takes free ports from NetUtils.findAvailableSocketPort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions