-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Threaded cond-> indents strangely #45
Comments
cljfmt currently doesn't take the outer form into consideration when performing indentation. Perhaps a rule can be added to look for an outer |
I don't think looking at the outer form should be necessary, I just included it to motivate my not wanting to treat the first argument as special. It seems to me a better rule for (cond-> a
b c
d e)
(-> v
(cond->
a b
c d))
(-> v
(cond->
a
b
c
d)) |
What about this form: (-> v
(cond-> a b
c d)) There are also other forms that are affected by an outer (-> (StringBuilder.)
(doto
(.append "foo")
(.append "bar"))
(.toString)) I think it's worth putting in a specific rule for |
Popping in to say I've also encountered this. It seems that it's less to do with nesting forms and more to do with the placement of the first value in a threading form, so that cljfmt will issue suggestions like this even when there is only one threading form: (cond->
- a
+ a
b
c
d)) When the threaded value is given its own line, cljfmt wants it indented by one space – but wants subsequent forms indented by two. This caused a bit of confusion for my team when It may be worth noting that, besides being a little bit surprising, this formatting is also incompatible with parinfer. |
Are there any plans to fix/support this? It's causing us some issues due to style conflicts with other editors/formatters |
I'm happy to accept a pull request for this, of course, but I don't have any plans in the near future for resolving this myself. Unfortunately I have a backlog of issues and features that I need to tackle before this. |
cond->
andcond->>
fit neatly into bigger->
forms, but the default indenting rules don't seem to work for that usage when conditions and threaded forms are each on their own line.So cljfmt likes this:
But wants to change this:
like so:
It wants the first arg indented 1 space, the rest indented 2.
(Incidentally my out of date version of cider doesn't like either of those indentations and has its own bad ideas about always treating the first arg specially.)
The text was updated successfully, but these errors were encountered: