-
Notifications
You must be signed in to change notification settings - Fork 3
/
.clang-format
177 lines (135 loc) · 5.32 KB
/
.clang-format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#===========================================================================#
# Language (C/C++) #
#===========================================================================#
Language: Cpp
#===========================================================================#
# Column limit and wrapping rules #
#===========================================================================#
# Maximum columns count
ColumnLimit: 120
# Column limit wrapping for comments
ReflowComments: true
# Prevent alignment of wrapped names to avoid misplaced spaces
AlignAfterOpenBracket: DontAlign
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
IndentWrappedFunctionNames: false
BinPackArguments: true
BinPackParameters: true
AlignOperands: false
# Brace wrapping
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterStruct: false
AfterUnion: false
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
# Don't break after return type
AlwaysBreakAfterReturnType: None
#===========================================================================#
# Indentation and spaces #
#===========================================================================#
# Rules: #
# + L2 #
# + L3 #
# + G3 #
#--------#
# Indent width and indent character
TabWidth: 4
IndentWidth: 4
ContinuationIndentWidth: 4
UseTab: Never
# Preprocessor
IndentPPDirectives: BeforeHash
# Declarations and assignments
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
# Disable spaces after '{' and before '}' in lists
Cpp11BracedListStyle: true
# Place '*' and '&' next to the name of the variable
PointerAlignment: Right
# Space after a cast, but not in its parentheses
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
# Space after logical not '!' (it's an unary operator)
SpaceAfterLogicalNot: false
# Space before assignment operators '=', '+=', '|=', etc...
SpaceBeforeAssignmentOperators: true
# Space before control statement parentheses, but not function parentheses
SpaceBeforeParens: ControlStatements
# No space in empty blocks '{}' or parentheses '()'
# SpaceInEmptyBlock: false <- This one isn't compatible with my clang-format version
SpaceInEmptyParentheses: false
# No space between angles '<>'
SpacesInAngles: false
# No space in parentheses -- after '(' and before ')'
SpacesInParentheses: false
# No space inb square brackets -- after '[' and before ']'
SpacesInSquareBrackets: false
# No space in container literals
# var a = [1, 2, 3] (<- betweebn square brackets and values)
# f({a: 1, b: 2, c: 3}) (<- before ':' caracter)
SpacesInContainerLiterals: false
# Space after "template" keyword
SpaceAfterTemplateKeyword: true
# Cases in a switch statement
IndentCaseLabels: true
# Nested namespace indentation
NamespaceIndentation: All
#===========================================================================#
# Layout inside a function's scope #
#===========================================================================#
# Enable one-line bracketted code
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
# ... but disallow one line loops
AllowShortLoopsOnASingleLine: false
# Except for while/for to allow counters like `while (++i < condition) {}`
AllowShortBlocksOnASingleLine: Empty
# A simple case case be written `case X: do_something(); break;`
AllowShortCaseLabelsOnASingleLine: true
# Remove empty line in blocks
KeepEmptyLinesAtTheStartOfBlocks: false
#===========================================================================#
# Global scope #
#===========================================================================#
# Max empty lines to keep
MaxEmptyLinesToKeep: 1
#===========================================================================#
# Readability improvements and extras #
#===========================================================================#
# Make macro declarations more eligible. Those won't trigger misplaced spaces.
AlignConsecutiveMacros: true
# Align backslashes when escaping linebreaks
AlignEscapedNewlines: Left
# Align trailing comments (//)
AlignTrailingComments: true
# Allow breaking string litterals when wrapping
BreakStringLiterals: true
# When wrapping, keep '=' on the top right, but put operators on the new line
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
# Include sorting and priority - lowest priority gets sorted at the bottom of the list
SortIncludes: true
IncludeBlocks: Preserve
IncludeCategories:
IncludeCategories:
- Regex: '^"[[:alnum:]./]+"' # Any "my_header.h"
Priority: 3
- Regex: '<criterion/[a-z]+\.h>' # Criterion headers
Priority: 2
- Regex: '<[[:alnum:]./]+>' # System/Standard libs
Priority: 1
# Sort 'using' declarations
SortUsingDeclarations: true