lsp

jkxyz 2025-02-05T18:52:58.638899Z

Hey! I'm trying to get clojure-lsp working via Tramp in Emacs. Using the default configuration with lsp-mode, it's able to start the server and connect to it. The code actions and formatting work fine. But commands like lsp-find-definition always report LSP :: Not found for: ->inst . Does anyone have any idea if I've missed some configuration options that should make this work? 🙏

ericdallo 2025-02-05T19:06:21.216859Z

I never tested clojure-lsp against remote filesystem and I suspect it should have multiple bugs, feel free to create issues with minimal repros I'm an emacs user but never tested TRAMP so have no experience with it

jkxyz 2025-02-05T20:06:29.357319Z

Yeah I realize it's an edge case. I had some luck with eglot working in a minimal project - it seems to work fine. But in a real project, it gets stuck after the server finishes initializing:

Tramp: Opening connection *EGLOT (nosco-gamma/(clojure-mode clojurescript-mode clojurec-mode clojure-ts-mode)) stderr* for josh@localhost using sshx...done
Tramp: Opening connection EGLOT (nosco-gamma/(clojure-mode clojurescript-mode clojurec-mode clojure-ts-mode)) for josh@localhost using sshx...done
[eglot] Waiting in background for server 'EGLOT (nosco-gamma/(clojure-mode clojurescript-mode clojurec-mode clojure-ts-mode))'
Tramp: Inserting '/sshx:josh@localhost:/home/josh/Code/Nosco/nosco-gamma/.gitmodules'...failed
File is missing: /sshx:josh@localhost:/home/josh/Code/Nosco/nosco-gamma/.gitmodules [2 times]
Tramp: Opening connection inotifywait for josh@localhost using sshx...done
Tramp: Opening connection inotifywait<1> for josh@localhost using sshx...done
[... repeated lines]
Tramp: Opening connection inotifywait<26> for josh@localhost using sshx...failed
[jsonrpc] Server exited with status 9
Error running timer: (error "Process EGLOT (nosco-gamma/(clojure-mode clojurescript-mode clojurec-mode clojure-ts-mode)) not running: killed
")
Error running timer: (error "Output file descriptor of EGLOT (nosco-gamma/(clojure-mode clojurescript-mode clojurec-mode clojure-ts-mode)) is closed")
The messages about .gitmodules are weird. There are no modules configured in the project. And it's strange that it tries to start inotifywait so many times

ericdallo 2025-02-05T22:53:41.495079Z

you should check for https://clojure-lsp.io/troubleshooting/#server-log and <https://clojure-lsp.io/troubleshooting/#client-server-log%7Cclient&lt;-&gt;server logs> to check if there is any exception

jkxyz 2025-02-06T12:07:46.628569Z

So I managed to dig deeper and fix this. It's not related to clojure-lsp, but sharing for posterity 🙂 The problem when using eglot is that it adds file watchers for every directory in the project: https://github.com/joaotavora/eglot/blob/master/eglot.el#L3844-L3847 And Tramp has some special handling for the file-notify package to handle watching files over remote connections. Basically it starts a new shell process running inotifywait each time: https://github.com/emacs-mirror/emacs/blob/ea04dd8ca93d609c0ee475c4acf58a56dfc0f1f3/lisp/net/tramp-sh.el#L3757 This maxes out at 25 concurrent Tramp connections. Which is sensible because you don't want to be running thousands of processes watching single directories. You just want a single recursive watcher on the project root. So I hacked around this in my config by overriding eglot's handler for didChangeWatchedFiles registration so that it only adds a single watcher to the project root, and eventually ends up calling inotifywait with the --recursive flag on the remote host. I think the real fix would be to add a new file-notify-add-watch-recursive function to Emacs, and add the necessary Tramp handlers for it. But now the setup works pretty great! I'm running Emacs natively on Windows and connecting to a project in WSL. Just as Richard Stallman intended. clojure-lsp is working great though!

ericdallo 2025-02-06T12:12:09.860509Z

got it, I think using lsp-mode this works out of the box, glad you found the issue

jkxyz 2025-02-06T12:17:32.714619Z

With lsp-mode, it starts and connects to the server, but none of the doc or xref functions seem to work. For instance I can't jump to a function definition or see args in the modeline. I'm happy using eglot for now though

👍 1