Parindent is just an idea for this discussion on standard clojure indentation, fork it if you believe it warrants further experimenting.
Indent Clojure files based on the following discussions:
- ALLOW - 1-space, 2-space, or Arg-alignment (user preference determined by first sibling line)
- ENFORCE - vertically aligned sibling lines
- ENFORCE - indentation after a paren should imply containment
Staggered indentation of siblings not allowed:
(cond
foo
- bar
+ bar
baz
- qux)
+ qux)
Cannot indent past an open-paren unless contained inside it (Parinfer):
(defn foo
([a b]
- (+ a b))
+ (+ a b))
([a b c]
- (+ a b c)))
+ (+ a b c)))
npm install -g parindent
To indent all your files in place, run from your project root:
parindent '**/*.{clj,cljs,cljc}' --write
$ parindent
Usage: parindent [opts] [filename ...]
A minimal indenter for Lisp code (e.g. Clojure)
Available options:
--write Edit the file in-place. (Beware!)
--list-different or -l Print filenames of files that are different from Parindent formatting.
--stdin Read input from stdin.
--version or -v Print Parindent version.