Calva: [2.0] Do we need nrepl.cmdline for anything when jack-in to CLI/deps projects?

Created on 9 Apr 2019  路  5Comments  路  Source: BetterThanTomorrow/calva

Right now we load nrepl.cmdline in the jack-in command line for CLI/deps projetcs. This seems to be unecessary since we have our own readline-ish behaviour in the REPL Window. Also lots of projects seem to use rebel readline and I wonder if this can somehow clash?

jack-in question repl-window

Most helpful comment

That worked, I can see the docstrings on hover now.

I added the "magic" incantation to my deps.edn...

{:paths ["src"]
 :aliases
 {:nrepl {:extra-deps {cider/cider-nrepl {:mvn/version "0.21.1"}}
          :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}

So now I can start the REPL server with just...

clj -A:nrepl

Besides, I deleted Leiningen, and Calva still works with my hello-calva deps project.

Thanks a lot for your help and for Calva!

All 5 comments

I guess the issue corresponds to the not yet released version 2.0 of Calva, but FWIW, here's my experience with a CLI/deps project and Calva 1.3.66.

I have a hello-calva folder with a deps.edn file like...

{:paths ["src"]
 :aliases {:nrepl {:extra-deps {cider/cider-nrepl {:mvn/version "0.21.1"}}
                   :main-opts ["-m" "nrepl.cmdline"]}}}

and a src/hello.clj file like...

(ns hello)

(println "hello Calva!")

I open hello-calva folder in VSCode and, in Settings, set "Calva: ConnectREPLCommand" to

clj -Sdeps '{:deps {reply {:mvn/version "0.4.3"}}}' -m reply.main --color --attach

From the VSCode integrated Terminal I execute

clj -A:nrepl

I click on the nREPL in the lower left of the editor window and the dialog is automatically filled in with 'localhost:' followed by the port opened by nREPL. I press enter.

I open hello.clj and use Shift+Cmd+P to invoke the command palette and select "Calva: Evaluate current file".

In VSCode Terminal's OUTPUT tab, with "Calva says" selected in the dropdown, I see "hello Calva!".

If I click the TERMINAL tab, and select "Clojure REPL" in the dropdown, there's a

user=> WARNING: cat already refers to: #'clojure.core/cat in namespace: net.cgrand.parsley.fold, being replaced by: #'net.cgrand.parsley.fold/cat

followed by a cursor, but no prompt. However, if I press enter, I get the prompt...

user=>

If I place the cursor after the last parenthesis in hello.clj's println and invoke the command palete (Shift+Cmd+P) and select "Calva: Evaluate selection or current form", in the Terminal's OUTPUT tab, with "Calva says" selected in the dropdown, I see this being printed

out: hello Calva!
=> nil

That's fine, but...

"View docstrings on hover"

doesn't work. Is there a known way to make it work?

Hello. Yes, it refers to the beta/dev version of Calva 2.

Interesting that you got a prompt in the Terminal REPL. I thought that would work only with leiningen, but maybe you have that installed, and that is why it works...

So, you have evaluations working, but not doc strings and such. It usually is a dependency problem. Try adding a dependency on nrepl 0.5.3 and change your dependency on cider/cider-nrepl to 0.20.0.

Also feel welcome to joing the # calva-dev channel on the clojurians slack. I am about to go offline for a while now, but hopefully there are others there that can help you.

You're right, I have leiningen installed

$ lein -v
Leiningen 2.8.1 on Java 1.8.0_74 Java HotSpot(TM) 64-Bit Server VM

Where does the dependency on nrepl have to be added? in :extra-deps or :deps or...? I tried this...

{:paths ["src"]
 :aliases {:nrepl {:extra-deps {nrepl {:mvn/version "0.5.3"}
                                cider/cider-nrepl {:mvn/version "0.20.0"}}
                   :main-opts ["-m" "nrepl.cmdline"]}}}

But docstrings on hover still don't work.

Is there another appropriate channel to discuss this besides Slack? Maybe clojureverse.org or stackoverflow.com? I think knowledge shared through those channels (especially SO) is more easily retrievable later when someone else needs it.

You are welcome to bring the questions anywhere you want. :smile: It is just that a chat room like that can be the quickest way.

I am embarrassingly unfamiliar with deps.edn, but tried it out now and starting the repl like this works in the test project I used:

clojure -Sdeps "{:deps {cider/cider-nrepl {:mvn/version \"0.20.0\"}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"

Without any cider or nrepl deps in deps.edn.

That worked, I can see the docstrings on hover now.

I added the "magic" incantation to my deps.edn...

{:paths ["src"]
 :aliases
 {:nrepl {:extra-deps {cider/cider-nrepl {:mvn/version "0.21.1"}}
          :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}

So now I can start the REPL server with just...

clj -A:nrepl

Besides, I deleted Leiningen, and Calva still works with my hello-calva deps project.

Thanks a lot for your help and for Calva!

Was this page helpful?
0 / 5 - 0 ratings