Fork me on GitHub
#lsp
<
2023-01-13
>
didibus03:01:26

lsp-workspace-command-execute: 'workspace/executeCommand' with 'add-missing-libspec' failed.

(error "The connected server(s) does not support method workspace/executeCommand.
To find out what capabilities support your server use 'M-x lsp-describe-session'
and expand the capabilities section")
What could I be doing wrong?

didibus04:01:11

Ok, I think my project root was wrong

didibus04:01:19

Other issue, lsp in emacs shows this header bar, but there is a character that shows as: E5CC instead of a character, this seems to not be a valid unicode character?

didibus04:01:39

Ok, I needed to install all-the-icons

didibus05:01:46

Seems add-missing-libspec doesn't ask you which one you want when there are possible conflicts?

didibus05:01:13

Or actually it's just buggy. Seems it adds a namespace that doesn't even have the method

ericdallo11:01:21

It's better to delegate to clojure-lsp code action (lsp-execute-code-actions) instead of manually calling the add missing libspec command, this way clojure-lsp ask to you which require to add with multiple choices

snoe16:01:50

We should address this bug tho, if ns a has a method and b doesn't add-missing should pick a if your cursor is on an exact match

šŸ‘ 2
didibus21:01:16

It seems it happens more when I have a small alias. I was trying: (c/quick-bench ...) Where criterium.core :as c is what I wanted. And it imported arrangement.core :as c But also that namespace doesn't have a quick-bench function. So I'm not sure what's up. If I just did: (quick-bench ...) Then it would work and require criterium.core :refer [quick-bench]

pmooser10:01:53

I'm having trouble getting clojure-lsp to work with my emacs config - is this the right place to ask questions?

pmooser16:01:54

I figured it out eventually ... I was failing to invoke lsp for each buffer.

borkdude15:01:05

Do some folks want to try out clojure-lsp nightly? It should support navigation now for quoted symbols like (requiring-resolve 'nextjournal.clerk/build!) and vars mentioned in deps.edn

ericdallo15:01:23

I tried in clojure-lsp project and it's working great, in bb.edn now works

Ellis15:01:41

Are there any limitations that might prevent textDocument/hover from working? I can't get it working on any work projects šŸ˜• Have tried eglot, lsp-mode & calva and all the same behaviour; returns a blank response for everything including core functions. It works no problem on my aoc repo, any other pointers trying to debug this would be appreciated šŸ™‚

ericdallo16:01:59

That sounds like classpath not found, so analysis of external deps are not included, for emacs, a message is printed asking if you wanna skip it or retry if an error is found, I'm about to try to fix that on calva

ericdallo16:01:42

One way to check that is checking logs

Ellis16:01:56

clj -Spath returns src:/home/elken/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar:/home/elken/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar:/home/elken/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar which is correct, I assume

ericdallo16:01:17

theoretically, it is clj -A:dev:test -Spath but it should bring similar classpath. Anyway, check server logs, it could be a wrong project root and other things

šŸ‘ 2
Ellis09:01:32

All clear, the only thing throwing me is the fact it's watching 200 folders in this particular example

Ellis09:01:54

It also looks (to me) like clj-kondo is understanding the project correctly

ericdallo12:01:01

The watcher comes from client, maybe there is some folder you want to ignore?

Ellis13:01:00

I don't think so, but I can try and start ignoring folders to see if it helps šŸ™‚

Ellis13:01:35

Nope šŸ˜ž I've ignored everything now except the smallest subset of the codebase & I still can't get textDocument/hover to resolve for anything (including core) LSP seems to initialize fine Logs: https://gist.github.com/elken/22b07c33117a659ae2918104408cca2c

Ellis13:01:31

Both should be in the gist

ericdallo13:01:08

Could you try remove .lsp/.cache and check server logs again?

Ellis13:01:55

No change šŸ˜ž Project only paths analyzed by clj-depend, took 0ms concerns me, is it possible for it to index in fractional milliseconds?

ericdallo13:01:57

that' s expected if you don' t have any clj-depend config, not relevant to your issue

Ellis13:01:04

I see, okay

ericdallo13:01:09

could you share the server logs after starting with the file removed?

Ellis13:01:47

The lsp cache? Sure

šŸ‘ 2
ericdallo13:01:05

That' s odd, it' s not printing any classpath found

Ellis13:01:27

Ohhhh I think I see the issue šŸ˜… they're monorepos

Ellis13:01:42

It's expecting there to be a parent deps.edn but there isn't one, lol....

Ellis14:01:32

I've tried adding them in .lsp/config.edn as :source-paths and there's some analysis at startup now, but still no textDocument/hover resolving šŸ˜• https://gist.github.com/elken/3890e632a29e550684b22020ee733da0

ericdallo14:01:46

I intend to create a post/tutorial on how to setup monorepos with clojure-lsp, but you can use clojure-lsp project itself as it' s a deps.edn monorepo

ericdallo14:01:09

basically, you need to add a dev alias linking to the sub repos so clojure-lsp can consider everything

Ellis14:01:00

So I need to create a top-level deps.edn? Or do you mean in the config.edn?

ericdallo14:01:21

top level deps.edn, like https://github.com/clojure-lsp/clojure-lsp/blob/master/deps.edn, it' s similar to how #polylith handle mono-repo projects where tools can understand that

Ellis14:01:34

Beautiful! šŸ˜ Thanks Eric šŸ™‚

šŸ‘ 2
Ellis15:01:06

That seems to be working for all the clj projects in it, but not the cljs one šŸ˜•

ericdallo15:01:14

if the cljs one has a different package manager, like shadow.cljs, it should have a root shadown unfortunately as well, not sure, that's a corner case I didnt face yet

Ellis15:01:11

Ah that makes sense actually, I'll figure it out and report back šŸ™‚

Ellis15:01:24

Seems this is all that's needed in a root-level shadow-cljs.edn

{:source-paths ["cljs-project"]}
Thanks again Eric šŸ™‚ Always a pleasure

ericdallo16:01:53

Good to know! I'll remember to add to the tutorial, thanks

Ellis16:01:29

Feel free to ping me when you have a draft if you want to add in any of my confusions šŸ˜›

šŸ‘ 2
didibus21:01:04

I feel the Emacs lsp package is not very good. I'm still trying to mess with it, but it seems to have a lot of conflicts with other things I use. Even the completion are strange, like it uses a different font for some reason? One thing I found really annoying is: (defn ) would be autocorrected to (defn) Now I'm not sure why. I don't think lsp does auto-format on every character? But I also have aggressive-indent mode which does, so maybe there's some weird conflict with lsp and aggressive-indent mode. Do others find lsp-mode in Emacs to be working reliably for them and without minor issues like this?

borkdude21:01:57

I have this:

lsp-enable-on-type-formatting nil
Not sure if it's related, but I don't think I'm using lsp formatting at all

didibus21:01:01

That was it! Ok, so it does have a reformat on every char type. My guess is it calls cljfmt which removes the space. It's so annoying haha. Thanks!

didibus21:01:41

I probably need to configure more things in it to get it to all work smoothly. I'll do some more digging.

borkdude21:01:57

more of my settings are here: https://github.com/borkdude/prelude/blob/master/personal/init.el#L391 I've disabled a few things that I found too much, like the breadcrumb

didibus06:01:03

Thanks, I'll probably use it as a starting place.

practicalli-johnny09:01:12

aggressive indent mode and LSP formatting will fight I've the code as it's typed. I removed aggressive indent a while ago and use LSP to format the code as it's typed. Sometimes I found aggressive mode too aggressive... Other that that Clojure LSP works very well for Emacs (specifically when I use https://practical.li/spacemacs/install-spacemacs/clojure-lsp/ or https://practical.li/doom-emacs/install/clojure-configuration/) I disable some of the Emacs LSP UI features (doc popup, sideline) as I prefer a simpler UI

borkdude09:01:13

@U0K064KQV Note that I disabled diagnostics in my config because I'm running clj-kondo separately (as I always use my own dev version)

didibus17:01:27

@U04V15CAJ Do you know what: ā€¢ lsp-enable-indentation ā€¢ lsp-signature-auto-activate ā€¢ lsp-enable-file-watchers do? File Watchers I think I understand that clojure-lsp does it's own file watching for deps.edn and such, and so lsp-mode doesn't need to do it?

didibus17:01:33

@U05254DQM Thanks. I love aggressive-indent mode, because I use adjust-parens mode, the combination is very nice, a kind of hybrid between paredit and pareinfer. But I might also try with just the lsp formatting. I'll look at your config as well for inspo.

didibus17:01:34

Also, anyone knows what this thing about LSP-PLIST is? In their https://emacs-lsp.github.io/lsp-mode/page/performance/ they say it's faster, but if it was faster I don't know why lsp would default to hash-tables? Clearly there's some trade off I'm missing?

borkdude18:01:11

@U0K064KQV There are docs for those - not sure exactly, I think when you change git branches, they take care that everything is re-analyzed, but it's not much of an issue to me