1

Is it possible to have eglot use a language server running on my local machine to work on files on the remote machine?

I'm trying to edit TypeScript files on a remote server. I can visit the file just fine via TRAMP, and I can run commands like prettier on that buffer using the remote node modules. I'd like to avoid having to run the language server on the remote machine if possible, but this may be misunderstanding how TRAMP works.

Evan Davis
  • 148
  • 6

1 Answers1

4

You will need to run the LSP server on the machine where the source code is, because the LSP protocol is predicated on the server having access to all of the source code at once, as files on disk.

I don’t see much documentation about it, but I am given to understand that if you open your source code via TRAMP then Eglot will simply search the remote host for the LSP server program, rather than your own computer. If it finds it, it will simply run it there on the remote host as expected.

Alternatively, most LSP servers can be set up to run as a service that listens on a TCP port. You could configure your LSP server as a service on the remote host, and then configure Eglot to connect to that port instead of trying to run a program. You would probably also need to configure SSH to enable local forwarding to that port over your ssh connection. The LSP protocol is not itself encrypted or authenticated, so you wouldn’t want to allow just anyone to connect to it; don’t allow that port through your firewall.

db48x
  • 15,741
  • 1
  • 19
  • 23