The Prerequisite setup is in the README (See also running with Cursive)
For background on using ClojureScript in CIDER see ClojureScript usage.
Make sure you have your CIDER installed in Emacs (e.g. by adding it from the MELPA package repository).
Now you can customize your CIDER configuration. Start by
entering M-x customize
, enter "cider" in the search box,
and press Search.
- Make sure the Cider Boot Command has the fully qualified path to where
you installed boot (usually in
~/bin
). - Set your Cider Boot Parameters to
cider-boot
When youcider-jack-in
this will call thecider-boot
task in yourbuild.boot
file. If, for other projects, you don't need to do any extra steps prior to running thecider
task itself (fromprofile.boot
) then you can just make a simple task like this:
(deftask cider-boot
"Cider boot params task"
[]
(cider))
- Set Cider Cljs Lein Repl to
Weasel
- For all the variables you changed be sure to click on State and select "Save for future sessions"
Visit app.cljs in a buffer and change
(def cursive? true)
to
(def cursive? false)
Now you're ready to M-x cider-jack-in-clojurescript
(on C-c M-J).
You will see a message Starting nREPL server via ...
which
will take a little while to run and set things up...
You will then see the question (because we have both build.boot
and project.clj
files), then enter "boot":
Which command should be used (default lein): boot
In the buffer cider-repl CLJS tenzing3 you will see
boot.user> << started Weasel server on ws://127.0.0.1:9001 >>
<< waiting for client to connect ...
You will then see this question and answer "n":
Visit 'http://localhost:3000' in a browser? (y or n) n
...because we do want to visit that web page, but at this point not all the ClojureScript files have been compiled (so let's be patient)!
When everything is ready you should hear an audible sound and see a notification
CLJS: http://localhost:3000 is ready
Now you can open (or reload) http://localhost:3000
In your browser JavaScript console you should see:
Opened Websocket REPL connection repl.js:168:1
Reload websocket connected.
In the buffer cider-repl CLJS tenzing3 you can change the
namespace for app.cljs
like this:
boot.user> (in-ns 'tenzing3.app)
tenzing3.app>
Now visit the app.cljs
buffer and enter M-x cider-eval-buffer
: this
will evaluate the file so all the symbols are defined in the REPL. At
this point you can evaluate a simple symbol:
tenzing3.app> baz
{:b 456}
tenzing3.app>
Now in app.cljs
if you change the definition of baz
to {:b 457}
and save the file you will notice that browser is updated automatically!
Whenever the browser is reloaded you'll see a new line like
i'm dynamically created at Thu Jan 26 2017 10:43:36 GMT-0600 (CST)
You can also print directly to the JavaScript console (where you should see 123 appear):
tenzing3.app> (println 123)
nil
tenzing3.app>
In the buffer cider-repl tenzing3 you can change the
namespace for server.clj
like this:
boot.user> (in-ns 'tenzing3.server)
tenzing3.server>
Now visit the server.clj
buffer and enter M-x cider-eval-buffer
: this
will evaluate the file so all the symbols are defined in the REPL. At
this point you can evaluate a simple symbol and call a function:
tenzing3.server> bar
{:a 123}
tenzing3.server> (foo bar)
foo with args: ({:a 123})
nil
tenzing3.server>
When you are done go to the cider-repl tenzing3 buffer
and enter M-x cider-quit
(on C-c C-q).
You will be asked (and can answer "y"):
Also kill server process and buffer? (y or n) y
You can now simply kill the cider-repl CLJS tenzing3 buffer.