cljfmt icon indicating copy to clipboard operation
cljfmt copied to clipboard

Discards lexical ,

Open arrdem opened this issue 8 years ago • 6 comments

It should be possible to use leading , to force indentation. cljfmt currently strips leading , leading to unexpected changes in indentation.

arrdem avatar Mar 18 '16 23:03 arrdem

This is due to the treatment of , as simple whitespace by rewrite-clj, currently being addressed over there in xsc/rewrite-clj#44

arrdem avatar Mar 28 '16 22:03 arrdem

[rewrite-clj "0.5.0"] brings :comma nodes which makes this more tractable. https://github.com/xsc/rewrite-clj/releases/tag/clojars-0.5.0

arrdem avatar Apr 03 '16 16:04 arrdem

Looking at the linked examples, it looks like you want to keep commas when they're the first non-whitespace character on the line.

And anywhere else, removing them is fine?

MatthewDarling avatar Dec 21 '17 23:12 MatthewDarling

So I use ,, as a line prefix in require/import forms since none of the indenters happen to understand or format prefix lists meaningfully and that trick happens to work in CIDER. Same thing for cond and other forms which have consecutive pairs that are not typically block indented when on different lines.

In general, I'm not sure that cljfmt should be removing commas when they occur.

arrdem avatar Dec 22 '17 00:12 arrdem

Is this still an issue? I can't reproduce it, for me commas remain untouched. But I also couldn't reproduce it with older versions (tried 0.4.1, 0.5.0, which were current at the time), maybe I'm missing something.

or avatar May 10 '22 06:05 or

@or one example I have that removes the comma is

(->> [] (map identity ,))

It's likely related to removing leading/trailing whitespace?

leafgarland avatar Jun 28 '22 02:06 leafgarland