lsp

Nazral 2024-08-10T11:26:07.705519Z

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

borkdude 2024-08-10T11:33:18.428709Z

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

Nazral 2024-08-10T11:33:40.211019Z

I'm running openbsd

borkdude 2024-08-10T11:33:52.812049Z

see jar file here: https://github.com/clojure-lsp/clojure-lsp/releases/tag/2024.08.05-18.16.00

Nazral 2024-08-10T11:33:58.044249Z

thank you!

borkdude 2024-08-10T11:34:08.536479Z

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

borkdude 2024-08-10T11:34:14.433379Z

but @ericdallo knows

borkdude 2024-08-10T11:37:14.331939Z

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

borkdude 2024-08-10T11:37:39.336289Z

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

Nazral 2024-08-10T11:38:19.816879Z

thank you that sounds exactly like what I wanted

Nazral 2024-08-10T11:38:30.717699Z

I'll try and set it up

ericdallo 2024-08-10T13:16:48.705659Z

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

Nazral 2024-08-10T15:15:51.523309Z

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"

ericdallo 2024-08-10T16:32:11.086659Z

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

ericdallo 2024-08-10T16:32:38.168639Z

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

borkdude 2024-08-10T16:33:14.400179Z

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

Nazral 2024-08-10T16:41:17.567659Z

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)

borkdude 2024-08-10T16:43:51.305599Z

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.

Nazral 2024-08-10T16:43:56.524639Z

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

borkdude 2024-08-10T16:44:07.801889Z

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

borkdude 2024-08-10T16:44:35.629279Z

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

Nazral 2024-08-10T16:44:48.702729Z

I am using emacs

borkdude 2024-08-10T16:47:36.542699Z

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

Nazral 2024-08-10T16:47:54.419749Z

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

ericdallo 2024-08-10T17:36:53.327219Z

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

Nazral 2024-08-10T18:52:58.537859Z

Ok got it working!

Nazral 2024-08-10T18:53:48.126329Z

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