tools icon indicating copy to clipboard operation
tools copied to clipboard

📎 Add `lsp` command

Open MichaReiser opened this issue 2 years ago • 1 comments

Description

Rome offers a lsp server today that clients can connect to by opening the rome __print_socket socket.

However, not all editors have built-in support to connect to an LSP socket and, instead communicate with the LSP by reading/writing output to the LSP process stdout/stdin. The lack of Rome's support for an LSP that communicates via stdin/stdout can be worked around by using nc but having such capability backed into Rome would ease the integration into editors like vim, or Lapce.

Goal

Add a rome lsp or rome lsp-proxy command that starts an LSP server that communicates via stdin/stdout.

Implementation

The best place to implement this command would probably be in rome_cli/src/commands/daemon.rs, the proxy command would then need to:

  • Call service::ensure_daemon() make sure the server is running
  • Call service::open_socket() to get a connection to the server
  • Spawn two asynchronous tasks on a tokio Runtime to copy data from stdin to the socket's "write half", and from the socket's "read half" to stdout respectively (this should be as simple as calling tokio::io::copy in both tasks)
  • Synchronously block the main thread on the two joined asynchronous task

Source

MichaReiser avatar Oct 13 '22 10:10 MichaReiser

oh, I'll try to contribute code for the command.

xiaoxin-sky avatar Oct 14 '22 09:10 xiaoxin-sky