cespare / goclj

Clojure parsing in Go
MIT License
37 stars 6 forks source link

Support regexp pattern matching in cljfmt.clj config file #79

Open mrkam2 opened 3 years ago

mrkam2 commented 3 years ago

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.

cespare commented 3 years ago

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.