git
/
.clang-format
221 строка · 5.9 Кб
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.
6
7# Use tabs whenever we need to fill whitespace that spans at least from one tab
8# stop to the next one.
9#
10# These settings are mirrored in .editorconfig. Keep them in sync.
11UseTab: Always12TabWidth: 813IndentWidth: 814ContinuationIndentWidth: 815ColumnLimit: 8016
17# C Language specifics
18Language: Cpp19
20# Align parameters on the open bracket
21# someLongFunction(argument1,
22# argument2);
23AlignAfterOpenBracket: Align24
25# Don't align consecutive assignments
26# int aaaa = 12;
27# int b = 14;
28AlignConsecutiveAssignments: false29
30# Don't align consecutive declarations
31# int aaaa = 12;
32# double b = 3.14;
33AlignConsecutiveDeclarations: false34
35# Align escaped newlines as far left as possible
36# #define A \
37# int aaaa; \
38# int b; \
39# int cccccccc;
40AlignEscapedNewlines: Left41
42# Align operands of binary and ternary expressions
43# int aaa = bbbbbbbbbbb +
44# cccccc;
45AlignOperands: true46
47# Don't align trailing comments
48# int a; // Comment a
49# int b = 2; // Comment b
50AlignTrailingComments: false51
52# By default don't allow putting parameters onto the next line
53# myFunction(foo, bar, baz);
54AllowAllParametersOfDeclarationOnNextLine: false55
56# Don't allow short braced statements to be on a single line
57# if (a) not if (a) return;
58# return;
59AllowShortBlocksOnASingleLine: false60AllowShortCaseLabelsOnASingleLine: false61AllowShortFunctionsOnASingleLine: false62AllowShortIfStatementsOnASingleLine: false63AllowShortLoopsOnASingleLine: false64
65# By default don't add a line break after the return type of top-level functions
66# int foo();
67AlwaysBreakAfterReturnType: None68
69# Pack as many parameters or arguments onto the same line as possible
70# int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
71# int cccc);
72BinPackArguments: true73BinPackParameters: true74
75# Add no space around the bit field
76# unsigned bf:2;
77BitFieldColonSpacing: None78
79# Attach braces to surrounding context except break before braces on function
80# definitions.
81# void foo()
82# {
83# if (true) {
84# } else {
85# }
86# };
87BreakBeforeBraces: Linux88
89# Break after operators
90# int value = aaaaaaaaaaaaa +
91# bbbbbb -
92# ccccccccccc;
93BreakBeforeBinaryOperators: None94BreakBeforeTernaryOperators: false95
96# Don't break string literals
97BreakStringLiterals: false98
99# Use the same indentation level as for the switch statement.
100# Switch statement body is always indented one level more than case labels.
101IndentCaseLabels: false102
103# Indents directives before the hash. Each level uses a single space for
104# indentation.
105# #if FOO
106# # include <foo>
107# #endif
108IndentPPDirectives: AfterHash109PPIndentWidth: 1110
111# Don't indent a function definition or declaration if it is wrapped after the
112# type
113IndentWrappedFunctionNames: false114
115# Align pointer to the right
116# int *a;
117PointerAlignment: Right118
119# Don't insert a space after a cast
120# x = (int32)y; not x = (int32) y;
121SpaceAfterCStyleCast: false122
123# No space is inserted after the logical not operator
124SpaceAfterLogicalNot: false125
126# Insert spaces before and after assignment operators
127# int a = 5; not int a=5;
128# a += 42; a+=42;
129SpaceBeforeAssignmentOperators: true130
131# Spaces will be removed before case colon.
132# case 1: break; not case 1 : break;
133SpaceBeforeCaseColon: false134
135# Put a space before opening parentheses only after control statement keywords.
136# void f() {
137# if (true) {
138# f();
139# }
140# }
141SpaceBeforeParens: ControlStatements142
143# Don't insert spaces inside empty '()'
144SpaceInEmptyParentheses: false145
146# No space before first '[' in arrays
147# int a[5][5]; not int a [5][5];
148SpaceBeforeSquareBrackets: false149
150# No space will be inserted into {}
151# while (true) {} not while (true) { }
152SpaceInEmptyBlock: false153
154# The number of spaces before trailing line comments (// - comments).
155# This does not affect trailing block comments (/* - comments).
156SpacesBeforeTrailingComments: 1157
158# Don't insert spaces in casts
159# x = (int32) y; not x = ( int32 ) y;
160SpacesInCStyleCastParentheses: false161
162# Don't insert spaces inside container literals
163# var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
164SpacesInContainerLiterals: false165
166# Don't insert spaces after '(' or before ')'
167# f(arg); not f( arg );
168SpacesInParentheses: false169
170# Don't insert spaces after '[' or before ']'
171# int a[5]; not int a[ 5 ];
172SpacesInSquareBrackets: false173
174# Insert a space after '{' and before '}' in struct initializers
175Cpp11BracedListStyle: false176
177# A list of macros that should be interpreted as foreach loops instead of as
178# function calls. Taken from:
179# git grep -h '^#define [^[:space:]]*for_\?each[^[:space:]]*(' |
180# sed "s/^#define / - '/; s/(.*$/'/" | sort | uniq
181ForEachMacros:182- 'for_each_builtin'183- 'for_each_string_list_item'184- 'for_each_ut'185- 'for_each_wanted_builtin'186- 'hashmap_for_each_entry'187- 'hashmap_for_each_entry_from'188- 'kh_foreach'189- 'kh_foreach_value'190- 'list_for_each'191- 'list_for_each_dir'192- 'list_for_each_prev'193- 'list_for_each_prev_safe'194- 'list_for_each_safe'195- 'strintmap_for_each_entry'196- 'strmap_for_each_entry'197- 'strset_for_each_entry'198
199# A list of macros that should be interpreted as conditionals instead of as
200# function calls.
201IfMacros:202- 'if_test'203
204# The maximum number of consecutive empty lines to keep.
205MaxEmptyLinesToKeep: 1206
207# No empty line at the start of a block.
208KeepEmptyLinesAtTheStartOfBlocks: false209
210# Penalties
211# This decides what order things should be done if a line is too long
212PenaltyBreakAssignment: 10213PenaltyBreakBeforeFirstCallParameter: 30214PenaltyBreakComment: 10215PenaltyBreakFirstLessLess: 0216PenaltyBreakString: 10217PenaltyExcessCharacter: 100218PenaltyReturnTypeOnItsOwnLine: 60219
220# Don't sort #include's
221SortIncludes: false222