Skip to content

Commit a34fc95

Browse files
committed
Extend a bit the ClojureScript section of the manual
1 parent 12735ad commit a34fc95

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

doc/up_and_running.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,22 @@ helpful for identifying each host.
7979

8080
## ClojureScript usage
8181

82-
ClojureScript support relies on the [piggieback][] nREPL middleware being
83-
present in your REPL session.
82+
CIDER works with ClojureScript, but you should keep in mind that not all
83+
the functionality available with Clojure exists for ClojureScript (at least
84+
not yet). To give you a concrete example - things like running tests and
85+
the debugger are currently Clojure-only features.
8486

85-
Add the following dependencies to your project (`project.clj` in
86-
Leiningen based project or `build.boot` in Boot project):
87+
ClojureScript support relies on the [piggieback][] nREPL middleware
88+
being present in your REPL session. There's one exception to this,
89+
though - [shadow-cljs][]. It has its own nREPL middleware and doesn't rely
90+
on piggieback at all.
91+
92+
To setup piggieback add the following dependencies to your project
93+
(`project.clj` in Leiningen based project or `build.boot` in Boot
94+
project):
8795

8896
```clojure
97+
;; use whatever are the most recent versions here
8998
[cider/piggieback "0.3.1"]
9099
[org.clojure/clojure "1.7.0"]
91100
```
@@ -117,6 +126,33 @@ ClojureScript. All usual CIDER commands will be automatically directed to the
117126
appropriate REPL, depending on whether you're visiting a `.clj` or a `.cljs`
118127
file.
119128

129+
`cider-jack-in-clojurescript` will prompt you about the type of
130+
ClojureScript to start. Keep in mind that some of the REPLs will
131+
require some additional setup, before you can make use of them (e.g. you'll
132+
need to have Node.js installed to be able to start a node REPL).
133+
134+
You can suppress the prompt the REPL to use by setting `cider-default-cljs-repl`.
135+
Here's an example that will make Nashorn the default:
136+
137+
```el
138+
(setq cider-default-cljs-repl "Nashorn")
139+
```
140+
141+
All supported ClojureScript REPLs are stored in
142+
`cider-cljs-repl-types`. If you need to extend it, you should use
143+
`cider-register-cljs-repl-type` in your Emacs configuration.
144+
145+
```el
146+
(cider-register-cljs-repl-type "super-cljs" "(do (...))" optional-requirements-function)
147+
```
148+
149+
You can also create a ClojureScript REPL with the command
150+
`cider-create-sibling-cljs-repl` in cases where you already have a
151+
Clojure REPL running.
152+
153+
Continue reading for the additional setup needed for the various ClojureScript
154+
REPLs out there.
155+
120156
### Browser-connected ClojureScript REPL
121157

122158
Using Weasel, you can also have a browser-connected REPL.
@@ -213,9 +249,26 @@ CIDER will determine which to use based on the type of file you're editing.
213249
You should also check out
214250
[Figwheel's wiki](https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl).
215251

252+
### Using shadow-cljs
253+
254+
Provided you've configured your project correctly you can simply use
255+
`cider-jack-in-clojurescript` to use `shadow-cljs`.
256+
257+
This will automatically start the shadow-cljs server and connect to it. You'll also
258+
be prompted for the build to use.
259+
260+
Alternatively you can start the server manually with something like:
261+
262+
```
263+
npx shadow-cljs server
264+
```
265+
266+
And connect to it with `cider-connect`.
267+
216268
[leiningen]: http://leiningen.org/
217269
[boot]: http://boot-clj.com/
218270
[piggieback]: https://github.com/clojure-emacs/piggieback
271+
[shadow-cljs]: https://github.com/thheller/shadow-cljs
219272

220273
## Working with `.cljc` files
221274

0 commit comments

Comments
 (0)