[cfe-dev] Clang-format configuration files
Kim Gräsman
kim.grasman at gmail.com
Mon May 6 13:27:04 PDT 2013
Hi Alexander,
When I did external config for IWYU, I added an #include mechanism to allow
configurations composed from different files. In our case it was to
support per-library configurations, which is probably not useful for
clang-format. However, it might be nice for you to allow "use the Google
style, but..." in the form of a base file and local overrides. E.g.
# start from Google style
BasedOn: google.clang-format
# local adjustments
ColumnLimit: 120
...
FWIW,
- Kim
On Monday, May 6, 2013, Alexander Kornienko wrote:
> It's time for clang-format to support more flexible style configuration.
> We're starting to work on configuration files support for clang-format.
>
> Some thoughts on desired features and overall design:
>
> - *contents*: fields of the FormatStyle struct, which currently has <
> 20 fields of primitive types;
> - *format*: a set of key-value pairs, most probably JSON or YAML with
> flat structure, e.g.:
> ColumnLimit: 80
> ConstructorInitializerAllOnOneLineOrOnePerLine: true
> ...
> - *file location*: 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:
> dir:
> .clang-format
> a.cpp
> subdir:
> .clang-format
> b.cpp
>
> *clang-format dir/a.cpp* should read only dir/.clang-format (assuming
> that there are no .clang-format files in parent directories), *clang-format
> dir/subdir/b.cpp* should use configuration values from
> dir/subdir/.clang-format, and for the values not defined there try to
> get them from dir/.clang-format
> - *command-line interface*: there's currently -style option which
> takes a name of a predefined style, we can use "-style config" or "-style
> file" to turn on configuration file parsing, or turn it on by default.
>
> Any comments/suggestions?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130506/60b40333/attachment.html>
More information about the cfe-dev
mailing list