This is a beginner-friendly Clojure setup for Atom, with a minimal set of package dependencies and custom keybindings. Credit goes to @jasongilman for his excellent ProtoREPL setup guide, from which I copied much of the content for this guide.
There are many improvements that can be made to this setup as you gain experience with Atom, Clojure, and related packages, but this guide is intended to focus on the essential basics a beginner needs for a smooth REPL-driven workflow.
Jump down to Configuration summary for the TL;DR if you're already comfortable configuring Atom.
The Atom documentation is excellent. It's highly worth reading the flight manual.
- Java (choose one of the following; I prefer Amazon Corretto)
- Amazon Corretto
- AdoptOpenJDK
- Other options (mind the license restrictions)
- Leiningen
These are the ones I install related to Clojure development.
- Party REPL - Clojure REPL with remote pairing support
- Parinfer - Handles parentheses and general Lisp editing.
- lisp-paredit - Used only for some basic cursor motions (expand/contract selection, forward/backward s-expression)
- (optional) teletype - Remote collaboration tool (required for Party REPL's remote pairing support)
The files attached to this gist show my completed configuration settings. If you're setting up Atom from scratch you can use these files verbatim and skip the following configuration instructions.
This is the built in package that comes with Atom for the Clojure Grammar. I find the default settings bad for the way that I work. I recommend changing them to the following.
- Auto Indent: unchecked
- Auto Indent On Paste: unchecked
- Non Word Characters:
()"':,;~@#$%^&{}[]
- Tab Length:
1
Everything else is left at the default.
- Enabled: checked
- Strict: unchecked
- Indentation Forms:
try, catch, finally, /^let/, are, /^def/, fn, cond, condp, /^if.*/, /.*\/for/, for, for-all, /^when.*/, testing, doseq, dotimes, ns, routes, GET, POST, PUT, DELETE, extend-protocol, loop, do, case, with-bindings, checking, with-open
- Keybindings Enable: unchecked
- Smart Mode: checked
These are main Atom settings related to Clojure that are different than the default.
- Auto Indent On Paste: unchecked
- Scroll Past End: checked
- Due to this autocomplete issue there is a lot of flashing from the autocomplete window that pops up. Scrolling down farther usually resolves the issue.
Open your config.cson
file (Application: Open Your Config
in Atom command palette) and add the following under the ".clojure.source":
heading (credit @lucasdf):
"bracket-matcher":
autocompleteCharacters: [
"()"
"[]"
"{}"
"\"\""
"“”"
"‘’"
"«»"
"‹›"
]
Open your keymap.cson
file (Application: Open Your Keymap
in Atom command palette) and add the following entry:
'atom-text-editor[data-grammar~="clojure"]':
'alt-up': 'lisp-paredit:expand-selection'
'alt-down': 'lisp-paredit:contract-selection'
'alt-right': 'lisp-paredit:forward-sexp'
'alt-left': 'lisp-paredit:backward-sexp'
'enter': 'lisp-paredit:newline'
The above keybindings give you basic s-expression navigation capabilities. alt-right
and alt-left
move the cursor forward or backward to the next s-expression boundary. Use these keystrokes, along with simple right
and left
arrow keypresses, to move the cursor quickly through your code.
Party REPL provides a default OSX keybinding of cmd-enter
(ctrl-enter
on Linux/Windows) to send the current top-level form to be evaluated in the REPL. To evaluate an inner form I use cmd-up
to select the inner form I'm interested in, then use cmd-enter
to evaluate just the selected form.
Parinfer has an excellent guide that describes how it works. I prefer using Indent/Smart mode in the Atom Parinfer package.