Fork me on GitHub
#calva
<
2022-10-02
>
eighttrigrams11:10:00

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

pez11:10:12

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?

eighttrigrams11:10:42

Hey pez, yes. It is.

pez11:10:33

Are there nrepl dependencies declared in project.clj, maybe? Leiningen is a bit strange in that command line injections do not always take precedence.

eighttrigrams11:10:06

there is no mention of nrepl in the project.clj

pez12:10:06

Does the repl work for evaluating things?

pez12:10:48

There is a command for logging the nrepl messages. Maybe that can tell us something about what is going wrong.

eighttrigrams12:10:12

yes, the repl works for evaluating things

eighttrigrams12:10:55

You mean opening the clojure-lsp log file?

pez12:10:31

The nrepl log. Search the command palette for nrepl and you should find the command.

eighttrigrams12:10:33

-> 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' ]
}

eighttrigrams12:10:01

it seems i only get this when i am connected to the repl

pez12:10:10

Definitely looks like a dependency problem. What does the Jack-in terminal say when things starts?

eighttrigrams12:10:49

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?

pez12:10:35

It’s in the terminals pane. But only if you are indeed using Jack-in. How are you starting the repl?

eighttrigrams12:10:13

I click on the REPL symbol in the status bar

eighttrigrams12:10:41

next I select "Generic", then give the port

eighttrigrams12:10:27

ah, i understand. this is not jack-in

pez12:10:39

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.

eighttrigrams12:10:36

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!

eighttrigrams13:10:40

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?

pez13:10:10

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.

eighttrigrams13:10:27

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!

metal 1
eighttrigrams13:10:36

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?

pez14:10:01

Yes, by default Calva uses nrepl for definitions. clojure-lsp is still used for a lot of other things, though.

eighttrigrams14:10:57

where can i find information on how to configure using clojure-lsp for definitions?

pez14:10:21

Search settings. http://calva.io might say something about it too.

eighttrigrams14:10:11

ok, will do. thanks pez!

eighttrigrams14:10:58

Ok, I found the option:

👍 1
eighttrigrams14:10:13

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.

metal 1
seancorfield19:10:38

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

seancorfield19:10:25

(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)

pez19:10:48

I think we should be able to make goto definition work with plain nrepl. Not completely sure why it doesn't work, tbh.

1
seancorfield19:10:28

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.

👍 1