Stephan Beyer | 1bf0259 | 2017-10-02 08:37:14 +0900 | [diff] [blame] | 1 | # This file is an example configuration for clang-format 5.0. |
| 2 | # |
| 3 | # Note that this style definition should only be understood as a hint |
| 4 | # for writing new code. The rules are still work-in-progress and does |
| 5 | # not yet exactly match the style we have in the existing code. |
Brandon Williams | 6134de6 | 2017-08-14 14:30:45 -0700 | [diff] [blame] | 6 | |
| 7 | # Use tabs whenever we need to fill whitespace that spans at least from one tab |
| 8 | # stop to the next one. |
| 9 | UseTab: Always |
| 10 | TabWidth: 8 |
| 11 | IndentWidth: 8 |
| 12 | ContinuationIndentWidth: 8 |
| 13 | ColumnLimit: 80 |
| 14 | |
| 15 | # C Language specifics |
| 16 | Language: Cpp |
| 17 | |
| 18 | # Align parameters on the open bracket |
| 19 | # someLongFunction(argument1, |
| 20 | # argument2); |
| 21 | AlignAfterOpenBracket: Align |
| 22 | |
| 23 | # Don't align consecutive assignments |
| 24 | # int aaaa = 12; |
| 25 | # int b = 14; |
| 26 | AlignConsecutiveAssignments: false |
| 27 | |
| 28 | # Don't align consecutive declarations |
| 29 | # int aaaa = 12; |
| 30 | # double b = 3.14; |
| 31 | AlignConsecutiveDeclarations: false |
| 32 | |
| 33 | # Align escaped newlines as far left as possible |
| 34 | # #define A \ |
| 35 | # int aaaa; \ |
| 36 | # int b; \ |
| 37 | # int cccccccc; |
| 38 | AlignEscapedNewlines: Left |
| 39 | |
| 40 | # Align operands of binary and ternary expressions |
| 41 | # int aaa = bbbbbbbbbbb + |
| 42 | # cccccc; |
| 43 | AlignOperands: true |
| 44 | |
| 45 | # Don't align trailing comments |
| 46 | # int a; // Comment a |
| 47 | # int b = 2; // Comment b |
| 48 | AlignTrailingComments: false |
| 49 | |
| 50 | # By default don't allow putting parameters onto the next line |
| 51 | # myFunction(foo, bar, baz); |
| 52 | AllowAllParametersOfDeclarationOnNextLine: false |
| 53 | |
| 54 | # Don't allow short braced statements to be on a single line |
| 55 | # if (a) not if (a) return; |
| 56 | # return; |
| 57 | AllowShortBlocksOnASingleLine: false |
| 58 | AllowShortCaseLabelsOnASingleLine: false |
| 59 | AllowShortFunctionsOnASingleLine: false |
| 60 | AllowShortIfStatementsOnASingleLine: false |
| 61 | AllowShortLoopsOnASingleLine: false |
| 62 | |
| 63 | # By default don't add a line break after the return type of top-level functions |
| 64 | # int foo(); |
| 65 | AlwaysBreakAfterReturnType: None |
| 66 | |
| 67 | # Pack as many parameters or arguments onto the same line as possible |
| 68 | # int myFunction(int aaaaaaaaaaaa, int bbbbbbbb, |
| 69 | # int cccc); |
| 70 | BinPackArguments: true |
| 71 | BinPackParameters: true |
| 72 | |
| 73 | # Attach braces to surrounding context except break before braces on function |
| 74 | # definitions. |
| 75 | # void foo() |
| 76 | # { |
| 77 | # if (true) { |
| 78 | # } else { |
| 79 | # } |
| 80 | # }; |
| 81 | BreakBeforeBraces: Linux |
| 82 | |
| 83 | # Break after operators |
| 84 | # int valuve = aaaaaaaaaaaaa + |
| 85 | # bbbbbb - |
| 86 | # ccccccccccc; |
| 87 | BreakBeforeBinaryOperators: None |
| 88 | BreakBeforeTernaryOperators: false |
| 89 | |
| 90 | # Don't break string literals |
| 91 | BreakStringLiterals: false |
| 92 | |
| 93 | # Use the same indentation level as for the switch statement. |
| 94 | # Switch statement body is always indented one level more than case labels. |
| 95 | IndentCaseLabels: false |
| 96 | |
| 97 | # Don't indent a function definition or declaration if it is wrapped after the |
| 98 | # type |
| 99 | IndentWrappedFunctionNames: false |
| 100 | |
| 101 | # Align pointer to the right |
| 102 | # int *a; |
| 103 | PointerAlignment: Right |
| 104 | |
| 105 | # Don't insert a space after a cast |
| 106 | # x = (int32)y; not x = (int32) y; |
| 107 | SpaceAfterCStyleCast: false |
| 108 | |
| 109 | # Insert spaces before and after assignment operators |
| 110 | # int a = 5; not int a=5; |
| 111 | # a += 42; a+=42; |
| 112 | SpaceBeforeAssignmentOperators: true |
| 113 | |
| 114 | # Put a space before opening parentheses only after control statement keywords. |
| 115 | # void f() { |
| 116 | # if (true) { |
| 117 | # f(); |
| 118 | # } |
| 119 | # } |
| 120 | SpaceBeforeParens: ControlStatements |
| 121 | |
| 122 | # Don't insert spaces inside empty '()' |
| 123 | SpaceInEmptyParentheses: false |
| 124 | |
| 125 | # The number of spaces before trailing line comments (// - comments). |
| 126 | # This does not affect trailing block comments (/* - comments). |
| 127 | SpacesBeforeTrailingComments: 1 |
| 128 | |
| 129 | # Don't insert spaces in casts |
| 130 | # x = (int32) y; not x = ( int32 ) y; |
| 131 | SpacesInCStyleCastParentheses: false |
| 132 | |
| 133 | # Don't insert spaces inside container literals |
| 134 | # var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ]; |
| 135 | SpacesInContainerLiterals: false |
| 136 | |
| 137 | # Don't insert spaces after '(' or before ')' |
| 138 | # f(arg); not f( arg ); |
| 139 | SpacesInParentheses: false |
| 140 | |
| 141 | # Don't insert spaces after '[' or before ']' |
| 142 | # int a[5]; not int a[ 5 ]; |
| 143 | SpacesInSquareBrackets: false |
| 144 | |
| 145 | # Insert a space after '{' and before '}' in struct initializers |
| 146 | Cpp11BracedListStyle: false |
| 147 | |
| 148 | # A list of macros that should be interpreted as foreach loops instead of as |
| 149 | # function calls. |
| 150 | ForEachMacros: ['for_each_string_list_item'] |
| 151 | |
| 152 | # The maximum number of consecutive empty lines to keep. |
| 153 | MaxEmptyLinesToKeep: 1 |
| 154 | |
| 155 | # No empty line at the start of a block. |
| 156 | KeepEmptyLinesAtTheStartOfBlocks: false |
| 157 | |
| 158 | # Penalties |
| 159 | # This decides what order things should be done if a line is too long |
Johannes Schindelin | 42efde4 | 2017-09-29 20:26:44 +0200 | [diff] [blame] | 160 | PenaltyBreakAssignment: 10 |
| 161 | PenaltyBreakBeforeFirstCallParameter: 30 |
| 162 | PenaltyBreakComment: 10 |
Brandon Williams | 6134de6 | 2017-08-14 14:30:45 -0700 | [diff] [blame] | 163 | PenaltyBreakFirstLessLess: 0 |
Johannes Schindelin | 42efde4 | 2017-09-29 20:26:44 +0200 | [diff] [blame] | 164 | PenaltyBreakString: 10 |
| 165 | PenaltyExcessCharacter: 100 |
Patryk Obara | a3715d4 | 2018-01-24 12:11:54 +0100 | [diff] [blame] | 166 | PenaltyReturnTypeOnItsOwnLine: 60 |
Brandon Williams | 6134de6 | 2017-08-14 14:30:45 -0700 | [diff] [blame] | 167 | |
| 168 | # Don't sort #include's |
| 169 | SortIncludes: false |