E.g: When formatting foo.cpp it will look for .cpp.clang-format
This makes it easy to different formatting for .c/.h files and
.cpp/.hpp files within the same directories.
wanders on Oct 7 2019, 4:10 AM.Authored by
Thanks for the patch, I think I understand what you are trying to do, but I have a few questions.
Is the premise here that you need slightly different styles for .cpp than for .h? could you explain why?
whilst I can see there is value in having such fine control, could you explain a little what leads you to needing that? because it feels like you are almost saying a bug in clang-format prevents me from using a single file and I'd like to understand if that is the case?
The "Language" option can not distinguish between C and C++.
We have projects which contains both C and C++ code. Using different style (yes..) for C and C++. Our C++ headers are named hpp.
In our toplevel we have the following symlinks
Before this we had a horrible wrapper script that used cd into different directories depending on extension, and those directories had different .clang-format files, and then had to run clang-format from stdin.
An alternative implementation I did consider was to add some kind of path matching in the configuration file doing multiple yaml documents in the configuration file. So in my case it would be something like:
--- Language: Cpp IndentWidth: 4 TabWidth: 4 MoreStuff... --- PathMatch: [ *.cpp, *.hpp ] SpaceBeforeParen: ControlStatements --- PathMatch [ *.c, *.h ] SpaceBeforeParen: Never ---