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