Skip to content

piotr-yuxuan/sample-dirac-re-frame

Repository files navigation

Dirac setup with IntelliJ and Emacs

A re-frame application designed to… well, that part is up to you.

Technically, this project is a re-frame rich single-paged application built upon React (wrapped into Reagent). I use Figwheel, Dirac for development so I can enjoy live-coding. A demo can be accessed here: https://piotr-yuxuan.github.io/sample-dirac-re-frame/

This project is a sample configuration for Emacs and IntelliJ.

Summary

Emacs standalone

I use Cider, the Clojure Interactive Development Environment that Rocks for Emacs. Sure you can get your way with other tools like Spiral.

Dirac is implemented as a Piggieback middleware fork, so you cannot run both. Unfortunately Cider needs Piggieback so currently is incompatible with Dirac. However, you don’t actually need Dirac in Emacs because Cider offers a REPL which can connect to a browser or some more exotic environmeents like Node or Nashorn.

For this project specifically, Cider needs to use leiningen with profile emacs. It can be achieved that way:

(use-package cider
  :custom ((cider-lein-global-options "with-profile +emacs")))

Then, all you need to do is launch Cider for cljs:

(cider-jack-in-clojurescript)

Now you can open a browser and go to localhost:3449.

More documentation on Cider here. More on Dirac there.

Emacs hosts Figwheel and IntelliJ hosts Dirac

Just launch Cider like the previous section, then define a new local Clojure REPL in IntelliJ with profile intelli-j-dirac then start it. Once it’s ready, eval (dirac! :join) and launch Chrome Canary with Dirac extension installed.

You may prefer to launch latest Chrome Canary with a dedicated user profile, for example:

/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary \
  --remote-debugging-port=9222 \
  --no-first-run \
  --user-data-dir=.chrome-user-data-dir

Click on Dirac icon on the top right-hand corner.

Communication between Emacs, IntelliJ and Dirac REPL

IntelliJ and Dirac shares the same cljs runtime and both can access Cider vars. However Cider can’t access Dirac or IntelliJ runtime.

IntelliJ standalone

Like in the previous section, define a REPL. Start it, then start figwheel, and finally join Dirac runtime.

(figwheel-sidecar.repl-api/start-figwheel!)
(dirac! :join)

Update third party code

Anytime Dirac the-Chrome-Canary-extension gets bumped to a new version, you need to upgrate Dirac dependency version accordingly. A leiningen plugin can help you do so.

lein ancient upgrade :all :check-clojure :allow-all

Releases

No releases published

Packages

No packages published