This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-02
Channels
Hello. I've got a problem with Calva (or clojure-lsp?). If I am not jacked-in, "jump to definition" works, but as soon as I successfully connect to a running REPL (Generic), "jump to definition" stops working. I am clueless as for how I even begin to debug this, so any pointers appreciated
Sounds like unmet nrepl dependency requirements. By default Calva prioritizes nrepl's definitions over clojure-lsp's. You can change this in settings, but I recommend to try find the root cause here. Is this a Leiningen project?
Hey pez, yes. It is.
Are there nrepl dependencies declared in project.clj, maybe? Leiningen is a bit strange in that command line injections do not always take precedence.
there is no mention of nrepl in the project.clj
There is a command for logging the nrepl messages. Maybe that can tell us something about what is going wrong.
yes, the repl works for evaluating things
You mean opening the clojure-lsp log file?
-> sent
{
op: 'info',
ns: 'some.namespace.consent',
symbol: 'check-validity-calc',
id: '12',
session: '03cf2877-d6bb-4ee4-8434-25bdf6b50591'
}
<- received
{
id: '12',
op: 'info',
session: '03cf2877-d6bb-4ee4-8434-25bdf6b50591',
status: [ 'done', 'unknown-op', 'error' ]
}
it seems i only get this when i am connected to the repl
Definitely looks like a dependency problem. What does the Jack-in terminal say when things starts?
i am not sure where to find it. i have an output window, which shows
; nREPL Connection was closed
; Connecting ...
; Hooking up nREPL sessions...
; Connected session: clj
+ some tips. I also have a "Calva says" terminal and a "Calva Connection log". Any of those?It’s in the terminals pane. But only if you are indeed using Jack-in. How are you starting the repl?
I click on the REPL symbol in the status bar
next I select "Generic", then give the port
ah, i understand. this is not jack-in
Yeah. So that is why you don't have the dependencies satisfied. If you have reasons to start the repl manually you can use the command copy jack-in command something, something, to get a command line that injects the nrepl dependencies. Otherwise, I recommend using Jack-in.
I need to do it via nrepl. Ok this command gives me dependencies, I will put these in the project.clj and see how that goes. Thanks!
ok, adding
update-in :dependencies conj '[nrepl "1.0.0"]' -- update-in :plugins conj '[cider/cider-nrepl"0.28.5"]' -- update-in '[:repl-options :nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' --
into my lein command worked.
now if ran into another problem. with "Jump to definition" it jumps for example to a path /app/src/some-namespace/abc.clj
and VSCode does not find the file. This is clearly docker related, because the app runs inside a container under /app
. My VSCode normally opens such file as src/some-namespace/abc.clj
. is there a way to configure this?See if configuring Calva to use clojure-lsp for definitions works better. I'm afk so can't look up the setting, but you should be able to search for it.
Update on my original question, if I update the path to the app in the docker container to look like in my host machine, it works. That is awesome!

So in this setup Calva does not use clojure-lsp
? Is this the reason "Jump to definition" does work when it is not connected via nrepl but stops working when connected?
Yes, by default Calva uses nrepl for definitions. clojure-lsp is still used for a lot of other things, though.
where can i find information on how to configure using clojure-lsp for definitions?
Search settings. http://calva.io might say something about it too.
ok, will do. thanks pez!
Setting the order lsp,repl
resolved my problem entirely (no need for my docker app path workaround). I can now jump to definitions! Again, thanks so much.

FWIW, I just ran into this exact same issue and it was because I'd decided to try going back to plain nREPL without the CIDER middleware (b/c I wanted to figure out what Calva functionality depended on it!): https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L102
(so I'm back using the CIDER m/w now and go to def works again after connecting to my running REPL -- I never "jack-in" b/c my REPL is much longer-lived, generally, than my editor session)
I think we should be able to make goto definition work with plain nrepl. Not completely sure why it doesn't work, tbh.
I find having the CIDER m/w active produces nastier stack traces in several situations so I'd rather avoid that (clojure.test output when there's an exception is the main culprit I think). It would be great if Calva could specifically document what functionality requires CIDER and what doesn't so folks could understand the trade offs.