goclj icon indicating copy to clipboard operation
goclj copied to clipboard

Support regexp pattern matching in cljfmt.clj config file

Open mrkam2 opened this issue 4 years ago • 1 comments

In my recent PR https://github.com/liftoffio/liftoff/pull/12386 I added more than a 100 functions to the indent-overrides. All of them could've been specified with a single regexp expression. See the corresponding PR comment.

mrkam2 avatar Jan 20 '21 23:01 mrkam2

Sure, I'm open to this. Could you be a bit more specific, though? How would the configuration work? Right now there's an optional namespace qualifier; how would that work if we gave a regex instead of a string?

Another option might be to be a bit more restrictive and instead of allowing arbitrary regular expressions, allow for matching certain prefixes. I think that covers all the existing use cases. It also covers the built-in indentation rules that cljfmt uses -- certain special prefixes (def, let, send-, and so on) get IndentListBody rather than IndentList.

Perhaps after we add this generalization, we could change the way the default indents work to being a default cljfmt config file rather than being hardcoded.

cespare avatar Jan 21 '21 00:01 cespare