formatter
formatter copied to clipboard
Formatting let bindings
Similar to #7 on formatting maps, how should let bindings be formatted? Should all of the init-forms (right hand side) be aligned, or have a ragged alignment?
(let [a nil
very-long-symbol {}])
;; or
(let [a nil
very-long-symbol {}])
Should lines that are destructuring collections be handled differently? They can get very long and would cause large gaps in let bindings if they were included.
I vote for aligning ”simple” let bindings and handle the destructuring ones differently. What that ”differently” means is another matter. What are some common patterns in use out there?
As with #7 there is the issue of enforcing alignment might make adding bindings cause some diff tools to report more differences than really are there.
I vote for aligning ”simple” let bindings and handle the destructuring ones differently. What that ”differently” means is another matter. What are some common patterns in use out there?
Cursive just puts one space between the binding and the init-form:
(let [subject-date (js/goog.date.DateTime.)
a nil
{:keys [x y z ab]} {}]
...
What I started to think about was rather how people format the destructurings, but maybe that is just following any rules for maps and vectors?
Ah right, yes that's also another thing to consider, and would probably end up being treated the same.