Skip to content

Tooling Integration Emacs, Cursive, VSCode etc.

David Nolen edited this page May 26, 2020 · 3 revisions

Cursive

Create a REPL. Use the clojure.main option. Supply the Krell parameters in the Parameters: field.

nREPL (Emacs, etc.)

Krell provides a standard ClojureScript REPL that should be compatible with existing nREPL tooling.

(require '[clojure.edn :as edn] 
         '[clojure.java.io :as io]
         '[cider.piggieback] 
         '[krell.api :as krell]
         '[krell.repl])

(def config (edn/read-string (slurp (io/file "build.edn"))))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))

Calva (VS Code)

With Calva you can add this REPL Connect Sequence to the workspace settings.json:

    "calva.replConnectSequences": [
        {
            "name": "Krell",
            "projectType": "Clojure CLI",
            "cljsType": {
                "connectCode": "(require '[clojure.edn :as edn] '[clojure.java.io :as io] '[cider.piggieback] '[krell.api :as krell] '[krell.repl]) (def config(edn/read-string(slurp(io/file \"build.edn\")))) (krell/build config) (apply cider.piggieback/cljs-repl (krell.repl/repl-env)(mapcat identity config))",
                "dependsOn": "User provided"
            }
        }
    ]

The Jack in command will then start the project and connect to the Krell REPL once the app is running on a device (wether real or virtual/emulated).

For a smooth workflow you can also:

  • Install the React Native Tools extension
  • Install the Debugger for Chrome extension, and add this Launch Configuration
            {
                "type": "chrome",
                "request": "launch",
                "name": "Launch Debugger",
                "url": "http://localhost:8081/debugger-ui/",
                "webRoot": "${workspaceFolder}"
            }

Together with the connect sequence this will make for a start of a Krell session like this:

  1. Open the project root in VS Code
  2. Issue the Jack-in command
  3. Issue the React Native; Run Android on Emulator (or Run iOS on Simulator) command. (Disable Fast Refresh from the *React Native dev menu, if it is enabled.)
  4. Issue the React Native: Run Element Inspector command (You might need to install the React Native inspector globally):
    yarn global add react-devtools
  5. Launch Debugger (F5)
  6. Hack away, with hot reload and interactive REPL

Once the debugger (a Chrome session) is running, you probably will want to enable Custom Formatters in order for clojure structures to be logged conveniently.

Clone this wiki locally