weavejester / cljfmt

A tool for formatting Clojure code
Eclipse Public License 1.0
1.11k stars 119 forks source link

Support multiple config.edn files #336

Open juszczakn opened 8 months ago

juszczakn commented 8 months ago

It's possible I'm just missing this and it's already possible, but it seems like cljfmt currently doesn't support a way to split up the config across multiple files?

clj-kondo supports projects exporting their own configs, such that downstream projects can import and make use of them. This sort of feature seems like it would be super helpful in cljfmt as well!

For example, a utility library that defines a common macro used by lots of projects could specify a cljfmt.edn, and downstream projects could choose to import and merge that config into their own root config in some way.

It wouldn't even necessarily have to be as complicated as what clj-kondo has, simply being able to specify other config files in your root config file, and having all the configs deep-merged into one seems like it would be a useful first step to me.

Something like being to specify this in your config.edn:

{:additional-configs ["../other-project/.cljfmt.edn"]}
weavejester commented 8 months ago

I don't believe there's any support for this currently. Allowing cljfmt to find config files on the classpath would be useful functionality. An :extra-configs or :include-configs key might also be useful.

juszczakn commented 8 months ago

@weavejester just made #337 as a quick poc, I have no idea if it's even correct, but something like that as the basic idea?

juszczakn commented 8 months ago

@weavejester I updated the poc, I think it's at a state where it might be worthy of an initial code review, although it's still a little rough maybe