<div dir="ltr">It's time for clang-format to support more flexible style configuration. We're starting to work on configuration files support for clang-format.<div><br><div>Some thoughts on desired features and overall design:<div>
<ul><li><b>contents</b>: fields of the FormatStyle struct, which currently has < 20 fields of primitive types;</li>
<li><b>format</b>: a set of key-value pairs, most probably JSON or YAML with flat structure, e.g.:<br>  ColumnLimit: 80<br>  ConstructorInitializerAllOnOneLineOrOnePerLine: true<br>  ...</li><li><b>file location</b>: in a longer term we'd like to support local per-project hierarchical model, so that style can be configured for a project and then partially or fully overridden in its various subprojects. E.g. for this directory structure:<br>
<font face="courier new, monospace">  dir:<br>    .clang-format<br>    a.cpp<br>    subdir:<br>      .clang-format<br>      b.cpp<br></font><br><font face="courier new, monospace"><b>clang-format dir/a.cpp</b></font> should read only <font face="courier new, monospace">dir/.clang-format</font> (assuming that there are no .clang-format files in parent directories), <font face="courier new, monospace"><b>clang-format dir/subdir/b.cpp</b></font> should use configuration values from <font face="courier new, monospace">dir/subdir/.clang-format</font>, and for the values not defined there try to get them from <font face="courier new, monospace">dir/.clang-format</font></li>
<li><font face="arial, helvetica, sans-serif"><b>command-line interface</b>: there's currently </font><font face="courier new, monospace">-style</font><font face="arial, helvetica, sans-serif"> option which takes a name of a predefined style, we can use "</font><font face="courier new, monospace">-style config</font><font face="arial, helvetica, sans-serif">" or "</font><font face="courier new, monospace">-style file</font><font face="arial, helvetica, sans-serif">" to turn on configuration file parsing, or turn it on by default.</font></li>
</ul><font face="arial, helvetica, sans-serif">Any comments/suggestions?</font></div></div></div></div>