cljstyle
cljstyle copied to clipboard
Support for vertical alignment?
Clojure Mode for Emacs supports vertical alignment, as does Calva's formatter. Any thoughts on what it might take to add this to cljstyle?
Looks like cljfmt has had a WIP PR open for a while for this: https://github.com/weavejester/cljfmt/pull/77
I personally would like that to be doable both ways if possible (via config), turn a vertical style code base into "normal" alignement or the inverse.
This does seem like it would be a good optional feature. You would need to write a formatting rule that looks for maps and various kinds of bindings with alternating pairs, then figure out how much whitespace needed to be between each binding to align with the longest one.
Excellent. Here's the prior art:
- Clojure Mode for Emacs: https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L1246
- Calva's formatter eventually just calls a fork of cljfmt: https://github.com/PEZ/cljfmt/blob/master/cljfmt/src/cljfmt/core.cljc#L497
I'll take a stab at this when I have some time.
Just kidding, @dparis is going to take a stab at it. I know this because I work with him. You're on the hook now, buddy.
Update: I've gotten a first pass implementation up on my fork https://github.com/dparis/cljstyle/pull/1/files
There are a few known cases that aren't working that I still need to fix, and I'd like to do a code quality pass, but overall seems to work decently. I'll submit a PR against upstream once those things are sorted out.
Hi guys, i was just trying enable this in cljstyle and bumped in this issue and there is a help-needed label, is there a way to help in this?