Emacs on windows, merlin mode, merlin server remote on linux, tramp, ssh

Running emacs on a windows box with no ocaml installation. But have tuareg, merlin, etc. in emacs.
Using tramp over ssh, can open a .ml file on a linux box.
I would like merlin mode to start and use a merlin server on the remote linux box.
(instead, tries to run ocmalmerlin on local windows box and fails)
Is this possible “out of the box”?
Or do I have to start an lsp server on linux box and talk to it via merlin (and is that worth trying)?
Thanks.
P.S. I was hopeful because running the ocaml repl seems to work – it runs ocaml on remote linux box.

I think under the hood merlin-mode works by calling out to the merlin binary via call-process-region which always runs on the local host rather than the remote host.

I haven’t tried it myself, but maybe you might have more luck with using lsp-mode? I’ve heard that lsp-servers play nicer when accessing them remotely.

I managed to set up Emacs + TRAMP + LSP to do remote development (not on the first attempt though, as these things were quite fiddly to set up).

Here’s what I got:

  1. You need opam install ocaml-lsp-server on the remote machine.
  2. Tell TRAMP to use path from the remote shell: (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
  3. Use Eglot as an LSP client. Although, lsp-mode claims that they support remote servers, I couldn’t quite make it work with lsp-mode. This is what I have in my init.el:
(require 'eglot)
(add-hook 'tuareg-mode-hook #'eglot-ensure)
3 Likes