Skip to content

Commit ba5680b

Browse files
committed
Extend the shadow-cljs documentation
1 parent 352cc04 commit ba5680b

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

doc/modules/ROOT/pages/cljs/shadow-cljs.adoc

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
11
= Using shadow-cljs
22
:experimental:
33

4+
`shadow-cljs` is one of the most popular toolchain for doing ClojureScript
5+
development these days. In this section we'll discuss how to set it up and
6+
use it together with CIDER.
7+
8+
== Setting up shadow-cljs
9+
10+
NOTE: This section assumes you've already installed node.js.
11+
12+
Installing `shadow-cljs` is pretty straight-forward. You can do it via `npm` or `yarn`:
13+
14+
$ npm install -g shadow-cljs
15+
$ yarn global add shadow-cljs
16+
17+
While it's not necessary to do a global installation that's generally the recommended approach.
18+
19+
== Starting a shadow-cljs REPL
20+
21+
=== Using cider-jack-in-cljs
22+
423
Provided you've configured your project correctly, you can simply use
5-
`cider-jack-in-cljs` for `shadow-cljs`.
24+
`cider-jack-in-cljs`:
25+
26+
* Press kbd:[C-c C-x j s] (or do `M-x cider-jack-in-cljs`)
27+
* When prompted for the ClojureScript REPL type to start, select `shadow`
628

729
This will automatically start the shadow-cljs server and connect to
8-
it. You'll also be prompted for the build to use.
30+
it. You'll also be prompted for the shadow-cljs build to use. Select
31+
your desired build (e.g. `app`) and you should see something like:
32+
33+
shadow.user> To quit, type: :cljs/quit
34+
[:selected :app]
35+
cljs.repl>
36+
37+
NOTE: CIDER will extract the list of available builds automatically
38+
from the `shadow-cljs.edn` file in the root of the current project.
39+
40+
You can get rid of the prompts for the REPL type and the target build
41+
by creating a `.dir-locals.el` file with the following contents in the
42+
root of your project.
43+
44+
[source,clojure]
45+
----
46+
((nil . ((cider-default-cljs-repl . shadow)
47+
(cider-shadow-default-options . "<your-build-name-here>"))))
48+
----
49+
50+
=== Using cider-connect-cljs
951

1052
Alternatively you can start the server manually with something like:
1153

@@ -19,3 +61,34 @@ And connect to it with `cider-connect`.
1961
If you already have a running server watching a build (for instance
2062
you have already run `npx shadow-cljs watch :dev`), you can use the
2163
`shadow-select` CLJS REPL and specify `:dev` when prompted.
64+
65+
== Configuration
66+
67+
You can tweak the command used by `cider-jack-in-cljs` to start the `shadow-cljs` server
68+
via the following configuration variables:
69+
70+
* `cider-shadow-cljs-command` (its default value is `npx shadow-cljs`)
71+
* `cider-shadow-cljs-global-options` (its default value is blank)
72+
* `cider-shadow-cljs-parameters` (its default value is `server`)
73+
74+
All of this results in the following default command to start the shadow-cljs server:
75+
76+
$ npx shadow-cljs server
77+
78+
The command is visible in the minibuffer when you're doing `cider-jack-in-cljs`.
79+
80+
As noted earlier you can also set a default build via `cider-shadow-default-options`:
81+
82+
(setq cider-shadow-default-options "app")
83+
84+
== Additional Resources
85+
86+
Here are a few useful sections from `shadow-cljs`'s own documentation:
87+
88+
* https://shadow-cljs.github.io/docs/UsersGuide.html#_installation[Installation]
89+
* https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL[nREPL Setup]
90+
* https://shadow-cljs.github.io/docs/UsersGuide.html#cider[Integration with CIDER]
91+
92+
=== Tutorials
93+
94+
* https://cestlaz.github.io/post/using-emacs-63-clojurescript/[Using shadow-cljs with CIDER]

0 commit comments

Comments
 (0)