Fork me on GitHub
#lsp
<
2024-08-10
Nazral11:08:07

Hi! Is it possible to connect remotely to clojure-lsp? Usecase is that I have a machine which doesn't support the graalvm, but I can run clojure-lsp on a different box / a vm

borkdude11:08:18

Which machine is this if I may ask? You can use clojure-lsp as jar file as well, you don't need to use the binary necessarily

Nazral11:08:40

I'm running openbsd

Nazral11:08:58

thank you!

borkdude11:08:08

I'm not sure if you need the standlone or the server one...

borkdude11:08:14

FWIW I always run clojure-lsp from source combined with clj-kondo from source (since I want to see my development changes locally). How to do this, search on this page: https://github.com/clj-kondo/clj-kondo/blob/master/doc/editor-integration.md for ~/bin/clojure-lsp-dev

borkdude11:08:39

but the jar file should work equally well if you want a released version

Nazral11:08:19

thank you that sounds exactly like what I wanted

Nazral11:08:30

I'll try and set it up

ericdallo13:08:48

standalone is the way to go, you will lose performance compared with the graal one but it should work

Nazral15:08:51

It seems to be working but I still run into one issue. To detail the setup, the source code resides in the VM too (because it uses docker for a bunch of stuff), I use sshfs to access it, + port forwarding to access the nrepl from the host, all this works fine. However, the lsp seems to be stuck on "analyzing external classpath"

ericdallo16:08:11

Yeah, pretty much it won't work, the support for remote code in clojure-lsp is not good

ericdallo16:08:38

We rely too much on expecting local files, probably kondo too

borkdude16:08:14

you can maybe connect to the remote nREPL while editing files locally

Nazral16:08:17

Accessing the VM's nREPL from the host works fine if that's what you mean, and I think the lsp is treating this as local files (it first failed because it didn't get some dependencies and the error disappeared after a lein deps)

borkdude16:08:51

What I mean is you could check out the repo locally, but connect to the remote nREPL and evaluate your local files against the remote nREPL.

Nazral16:08:56

running java -jar clojure-lsp-standalon.jar --project-root ./ diagnostics works fine and relatively fast

borkdude16:08:07

This way you could just edit files locally and run lsp locally

borkdude16:08:35

Another way could be to use a decent terminal editor like emacs or vim and run that remotely

Nazral16:08:48

I am using emacs

borkdude16:08:36

ok, then you could run emacs remotely + the jar solution and edit remotely in an ssh or tmux session perhaps

Nazral16:08:54

but it seems like it's the diagnostics which runs out of memory when running from lsp-mode but runs fine when running from a terminal

ericdallo17:08:53

BTW you can download the clojure-lsp artifact which is a wrapper for the standalone jar so you don't need to do that

Nazral18:08:58

Ok got it working!

Nazral18:08:48

Nothing super exciting, I had to set -XX:ReservedCodeCacheSize=2048m -Xmx6g