run-clang-format icon indicating copy to clipboard operation
run-clang-format copied to clipboard

Support --style=file:<path/to/file> for older versions of clang-format

Open luator opened this issue 2 years ago • 0 comments

Allows using a .clang-format file from an arbitrary location (i.e. does not need to be in the project directory or parent).

This is done by loading the file and passing the config to clang-format as a YAML string, i.e. like this:

clang-format file.cpp --style "{BasedOnStyle: Google, IndentWidth: '4', ...}"

Adds conditional dependency on the yaml package for reading the file.

Note that starting from version 14, clang-format supports specifying a file like this on its own. So if you are interested in merging this change, it would probably make sense to extend it a bit to check the version and only load the config like this for versions <14.

luator avatar Feb 28 '22 09:02 luator