0.2.0 • Published 5 years ago

parindent v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Parindent

Try it online

WIP public prototype— 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.