[gimp] clang-format: improve according to our coding style.



commit 3d97a408ea74e0015cf86331b9c8f1a079b9ff3e
Author: Jehan <jehan girinstud io>
Date:   Wed Jan 19 23:17:23 2022 +0100

    clang-format: improve according to our coding style.
    
    - Align macro values.
    - Align backslashes to escape newlines.
    - Added explicit PointerAlignment though this one seems unneeded.
    - Increase the column limit (even though 80 is really the official one)
      and add some penalty on breaking on very unexpected places, such as
      around assignments or on first parameters in calls/declaration. We
      want short lines but this is more of a soft rule which should not
      override sensible line breaking rules.
    - Group some rules and reorder rule names alphabetically within groups.

 .clang-format | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/.clang-format b/.clang-format
index 882aabe19d..3cf5fde832 100644
--- a/.clang-format
+++ b/.clang-format
@@ -6,12 +6,33 @@
 ---
 
 AlignAfterOpenBracket: Align
+AlignArrayOfStructures: Left
 AlignConsecutiveAssignments: Consecutive
 AlignConsecutiveDeclarations: Consecutive
-AlignArrayOfStructures: Left
+AlignConsecutiveMacros: Consecutive
+AlignEscapedNewlines: Left
+
 AlwaysBreakAfterReturnType: AllDefinitions
-UseTab: Never
+BreakBeforeBraces: GNU
 IndentWidth: 2
 SpaceBeforeParens: Always
-BreakBeforeBraces: GNU
-ColumnLimit: 80
\ No newline at end of file
+PointerAlignment: Right
+UseTab: Never
+
+# Our column limit is more around 80 characters but we want to avoid
+# this rule to be over-agressive. So for clang-format, let's use a
+# higher limit. Then let's put some biggish penalties on breaking on
+# assignment, or parentheses, or other similar cases. Actually with such
+# limits, if clang-format really ends up re-formatting, there might be
+# something better to do code-wise (i.e. we might be in an akwardly
+# over-nested block case).
+ColumnLimit: 100
+PenaltyBreakAssignment: 40
+PenaltyBreakBeforeFirstCallParameter: 40
+# Uncomment this when we start using clang-format 14 in the CI.
+# PenaltyBreakOpenParenthesis: 40
+PenaltyExcessCharacter: 1
+# Strings are more often longer by usage, so let's give these slightly
+# more space to breath.
+PenaltyBreakString: 60
+PenaltyReturnTypeOnItsOwnLine: 50


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]