Understanding jack-in in Calva

Hi there!

Jack-in is a bit of an unfortunate name… :grinning: . Basically there are two options:

  1. You start the REPL, and you connect to that REPL. What @didibus said applies: Here you are responsible for meeting Calva’s dependencies requirements.
  2. Calva starts the REPL and connects it. Calva will injects the dependencies it needs. (This is Jack-in)

Jack-in does not cover as many project setups as Connect does. The recommendation is intended to be more like: If your setup allows jack-in, then consider using it. If not, then regular connect is what you need to use.

There is a Calva command for copying the command line Jack-in would use to the clipboard. It can be used to modify the command line you use to start the REPL yourself. Or to inform you about what dependencies Calva has so that you can configure your project.

I’m not sure I understand the setup with your PHP app… That step 1 in your workflow, it is starting a dev version of your server, right? I don’t see when you are connecting to it. If you are not connecting to it, then you should be able to use a similar workflow with Calva. You probably need to us VS Code Workspaces to be able to open the same project in different windows. See Workspace Layouts - Calva User Guide for some info on this.

Using Jack-in:

  1. lein run (I would use the VS Code integrated terminal, it is pretty awesome)
  2. In one VS Code workspace. Jack-in, selecting the shadow-cljs project type, selecting to start and connect the the :app build.
  3. In another VS Code workspace. Connect to nREPL post 3000

I’ve tried to describe the Jack-in mechanism here: The Jack-in Academy - Calva User Guide

Using connect:

  1. lein run
  2. shadow-cljs -d cider/cider-nrepl:0.27.4 watch app (Again. I’d choose the VS Code terminal)
  3. In one VS Code workspace. Connect, selecting the shadow-cljs project type, selecting connect the the :app build.
  4. In another VS Code workspace. Connect to nREPL post 3000

(The reason you need two VS Code windows is that Calva only can handle one project session per window. Since in your case the Clojure REPL and the ClojureScript REPL are not in the same process, it gets to be two separate sessions from Calva’s perspective.)

You can configure things so that shadow-cljs uses Leingen to start the the REPL and skip the lein run step there. See the Leiningen build tools section here: Shadow CLJS User’s Guide

Here’s the current command line that Calva uses for a Leingingen project with a :dev profile, btw:

lein update-in :dependencies conj '[nrepl,"0.9.0"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.27.4"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- with-profile +dev repl :headless

I hope this helps some. Please don’t hesitate to keep asking until you have your workflow working well in Calva.

2 Likes