cljfmt
cljfmt copied to clipboard
Thread macro is not honored
Give the following code:
(-> zz
(as-> x
foo))
It should be formatted as:
(-> zz
(as-> x
foo))
Which also happens to be what emacs clojure mode does.
However, cljfmt thinks the code is already formatted.
Steps to reproduce: clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.8.0"}}}' -m cljfmt.main check example.clj
Why should it be formatted that way? Can you give some justification?
It's like macro body forms two spaces indented.
foo here belongs to the body part.
https://github.com/bbatsov/clojure-style-guide#body-indentation
Similar to the fashion foo is indented here:
(as-> y x
foo)
The section of the Clojure style guide you link to recommends that forms shouldn't be indented 4 spaces, but in your original post you have indented 4 spaces. Was that a typo?
The issue is not about the format of -> but rather the inconsistency on how cljfmt handles as->.
Cljfmt requires that the body form to be two space indents, for example,
;; cljfmt thinks foo is correctly indented (1)
(as-> y
x
foo)
;; cljfmt thinks foo is not correctly indented (2)
(as-> y
x
foo)
The problem is, when the as-> is inside thread->, an implicit argument is placed; however, cljfmt seems to ignore it and formats it similar to the above case (2).
(-> y
(as-> x
foo))
Ah, yes, that's a known missing feature. Currently cljfmt is not aware of the threading macros when handling block indentation.
Duplicate of https://github.com/weavejester/cljfmt/issues/223.
Closed due to duplicate.