weavejester / cljfmt

A tool for formatting Clojure code
Eclipse Public License 1.0
1.11k stars 120 forks source link

Make one space list indentation configurable #323

Closed miridius closed 10 months ago

miridius commented 10 months ago

Per the discussion in #97, cljfmt follows the Clojure Style Guide's rule of indenting function/macro arguments by 1 space if there are no arguments on the same line as the function name. In other words, it is indented as if it were simply a list like any other data structure. Conversely, functions or macros that have a "body" are indented by 2 spaces.

This is in my experience a somewhat controversial recommendation and not always followed in the wild. Both Cursive and zprint use 2 space indentation for function arguments by default, for example. So I think it would be helpful to have a configuration option to let users choose whether to use 1 or 2 spaces for function argument indentation.

[!NOTE]
The definition of what is an "argument" vs a "body" is a little bit vague and sometimes feels a little contradictory. For example, -> is considered to have arguments, but as-> has a body. if has a body, but and and or have arguments. I think this is one of the reasons that some users prefer just to use 2 spaces across the board.