I've been using clang format to help keep my code clean. For multiline function calls, is there any way to get clang to put the cloning parenthesis on it's own line?
Example:
What it's doing now:
increment_and_call_on_match(
clique_colors,
0,
max_clique_color,
[&](int clique_color) {
comms.emplace_back(context.split_by_color(clique_color));
},
[&](int) { context.split_by_color(); });
What I want:
increment_and_call_on_match(
clique_colors,
0,
max_clique_color,
[&](int clique_color) {
comms.emplace_back(context.split_by_color(clique_color));
},
[&](int) { context.split_by_color(); }
); //Closing paren on new line
Short answer: YES. The clang-format tool has a -sort-includes option. Changing the order of #include directives can definitely change the behavior of existing code, and may break existing code.
You can install clang-format and git-clang-format via npm install -g clang-format . To automatically format a file according to Electron C++ code style, run clang-format -i path/to/electron/file.cc . It should work on macOS/Linux/Windows.
Clang-Format is a widely-used C++ code formatter. As it provides an option to define code style options in YAML-formatted files — named . clang-format or _clang-format — these files often become a part of your project where you keep all code style rules.
clang-format file, we need to place it in the project folder or in any parent folder of the file you want to format. clang-format.exe searches for the config file automatically starting with the folder where the file you want to format is located, all the way to the topmost directory.
A new option AlignAfterOpenBracket: BlockIndent
was added 2022-01-17 in the approved code review https://reviews.llvm.org/D109557, which is in LLVM 14.0.0-rc1 or later.
(I too want this, as we have thousands of lines of code which use this style, and clang-format supporting this would get me to adopt clang format in Visual Studio - https://developercommunity.visualstudio.com/content/problem/232465/clang-format-messes-with-closing-parentheses-in-fu.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With