RFC: clang-format option to include another configuration file

TL;DR: I would like to add support for an “include” syntax in _clang-format configuration files, allowing an arbitrary configuration file to be read and merged into the current configuration, without having to be located in an ancestor directory (nor named “_clang-format”).

My team is starting to adopt clang-format for formatting our (very large) C++ codebase. One maintenance issue we’ve identified is the existing behavior of reading _clang-format configuration files in ancestor directories, with “more local” configuration files overriding the “more global” ones. This isn’t flexible enough for my needs, as we have multiple, competing style conventions in different parts of our repo, and this does not map neatly onto our directory hierarchy.

Because of this situation, I’m currently stuck with the necessity of cloning my team’s specific style settings in about 6 different places in our repo, which makes me cry a little. Thus, I would like to add support for one _clang-format file to include another one, at an arbitrary path (and, ideally, expanding environment variables in the process).

Thoughts? Objections? Alternatives?

1 Like