Fork me on GitHub
#lsp
<
2022-10-21
>
hiredman20:10:21

I am starting to get my feat wet with clojure-lsp, and I am trying to troubleshoot my setup, start with running "clojure-lsp" and typing in "{}" try and get the error like is show here https://clojure-lsp.io/troubleshooting/#server-is-not-initializing , but I am not getting anything, is that troubleshooting step still correct?

ericdallo20:10:26

Unfortunately it's outdated, we recently migrated outside lsp4j and that exception is no more

ericdallo20:10:49

But you can just skip it, TBH I think I'll remove that from the troubleshooting

ericdallo20:10:06

What exactly is not working?

hiredman20:10:15

well, it is really the only thing in trouble shooting

hiredman20:10:32

hard to say, I don't have much experience with the lsp stuff

hiredman20:10:54

I am trying to use eglot (emacs lsp client)

hiredman20:10:10

and it seems to launch clojure-lsp, and then things timeout

hiredman20:10:29

(lots of requests getting sent to clojure-lsp from what I can see, but no responses)

ericdallo20:10:35

It's not the only thing on troubleshooting, there are more sections. Right, I'm a lsp-mode user but I know @U976F1AR2 uses it with eglot

ericdallo20:10:55

There is not that much people using it with eglot AFAIK but it should work

ericdallo20:10:25

Are your clojure-lsp updated?

hiredman20:10:44

I just run the install script

hiredman20:10:59

clojure-lsp 2022.10.05-16.39.51
clj-kondo 2022.10.05

ericdallo20:10:05

Looks correct

ericdallo20:10:24

Is eglot pointing to the correct path of clojure-lsp?

hiredman20:10:29

I am running on it on a pretty big project

ericdallo20:10:55

A start would be to test in a sample project

hiredman20:10:03

yeah, clojure-lsp is launching, and that is the only clojure-lsp I have installed

ericdallo20:10:24

Alright, you can enable server trace logs, but before you can check server logs

ericdallo20:10:32

It's on the troubleshooting how to check server logs

hiredman20:10:27

yeah, I do have logs, and there is output in there, nothing that looks abnormal, I bumped up the eglot timeouts already, but maybe I need to bump them up even more for the first run on a large project

ericdallo20:10:22

Oh, yeah, for bug projects the really first time should take more time, 1-2mins if a huge project

borkdude20:10:50

@U0NCTKEV8 My 2 cts: if you want to get started, it might be better to use lsp-mode which all of the clojure-lsp maintainers are also using and after a while migrate to eglot if you're more comfortable with the existing setup

👍 1
ericdallo20:10:51

With lsp-mode there is a progress bar during initialize, I think eglot doesn't have that

hiredman20:10:57

I had it at 5 minutes and just bumped to 10 🙃

ericdallo20:10:22

Hum, I doubt clojure-lsp takes that much, you can confirm on logs too

ericdallo20:10:10

Clojure-lsp server logs say exactly how much time it took to start

hiredman20:10:22

it looks like clojure-lsp is crashing, because it is sending progress analyzing project updates, and I can see stuff in the logs, then sometime after 100% of that, everything goes quiet and there is no clojure-lsp process running anymore (checked via ps)

hiredman20:10:35

ah, ok, maybe missed the clojure-lsp process still running, but I've got it running with --trace now

hiredman20:10:45

lots of chatter in the log

hiredman20:10:47

huh, so it is running and seems to be fine, but doing a rename, the server log says it is sending back the edits, but elgot is saying it got a timeout

ericdallo20:10:50

Trace may help know if clojure-lsp is receiving and send logs

ericdallo20:10:10

Hum, sounds like client issue indeed

hiredman20:10:23

it doesn't help that I keep wanting to call it elgot

ericdallo20:10:29

I'd suggest trying another client like vscode or lsp-mode

hiredman20:10:56

eglot is got mainlined into emacs

hiredman20:10:16

not in a release yet I don't believe

ericdallo20:10:17

I know, still missing lots of stuff lsp-mode has

borkdude20:10:08

@U0NCTKEV8 a tip when installing lsp-mode: when you find it too noisy, you can disable stuff. This is my current config https://github.com/borkdude/prelude/blob/2a951dfa28d8b7c535430cc86ead7ccff18c43a3/personal/init.el#L374-L391 e.g.

lsp-headerline-breadcrumb-enable nil

borkdude20:10:40

(I also disabled linting but this is because I run clj-kondo separately, the latest dev version)

borkdude20:10:47

On the other hand, I found lsp-lens-enable t worth enabling (which shows the number of references and tests next to each var). I'm not sure if that is enabled or disabled by default

hiredman20:10:52

the thing is, if I wanted lsp-mode I would have installed lsp-mode 🙂

👍 1
ericdallo20:10:08

Something of this may be useful for you/apply even for eglot: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/

hiredman20:10:57

it seems like some how rpc reply messages are being dropped

ericdallo20:10:07

Maybe add a log on eglot side when receive a msg or something

hiredman21:10:10

looks like jsonrpc is complaining about some message it gets from clojure-lsp at start up, and then maybe refusing to parse more messages after that

borkdude21:10:42

could it be that clojure-lsp is printing something to stdout while it should print something to stderr?

borkdude21:10:30

@U06F82LES has also been using eglot I think

hiredman21:10:12

hard to tell, I need to figure out how to get in the middle between emacs and eglot and see what is actually going on

hiredman21:10:31

I disabled kondo linting in clojure-lsp, and that appears to have gotten rid of the jsonrpc startup error, but operations still all timeout

ericdallo21:10:19

What setq exactly?

hiredman21:10:01

the one that starts with setting gc-cons-threshold

hiredman21:10:30

this is intense, a lot of information suddenly getting throw at me

ericdallo21:10:36

Oh right, IMO that should be the default value, I have no idea why emacs doesn't change that..

ericdallo21:10:02

With eglot there I hope they start to realize those changes :)

jacob.maine21:10:11

Not that it’s available with eglot, but those setq settings are checked by lsp-doctor, correct?

👍 1
borkdude21:10:12

> this is intense, a lot of information suddenly getting throw at me now I really want to see a screenshot :)

jacob.maine21:10:29

@UKFSJSM38 now that eglot is https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg01609.html, we probably need to spend more time ensuring it’s operating smoothly. I’ve had good luck with lsp-mode, but there are likely to be more eglot users soon

👍 3
hiredman21:10:17

@U04V15CAJ I've using just emacs without even cider and any of that stuff, just getting docstrings in the minibuffer confuses and amazes

😆 1
hiredman21:10:35

but I still cannot turn kondo on in the clojure-lsp config without it breaking things

ericdallo21:10:31

@U07M2C8TT agreed, there are know eglot issues I know like not going to definition of external files

borkdude21:10:14

@U0NCTKEV8 my experience was that having both flycheck + flycheck-clj-kondo and also lsp-mode trying to do thing with flycheck didn't work for me. So I disabled lsp-mode's flycheck completely for this reason

borkdude21:10:20

Not sure how to do that with eglot

hiredman21:10:44

M-. doesn't work for stuff in jars (I know, I know, I haven't had a working M-. setup in years anyway)

jacob.maine21:10:29

Opting to use clj-kondo’s flycheck over lsp-mode’s flycheck is worth trying but be aware that you lose a diagnostic that way… specifically unused-public-var, which flags vars that are defined but never used. @U04V15CAJ I think you also prefer using them separately so you can more easily see the very latest lint from your local build of clj-kondo, rather than waiting for clojure-lsp to bump its clj-kondo version, correct?

borkdude21:10:37

When I navigate to first , emacs points me to clojure source in .emacs.d/workspace/.cache - not sure why it doesn't open the .jar file (like CIDER does) but it does navigate to something for me

borkdude21:10:02

I'm not using :unused-public-var as lens-mode already gives me that information. And yes, I'm running the always latest dev version of clj-kondo so I can actually see what I'm doing

jacob.maine21:10:56

Yep, lens-mode is a decent substitute, but I like having the unused vars in the flycheck errors list

hiredman21:10:55

M-. on first drops me in a new file called "core.clj" in /var/foo/home/kevin/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar::clojure/

hiredman21:10:33

elgot must just not handle paths into jars I guess, the '::' thing

jacob.maine21:10:09

I think @UKFSJSM38 was planning to change lsp-mode so that it doesn’t use the .emacs.d/workspace/.cache directory @U04V15CAJ

🎉 1
jacob.maine21:10:35

@U0NCTKEV8 would you try adding :dependency-scheme "jar" to your clojure-lsp config.edn?

jacob.maine21:10:38

After changing it, it’s probably best to blow away your .lsp/.cache and restart clcojure-lsp

hiredman21:10:10

I will try that

jacob.maine21:10:28

clojure-lsp supports two “dependency-scheme”s which are essentially formats for the URLs it returns. The URL you pasted, with the :: looks like it’s the “zipfile” scheme, which eglot almost surely won’t understand. The “jar” dependency scheme should use !/ instead of :: (among other differences) which perhaps eglot will understand. Unfortunately the “zipfile” scheme is our default, though we’re talking about changing that. If this works, it’s a change that should really be incorporated upstream into eglot

hiredman22:10:04

also wonky, in a slightly weirder way

hiredman22:10:12

and for some reason the new empty file it jumped me into has had an ns decl inserted at the top

(ns ws.billing.member.file:.var.foo.home.kevin..m2.repository.org.clojure.clojure.1.11.1.clojure-1.11.1.jar!.clojure.core)

jacob.maine22:10:04

That’s one of the clojure modes, possible clojure-lsp, “helping” you fill out the ns name based on the new file’s name

hiredman22:10:19

ah, I see, when the new file opened eglot asked if the server was allowed to edit the file, and the server helpfully inserted a namespace decl to match the crazy location the file ended up in

jacob.maine22:10:16

The last comment on that Issue was 44 seconds ago, so I don’t think you’re alone

jacob.maine22:10:25

Also a reminder… when you’re done debugging, don’t forget to turn off tracing—it’s a common performance problem

hiredman22:10:55

already did

👍 1
ericdallo22:10:11

@U976F1AR2 opened that issue, he's a clojure-lsp and eglot user (and a coworker :p), I bet he can help too with his eglot knowledge

ericdallo22:10:35

It'd be really nice to make all eglot users use jar dependency or we change the default @U07M2C8TT

jacob.maine22:10:46

@UKFSJSM38 what I don’t understand is why we need to jump through all these hoops. Emacs already understands jars and their files. Try opening a jar file from your .m2 directory. Is it just that Emacs needs a special URI format that we’re not serving?

jacob.maine22:10:05

s/Emacs/vanilla Emacs/

jacob.maine23:10:59

To follow up on this … it appears that arc-mode.el provides https://github.com/emacs-mirror/emacs/blob/55eabe96c92aaee336a7ed4cce4d5b4186c9eeeb/lisp/arc-mode.el#L651, which is a dired style view of an archive. Because jar files follow the zip file format, archive-find-type https://github.com/emacs-mirror/emacs/blob/55eabe96c92aaee336a7ed4cce4d5b4186c9eeeb/lisp/arc-mode.el#L736 the jar as a zip. This gets translated in the mode line into “Zip-Archive”. From the dired view, you can navigate to a file. That’s as far as I’ve gotten. I’m not sure yet how it unzips the file, or whether that’s something tools like eglot and lsp-mode could hook into

ericdallo23:10:24

It unzips the jar under the hood and get the content to a temp buffer, that's how cider does as well

ericdallo23:10:03

I think emacs only works with jar deps scheme, I can't recall if zipfile works

jacob.maine23:10:06

> emacs only works with jar deps scheme It sounds like Emacs itself, with its default packages, doesn’t work with either scheme. That is, if you just tell it to open a file inside a jar using either scheme, it thinks you’re talking about a new file. > It unzips the jar under the hood That’s what I’m reading too. It’s not clear to me whether external tools could use the functions it defines to open files in jars, or if you have to first open the jar in dired

ericdallo23:10:36

AFAIK the mode helps providing functions, check cider-find-var it uses a similar o rthe same function that does that

jacob.maine00:10:07

Yep, you’re right, cider uses a helper from arc-mode.el. I’m going to report that on the eglot ticket. Maybe it’ll help them too.

👍 2
lispers-anonymous00:10:42

I am reporting back from https://github.com/joaotavora/eglot/issues/661 Eglot does not set the "jar" dependency-scheme setting, but even if it is set it has even more trouble understanding "jar" format than the "zipfile" format . This is because the jar: uri contains a nested uri, so it needs to be parsed twice. So setting the dependency-scheme from eglot won't really help this problem as is. I will at least try to get a change pushed to eglot so that it can dispatch the jar scheme properly. Even with that in place, more code will have to be loaded up into emacs to make it understand how to open URLs inside jar archives. More on that to come!

👍 2
lispers-anonymous14:11:40

Posting an update on this: https://github.com/joaotavora/eglot/issues/661#issuecomment-1313839319 eglot can now open jar (and zipfile) scheme URIs with this new package I wrote, "jarchive", which is available on ELPA. Hope this helps!

👍 1