Fork me on GitHub
#lsp
<
2023-09-18
>
pesterhazy07:09:28

No definitions found for: LSP identifier at point
I'm seeing this error all the time in our monorepo (containing 100 projects). This is probably due to configuration errors on my part, but I've been reluctant to look into them for some reason. So this week I've decided to investigate every "jump-to-definition" error I encounter and document my findings in this thread, stream-of-conscious style

pesterhazy07:09:06

example1: symbol used in a clojure file, required from a support library in the monorepo

pesterhazy07:09:44

My first guess is that the classpath is wrong. Looking at the docs, this seems like a promising lead, given that the lib is included only when -A:dev is specified

pesterhazy07:09:09

So following the docs, I'm adding a config setting

{"project-specs" [{:project-path "deps.edn"
                   :classpath-cmd ["clojure" "-A:dev" "-Spath"]}]}
That doesn't seem to be working

pesterhazy07:09:30

Do I need to clear some caches? Restart emacs? eglot-reconnect?

mpenet07:09:23

how are the dependencies expressed (coord type)?

mpenet07:09:23

with eglot: if they point to jars you need to use jarchive to allow eglot to get to their source -> https://github.com/mpenet/emax/blob/master/init.el#L461-L466

mpenet07:09:38

ah, then no

pesterhazy07:09:05

I'm using jarchive already - but yeah that's a good pointer for future reference!

pesterhazy07:09:25

OK 💡 this seems to be working

{:source-aliases #{:dev}}

pesterhazy07:09:58

Ok trying it again I can confirm that

:project-specs [{:project-path "deps.edn" :classpath-cmd ["clj" "-Spath"]}]
doesn't work but
:source-aliases #{:dev}

pesterhazy07:09:12

Also it seems like restarting emacs is enough to make sure the new config file is taken into account (this is important when making systematic improvements). Is there a more lightweight way to be 100% sure I'm not seeing cached results?

pesterhazy07:09:52

example 1 is solved – I'll add to this thread when I run into new issues

mpenet08:09:21

I guess nuking .lsp in your project

pesterhazy08:09:42

also .clj-kondo?

mpenet08:09:47

yes, the .cache bit

pesterhazy08:09:23

this is a handy shortcut

% git clean -fxd .clj-kondo .lsp
Removing .clj-kondo/.cache/
Removing .clj-kondo/babashka/
Removing .clj-kondo/com.pitch/
Removing .clj-kondo/funcool/
Removing .lsp/.cache/

👍 3
ericdallo11:09:52

@U06F82LES by default clojure-lsp will use -A:dev:test unless you override project-specs or source-aliases, so that should work out of the box

ericdallo11:09:50

Oh, I think there is a bug not considering those default aliases :thinking_face: