Fork me on GitHub

Hello, I'm trying to set up Calva to onboard new people on a Clojure fullstack project (with shadow-cljs) I use Emacs and set up a long time ago the following environment: • Configure Cider to use shadow-cljs as a library (without npm): (and also • Launch two REPLs in the same process with cider-jack-in-clj&cljs. I'm a bit lost in the Calva documentation. Can I achieve the same thing with ? Is it possible to have two REPLs in the same process with Calva ? Thanks a lot.


Is shadow-cljs configured to use deps.edn or lein for dependencies? If so jack-in using the shadow-cljs project type should work.


I think it is. Here is the beginning of my shadow-cljs.edn file:

{:deps true
  :builds {:app {:target :browser ...
When I choose the shadow-cljs project type, I get an error since there is no Node.js configuration in the project (no package.json and no node_modules folder). When I choose the deps.edn + shadow-cljs, the process goes well until I choose the :app build. I then get the following message :
; Creating cljs repl session...
; Connecting cljs repl: deps.edn + shadow-cljs...
;   The Calva Connection Log might have more connection progress information.
; Failed starting cljs repl for build: :app. Is the build running and connected?
   See the Output channel "Calva Connection Log" for any hints on what went wrong.


Apart from that, I didn't understand if it is possible with Calva to: 1. Have multiple windows for multiple REPL connections. 2. Create sibling connections with one REPL session to prevent having two JVM instances for clj and cljs REPLs. On cljc files, it is possible on Cider to choose with which REPL to evaluate an expression (cljs on the browser or clj on the JVM).


Maybe it is npx that needs package.json. Copy the jack-in command line and use it without npx from the terminal. Then use Calva Connect to connect to it. Calva will create one clj and one cljs repl session and let you choose which one should be used for cljc files.


I managed to connect and run shadow server with :

(defn cljs-repl
   (cljs-repl :app))
   (shadow/watch build-id)
   (shadow/nrepl-select build-id)))
But then, I don't understand how to reach the other REPL to start my backend HTTP server. With Cider, there are two different buffers.


That's basically what Calva does if you Connect using the shadow-cljs project type. Did you try that? It will give you two sessions, one for clj and one for cljs. They share the same REPL/output window, which is considered to be a cljc file. There is a command (and a status bar button) for toggling which REPL the cljc files are using. clj files will use the clj connection and cljs files will use the cljs one.


I try right now.


The way you did it now doesn't really work, because Calva will get confused when the clj session is used for cljs things. (And also you won't get the two connections you need.)


I can do a screen share if you like. Easier to show you how to do it then.


With pleasure


I went to ClojureD on 2018. That was very good. That's a shame I don't go this year. Thanks again.

🙏 1

It would have been awesome to meet there. Next time!


Hello @U0ETXRFEW, It spent quite some time extracting a small project from the big one. But there it is : I could reproduce the behaviour that we saw with Calva. Enjoy ClojureD.

🙏 1
metal 1

Sorry for belated answer. Looking at this now. One thing I notice is that if we start the repl using shadow-cljs shadow-cljs -d cider/cider-nrepl:0.27.4 watch :app, the shadow dependencies are never added, because the clojure aliases are not provided. If I change to :deps {:aliases [:dev :cljs]}, then jack-in using the shadow-cljs project type works. No idea why I didn't spot this when we screen shared.


Humm, but doing so, the command shadow-cljs -d ... uses the Node.js executable no ?


To use Clojure CLI with shadow-cljs as a library, the command should start with clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.9.0"},cider/cider-nrepl {:mvn/version,"0.27.4"}}}' -M:dev:cljs ... no ?


Yes, it uses the node executable, which shouldn't matter much if it is done via jack-in, but I was mainly noticing this because it puzzled me why the shadow-cljs project type jack-in wouldn't work.


I've gotten it to work via clojure deps too. Regular connect, without jack-in. I'll wrap some conclusions up once I've understood things better.


I've filed a PR on your example project, @U94V75LDV. Let me know if it makes sense or not.


Hello @U0ETXRFEW PR merged. Thanks a lot. I tried to use the Joyride commands (after installing Joyride). At VSCode startup I get the following message :

Requiring Calva failed: #error {:message "Could not find namespace: z-joylib.editor-utils.", :data {:type :sci/error, :line 2, :column 3, :message "Could not find namespace: z-joylib.editor-utils.", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 2, :column 3, :file "helpers.cljs", :ns #object[w2 helpers]})}], :file "helpers.cljs"}, :cause #object[Error Error: Could not find namespace: z-joylib.editor-utils.]}


Then I run the Joyride command : > Run Joyride: Run Workspace Script.. and select start_project.cljs, to start the project REPL. Which works


I then connect the project to the REPL and when I try to run the (helpers/refresh-and-restart) from Joyride, I get the following message : Could not resolve symbol: helpers/refresh-and-restart from VSCode.


May be I missed something on Joyride configuration and installation.


But in general, I can now use the reloaded workflow from VSCode. Thanks a lot !


I left some require in that's not needed. Remove it, and it should start to work, I think. I didn’t catch it because of some user script I have.


I filed a new PR, fixing the Joyride issue.


Sorry, I was a bit disconnected for a long week. Thanks a lot. PR merged.


i have a file that i want to eval forms and it not switch to user. it has no ns at the top, it's just a scratch file

👀 1

Almost missed to answer this despite @brandon.ringe’s notification help... This with scratch files is something I have long been wanting to support. It shouldn't be very hard, I think. So not switching to user ns means that you would like to have a way to stay in whatever the current ns is, I guess, @lilactown?

💯 1

I use this in joyride that I think does what you're describing, except output goes to the output console instead of the normal repl output...

(defn evaluate-current-form+ []
  (p/let [result (c/repl.evaluateCode (c/repl.currentSessionKey)
                                      (second (c/ranges.currentForm))
                                      #js {:stdout #(.append (j/output-channel) %)
                                           :stderr #(.append (j/output-channel) (str "Error: " %))})]
    (.-result result)))
if evaluateCodeUpdatingUI was exposed in the api I think that would emulate the normal Calva experience?


Have you tried using evaluateCodeUpdatingUI via executeCommand, @U015879P2F8?


No, I just came across it for the first time a few minutes ago 🙂 when I was trying to see how normal evaluations in calva differed from the evaluateCode method exposed in the api.


I'll give it a try in a little bit


is there a way to do that?

Alex Miller (Clojure team)17:06:52

oh you probably mean via UI :)


yea sorry, i mean specifically using calva's evaluate current form command

👀 1

Hey , look at which extension was chosen to highlight the new Sponsoring feature of VS code:

👏 18
calva 22
clojure-spin 12
❤️ 12
🎉 3

Wow, that’s awesome!


Really nice!

🙏 1

I just updated VS Code and came here to mention that (haven't looked at Slack today until now!). 'grats @U0ETXRFEW and team!

🙏 1
thanks3 1

This is simply awesome!


Almost missed to answer this despite @brandon.ringe’s notification help... This with scratch files is something I have long been wanting to support. It shouldn't be very hard, I think. So not switching to user ns means that you would like to have a way to stay in whatever the current ns is, I guess, @lilactown?

💯 1