How to Use Calva with Luminus#
Luminus is a powerful and versatile Leiningen template for creating web development projects. It comes with built in configuration which makes it easy to use Calva as your Clojure(Script) editor.
Server + shadow-cljs#
Basically this is the same wokflow as with Server only. Behind the scenes there is more happening, though. Such as the ClojureScript app being built and the CLJS REPL connected once the web app is running.
- If you haven't created the project yet, create a new shadow-cljs Luminus project. E.g.:
$ lein new luminus my-luminus-shadow +reagent +re-frame +shadow-cljs
- Install npm dependencies
(Or
$ npm i
yarn
if you prefer.) - This creates the folder
my-luminus-shadow
. Open it in VS Code:$ code my-luminus-shadow
- Use the Calva command Start a Project REPL and Connect (aka Jack-in):
ctrl+alt+c ctrl+alt+j
- Select to start my-luminus-shadow Server + Client, and wait for the Terminal Calva Jack-in output to say
[:app] Build completed.
- Open 127.0.0.1:3000 in your web browser and start hacking.
Note
Currently Calva has troubles following the app-start with shadow-cljs, so Calva will report Jack-in done.
in the output destination before shadow-cljs is actually done building the app. If you open the app page at that stage, you will see a message to “Please run lein shadow watch app
”. Rest assured that this is already underway. Follow the Jack-in process in the Terminal tab in VS Code for the message that the app is built, then reload the app page in the web browser.
Server Only#
The workflow here is really just: Jack-in and start hacking. However, the first time it will involve these steps:
- If you haven't created the project yet, create a new server only Luminus project. For a all-defaults setup it is like so:
$ lein new luminus my-luminus-server
- This creates the folder
my-luminus-server
. Open it in VS Code:$ code my-luminus-server
- Use the Calva command Start a Project REPL and Connect (aka Jack-in):
ctrl+alt+c ctrl+alt+j
- Select to start my-luminus-shadow Server and wait until you see
Jack-in done.
in the output destination.
- Select to start my-luminus-shadow Server and wait until you see
- Open 127.0.0.1:3000 in your web browser and start hacking.
Server + Figwheel#
This is Legacy Figwheel (lein-figwheel), so the recommendation is to use the shadow-cljs setup instead. As with the server only, the workflow here is really just: Jack-in and start hacking. The first time it involves these steps:
- If you haven't created the project yet, create a new server only Luminus project. E.g.:
$ lein new luminus my-fw +reagent
- This creates the folder
my-fw
. Open it in VS Code:$ code my-fw
- Use the Calva command Start a Project REPL and Connect (aka Jack-in):
ctrl+alt+c ctrl+alt+j
, select Server + Client - my-fw in the Project type picker menu, and wait for the web app to pop open in your web browser. - Start hacking.
If you prefer to open the web app yourself, open .vscode/settings.json
and change "shouldOpenUrl"
to false
in the pre-configured Calva connect sequence. Calva will then print the URL 127.0.0.1:3000 in the output, so that you can click it open.
Etcetera#
You will have three Calva Custom Command Snippets configured. Invoke them by issuing the Run Custom REPL Command, ctrl+alt+c .
(that's a dot). These commands control the Luminus server:
Start <project> Server
Stop <project> Server
Restart <project> Server
When used, Calva will open its REPL window and execute the command, if it is not already opened. You can close this window if you prefer to use the REPL directly from the Clojure files.
Calva also opens the REPL window, and starts the Luminus server, as part of the Jack-in process.