Skip to content

Conversation

avocade
Copy link

@avocade avocade commented Oct 10, 2025

Correctly align maps and forms with columnar layout.

Enable with :align-maps? true and :align-forms? true in .cljfmt.clj config file.


Based almost entirely on the great work by reutsharabani in his two PRs:

reutsharabani#1
reutsharabani#3

With a sprinkle of magic dust on top to fix null pointer exceptions and whitespace issues for complex binding forms like map and vector:

(let [{:keys [a b]} (foo)] ...)

and

(let [[a b] (foo)] ...)

@avocade
Copy link
Author

avocade commented Oct 10, 2025

Note that it's still a draft PR, and has very little testing yet (except the beefed-up test suite). So play around, but not ready for anything serious yet. Needs more testing in production codebases, and more test cases to cover edge cases.

I'd prefer the blessing of the original author @reutsharabani if this is to be taken forward, since he's done the heavy lifting.

also needs to be rebased on master of course.

like for map- or vector-destructuring; add whitespace between the top forms and
not inside the vector (ie in `[[a b] (foo)]` or `[{:keys [a b]} (baz)]`)
@avocade avocade force-pushed the align-forms-and-maps branch 2 times, most recently from 3dc2591 to 25e1f17 Compare October 10, 2025 15:27
@reutsharabani
Copy link

Most of the work here was done by weavejester. I expect he is very busy but hopefullyyou can make it happen!

And I am a she not a he :)

@weavejester
Copy link
Owner

I've had a lull in my work, so this PR came at the right time to encourage me to return to this. I'm currently working on the align-maps branch of this repository, and the work done on all the tests here has been invaluable.

The branch is currently mostly working. I'm currently in the middle of porting all the tests over and fixing any issues they raise. I'll be spending a few days on this so I'm hoping to put this issue finally to rest.

Thanks again to everyone who contributed.

weavejester added a commit that referenced this pull request Oct 12, 2025
Add the :align-map-columns? option. This will align the keys and values
of maps such that they line up in columns. Defaults to false.

This option only works on maps, not binding vectors (such as in 'let').

Partially solves #35. Closes #299. Closes #370.
weavejester added a commit that referenced this pull request Oct 12, 2025
Add the :align-map-columns? option. This will align the keys and values
of maps such that they line up in columns. Defaults to false.

This option only works on maps, not binding vectors (such as in 'let').

Partially solves #35. Closes #299. Closes #370.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants