Skip to content

Commit a72478a

Browse files
dgrbbatsov
authored andcommitted
Deep editing pass on documentation (#2531)
1 parent f58093e commit a72478a

12 files changed

+828
-629
lines changed

doc/clojurescript.md

Lines changed: 77 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
## ClojureScript
22

3-
CIDER works with ClojureScript, but you should keep in mind that not all
4-
the functionality available with Clojure exists for ClojureScript (at least
5-
not yet). To give you a concrete example - things like running tests and
6-
the debugger are currently Clojure-only features.
3+
CIDER works well with ClojureScript, but not all CIDER features are
4+
available in ClojureScript (yet). For instance, the test runner and
5+
debugger are currently Clojure-only features. Unlike the Clojure
6+
ecosystem that is dominated by Leiningen and Boot, the ClojureScript
7+
ecosystem has a number of different choices for REPLs. You'll have to
8+
decide which one you want to run and how you want CIDER to interact
9+
with it. This chapter describes some of the more common choices
10+
and the configurations required to get them working.
711

812

913
### Piggieback
1014

1115
ClojureScript support relies on the [piggieback][] nREPL middleware
1216
being present in your REPL session. There's one exception to this,
13-
though - [shadow-cljs][]. It has its own nREPL middleware and doesn't rely
17+
though: [shadow-cljs][]. It has its own nREPL middleware and doesn't rely
1418
on piggieback at all.
1519

16-
If `cider-inject-dependencies-at-jack-in` is enabled (which is the default) then
17-
piggieback will be automatically added and configured for your project when
18-
doing `cider-jack-in-cljs`.
20+
If `cider-inject-dependencies-at-jack-in` is enabled, which it is by
21+
default, then piggieback will be automatically added and configured
22+
for your project when doing `cider-jack-in-cljs`.
1923

20-
If this configuration option is disabled or you're going to connect to
21-
an already running nREPL server using `cider-connect-cljs` - continue
22-
reading ahead.
24+
If `cider-inject-dependencies-at-jack-in` is disabled or you're going
25+
to connect to an already running nREPL server using
26+
`cider-connect-cljs`, use the configuration in the following section.
2327

2428
#### Manual Piggieback Setup
2529

26-
To setup piggieback add the following dependencies to your project
27-
(`project.clj` in Leiningen based project or `build.boot` in Boot
30+
To setup piggieback, add the following dependencies to your project
31+
(`project.clj` in a Leiningen based project or `build.boot` in a Boot
2832
project):
2933

3034
```clojure
@@ -50,32 +54,37 @@ or in `build.boot`:
5054

5155
### Starting a ClojureScript REPL
5256

53-
There are many ClojureScript REPLs out there and it's often hard to wrap your
54-
head around them and the differences between them. You'd do well to read [this
55-
awesome article](https://lambdaisland.com/guides/clojure-repls/clojurescript-repls)
56-
before proceeding with the rest of the instructions listed here.
57+
!!! Tip
5758

58-
Open a file in your project and issue <kbd>M-x</kbd>
59+
There are many ClojureScript REPLs available, each offering a
60+
different set of capabilities and features. As background for this
61+
section, you might want to read [this awesome
62+
article](https://lambdaisland.com/guides/clojure-repls/clojurescript-repls)
63+
before proceeding.
64+
65+
Open a file in your project and type <kbd>M-x</kbd>
5966
`cider-jack-in-cljs` <kbd>RET</kbd>. This will start up the nREPL
60-
server, and then create a ClojureScript REPL buffer for you, one.
67+
server and create a ClojureScript REPL buffer.
6168

6269
!!! Note
6370

6471
Prior to CIDER 0.18, `cider-jack-in-cljs` would create both a Clojure and
6572
a ClojureScript REPL. In CIDER 0.18+ if you want to create both REPLs
6673
you'll have to use `cider-jack-in-clj&cljs` instead.
6774

68-
When you have a combination of Clojure and ClojureScript REPLs all
69-
usual CIDER commands will be automatically directed to the appropriate
70-
REPL, depending on whether you're visiting a `.clj` or a `.cljs` file.
75+
When you have a combination of Clojure and ClojureScript REPLs, CIDER
76+
will automatically direct all the usual CIDER commands to the
77+
appropriate REPL based on whether you're currently visitng a `.clj` or
78+
`.cljs` file.
7179

72-
`cider-jack-in-cljs` will prompt you about the type of
73-
ClojureScript to start. Keep in mind that some of the REPLs will
74-
require some additional setup, before you can make use of them (e.g. you'll
75-
need to have Node.js installed to be able to start a node REPL).
80+
`cider-jack-in-cljs` will prompt you for the type of ClojureScript
81+
REPL you want to start. Keep in mind that some of the REPLs will
82+
require you to configure additional setup. For example, you'll need to
83+
have Node.js installed to be able to start a Node REPL.
7684

77-
You can suppress the prompt the REPL to use by setting `cider-default-cljs-repl`.
78-
Here's an example that will make Nashorn the default:
85+
If you frequently use the same ClojureScript REPL, you can set
86+
`cider-default-cljs-repl` and CIDER will skip the prompt and use this
87+
instead. For example, the following will make Nashorn the default:
7988

8089
```el
8190
(setq cider-default-cljs-repl 'nashorn)
@@ -106,20 +115,20 @@ You can also modify the known ClojureScript REPLs on a per-project basis using
106115
(cider-default-cljs-repl . super-cljs)))
107116
```
108117

109-
You can also create a ClojureScript REPL with the command
110-
`cider-jack-in-sibling-clojurescript` in cases where you already have a
111-
Clojure REPL running.
118+
If you already have a Clojure REPL running and want to add a
119+
ClojureScript REPL, you can invoke
120+
`cider-jack-in-sibling-clojurescript` to add it.
112121

113-
Continue reading for the additional setup needed for the various ClojureScript
114-
REPLs out there.
122+
The following sections describe the configurations for several common
123+
CloudScript REPL use cases.
115124

116-
### Browser-connected ClojureScript REPL
125+
### Browser-Connected ClojureScript REPL
117126

118127
Using Weasel, you can also have a browser-connected REPL.
119128

120129
1. Add `[weasel "0.7.0"]` to your project's `:dependencies`.
121130

122-
2. Issue <kbd>M-x</kbd> `cider-jack-in-cljs` <kbd>RET</kbd> and choose
131+
2. Type <kbd>M-x</kbd> `cider-jack-in-cljs` <kbd>RET</kbd> and choose
123132
the `Weasel` option when prompted about the ClojureScript REPL type you want
124133
to use.
125134

@@ -131,15 +140,15 @@ Using Weasel, you can also have a browser-connected REPL.
131140
(repl/connect "ws://localhost:9001")
132141
```
133142

134-
4. Open a file in your project and issue <kbd>M-x</kbd> `cider-jack-in-cljs`.
143+
4. Open a file in your project and type <kbd>M-x</kbd> `cider-jack-in-cljs`.
135144

136145
Provided that a Piggieback-enabled ClojureScript environment is active in your
137146
REPL session, code loading and evaluation will work seamlessly regardless of the
138147
presence of the `cider-nrepl` middleware. If the middleware is present then most
139148
other features of CIDER will also be enabled (including code completion,
140149
documentation lookup, the namespace browser, and macroexpansion).
141150

142-
### Browser-connected ClojureScript REPL in Boot project
151+
### Browser-Connected ClojureScript REPL in Boot Projects
143152

144153
1. Add this to your dependencies in `build.boot`:
145154

@@ -166,10 +175,10 @@ and this at the end of `build.boot`:
166175
(cljs)))
167176
```
168177

169-
2. Issue <kbd>M-x</kbd> `customize-variable` <kbd>RET</kbd> `cider-boot-parameters`
178+
2. Type <kbd>M-x</kbd> `customize-variable` <kbd>RET</kbd> `cider-boot-parameters`
170179
and insert `dev`.
171180

172-
3. Open a file in your project and issue <kbd>M-x</kbd> `cider-jack-in-cljs`.
181+
3. Open a file in your project and type <kbd>M-x</kbd> `cider-jack-in-cljs`.
173182

174183
5. Connect to the running server with your browser. The address is printed on the terminal, but it's probably `http://localhost:3000`.
175184

@@ -195,7 +204,7 @@ You can also use [Figwheel](https://github.com/bhauman/lein-figwheel) with CIDER
195204
```
196205

197206
Keep in mind that figwheel 0.5.16 is the first to support piggieback
198-
0.3. If you're using an older figwheel you should stick to piggieback
207+
0.3. If you're using an older figwheel, you should stick to piggieback
199208
0.2.2 (which uses the old `com.cemerick/piggieback` package coordinates).
200209

201210
3. Add this to your dev `:repl-options` (not needed for `cider-jack-in-cljs`):
@@ -205,7 +214,7 @@ Keep in mind that figwheel 0.5.16 is the first to support piggieback
205214
```
206215

207216
4. Start the REPL with `cider-jack-in-cljs` (<kbd>C-c C-x (C-)j (C-)s</kbd>). Select
208-
`figwheel` when prompted about the ClojureScript REPL type.
217+
`figwheel` when prompted for the ClojureScript REPL type.
209218

210219
5. Open a browser to the Figwheel URL so that it can connect to your application.
211220

@@ -221,10 +230,10 @@ You should also check out
221230

222231
You can also use [Figwheel-main](https://github.com/bhauman/figwheel-main) with CIDER.
223232

224-
1. Add this to your dev `:dependencies`:
233+
1. Add this to your dev `:dependencies` (not needed for `cider-jack-in-cljs`):
225234

226235
```clojure
227-
[cider/piggieback "0.3.10"] ; not needed for cider-jack-in-cljs
236+
[cider/piggieback "0.3.10"]
228237
```
229238

230239
2. Add this to your dev `:repl-options` (not needed for `cider-jack-in-cljs`):
@@ -233,30 +242,31 @@ You can also use [Figwheel-main](https://github.com/bhauman/figwheel-main) with
233242
:nrepl-middleware [cider.piggieback/wrap-cljs-repl]
234243
```
235244

236-
3. Start the REPL with `cider-jack-in-cljs` (<kbd>C-c C-x (C-)j (C-)s</kbd>). Select
237-
`figwheel-main` when prompted about the ClojureScript REPL type.
245+
3. Start the REPL with `cider-jack-in-cljs` (<kbd>C-c C-x (C-)j
246+
(C-)s</kbd>). When CIDER prompts about the ClojureScript REPL type,
247+
type `figwheel-main`.
238248

239249
4. Select the Figwheel build to run when prompted for it. (e.g. `:dev`).
240250

241251
### Using shadow-cljs
242252

243-
Provided you've configured your project correctly you can simply use
244-
`cider-jack-in-cljs` to use `shadow-cljs`.
253+
Provided you've configured your project correctly, you can simply use
254+
`cider-jack-in-cljs` for `shadow-cljs`.
245255

246-
This will automatically start the shadow-cljs server and connect to it. You'll also
247-
be prompted for the build to use.
256+
This will automatically start the shadow-cljs server and connect to
257+
it. You'll also be prompted for the build to use.
248258

249259
Alternatively you can start the server manually with something like:
250260

251-
```
252-
npx shadow-cljs server
261+
```sh
262+
$ npx shadow-cljs server
253263
```
254264

255265
And connect to it with `cider-connect`.
256266

257-
Lastly, if you already have a running server watching a build, for instance you
258-
have already run `npx shadow-cljs watch :dev`, you can use the `shadow-select`
259-
CLJS REPL and specify `:dev` when prompted.
267+
If you already have a running server watching a build (for instance
268+
you have already run `npx shadow-cljs watch :dev`), you can use the
269+
`shadow-select` CLJS REPL and specify `:dev` when prompted.
260270

261271
[leiningen]: http://leiningen.org/
262272
[boot]: http://boot-clj.com/
@@ -265,14 +275,16 @@ CLJS REPL and specify `:dev` when prompted.
265275

266276
## Working with `.cljc` files
267277

268-
Ordinarily, CIDER dispatches code from `clj` files to Clojure REPLs and `cljs`
269-
files to ClojureScript REPLs. However, `cljc` files have two possible connection
270-
targets. By default, CIDER tries to evaluate `cljc` files in all matching
271-
connection buffers, both `clj` and `cljs` (if present).
272-
273-
Simply put - if you're evaluating the code `(+ 2 2)` in a `cljc` file and you
274-
have an active Clojure and and active ClojureScript REPL, then the code is going
275-
to be evaluated twice - once for each of the REPLs. In fact, you can create
276-
multiple clj and cljs sibling connections (<kbd>C-c C-x C-s C-s/j</kbd>) within
277-
Cider session and evaluation will be directed into all REPLs simultaneously. See
278-
[Managing Connections](managing_connections.md) for more details.
278+
Ordinarily, CIDER dispatches code from `clj` files to Clojure REPLs
279+
and `cljs` files to ClojureScript REPLs. But`cljc` files have two
280+
possible connection targets, both of which are valid. So, by default,
281+
CIDER tries to evaluate `cljc` files in all matching connection
282+
buffers, both `clj` and `cljs`, if present.
283+
284+
Thus, if you're evaluating the code `(+ 2 2)` in a `cljc` file and you
285+
have both an active Clojure and ClojureScript REPL then the code is
286+
going to be evaluated twice, once in each of the REPLs. In fact, you
287+
can create multiple clj and cljs sibling connections (<kbd>C-c C-x C-s
288+
C-s/j</kbd>) within a CIDER session and evaluation will be directed
289+
into all REPLs simultaneously. See [Managing
290+
Connections](managing_connections.md) for more details.

doc/code_completion.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,31 @@ dedicated buffer.
1818

1919
## Auto-completion
2020

21-
CIDER users are advised to use [`company-mode`](http://company-mode.github.io/)
22-
to enable auto-completion inside of source code and REPL buffers. To install
23-
`company-mode` do:
21+
While the standard Emacs tooling works just fine, we suggest that
22+
CIDER users consider using
23+
[`company-mode`](http://company-mode.github.io/) instead. Company mode
24+
can be used for auto-completion for both source code and REPL buffers.
25+
To install `company-mode`:
2426

2527
<kbd>M-x</kbd> `package-install` <kbd>RET</kbd> `company` <kbd>RET</kbd>
2628

27-
After installation, company can be turned on globally, like so --
29+
After installation, you can turn on `company-mode` globally:
2830

2931
```el
3032
(global-company-mode)
3133
```
3234

33-
-- or through mode-specific hooks:
35+
or through mode-specific hooks:
3436

3537
```el
3638
(add-hook 'cider-repl-mode-hook #'company-mode)
3739
(add-hook 'cider-mode-hook #'company-mode)
3840
```
3941

40-
When `company-mode` is thus enabled, it will receive completion information
41-
from `cider-complete-at-point`, and requires no additional setup or plugins.
42+
When `company-mode` is enabled, it will receive completion information
43+
from `cider-complete-at-point` and requires no additional setup or plugins.
4244

43-
If you'd prefer to trigger completions manually you can add this to you config:
45+
If you'd prefer to trigger completions manually you can add this to your config:
4446

4547
```el
4648
(setq company-idle-delay nil) ; never start completions automatically
@@ -56,22 +58,25 @@ you can add this to your config:
5658

5759
### Fuzzy candidate matching
5860

59-
By default `company-mode` will provide completion candidates with the assumption
60-
that whatever you've typed so far (e.g. `map-`) is a completion prefix (meaning
61-
you'd get only candidates that have `map-` in the beginnings of their names).
62-
You can get enhanced fuzzy completion with the CIDER-specific completion style
63-
by adding:
61+
By default `company-mode` will provide completion candidates with the
62+
assumption that whatever you've typed so far is a prefix of what
63+
you're really trying to type. For example, if you type `map-` then
64+
you'll only get completion candidates that have `map-` as the
65+
beginning of their names. Sometimes, you don't know the exact prefix
66+
for the item you want to type. In this case, you can get
67+
CIDER-specific "fuzzy completion" by adding:
6468

6569
```el
6670
(add-hook 'cider-repl-mode-hook #'cider-company-enable-fuzzy-completion)
6771
(add-hook 'cider-mode-hook #'cider-company-enable-fuzzy-completion)
6872
```
6973

70-
Now `company-mode` will accept certain fuzziness when matching candidates
71-
against the prefix. For example, typing `mp` will show you `map-indexed` as one
72-
of the possible completion candidates, `cji` will complete to `clojure.java.io`,
73-
etc. Different completion examples are
74-
listed [here](https://github.com/alexander-yakushev/compliment/wiki/Examples).
74+
Now, `company-mode` will accept certain fuzziness when matching
75+
candidates against the prefix. For example, typing `mp` will show you
76+
`map-indexed` as one of the possible completion candidates and `cji`
77+
will complete to `clojure.java.io`. Different completion examples are
78+
shown
79+
[here](https://github.com/alexander-yakushev/compliment/wiki/Examples).
7580

7681
### Completion annotations
7782

0 commit comments

Comments
 (0)