SignSpice / parindent

prototype for standardizing indentation in clojure files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parindent is just an idea for this discussion on standard clojure indentation, fork it if you believe it warrants further experimenting.

Parindent

Try it online

Indent Clojure files based on the following discussions:

Current Rules

  1. ALLOW - 1-space, 2-space, or Arg-alignment (user preference determined by first sibling line)
  2. ENFORCE - vertically aligned sibling lines
  3. ENFORCE - indentation after a paren should imply containment

Friction

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)))

Install

npm install -g parindent

Try it

To indent all your files in place, run from your project root:

parindent '**/*.{clj,cljs,cljc}' --write

Usage

$ 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.

About

prototype for standardizing indentation in clojure files


Languages

Language:JavaScript 90.1%Language:HTML 9.9%