Skip to content

Commit 2afa200

Browse files
committed
Add clang-format configuration
1 parent a268782 commit 2afa200

File tree

2 files changed

+200
-0
lines changed

2 files changed

+200
-0
lines changed

.clang-format

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
Language: Cpp
2+
IndentWidth: 2
3+
UseTab: Never
4+
ColumnLimit: 120
5+
SortIncludes: false
6+
AccessModifierOffset: -2
7+
ReflowComments: false
8+
ConstructorInitializerIndentWidth: 2
9+
ContinuationIndentWidth: 2
10+
AllowShortFunctionsOnASingleLine: None
11+
BreakBeforeBraces: Custom
12+
BraceWrapping:
13+
AfterExternBlock: true
14+
AfterClass: true
15+
AfterFunction: true
16+
AfterNamespace: false
17+
AfterEnum: false
18+
AfterCaseLabel: false
19+
AfterControlStatement: Never
20+
AfterStruct: false
21+
AfterUnion: false
22+
BeforeLambdaBody: false
23+
BeforeElse: false
24+
BeforeCatch: false
25+
BeforeWhile: false
26+
IndentBraces: false
27+
SplitEmptyFunction: true
28+
SplitEmptyRecord: false
29+
SplitEmptyNamespace: true
30+
PPIndentWidth: 2
31+
FixNamespaceComments: false
32+
# ??????
33+
IndentPPDirectives: BeforeHash
34+
SpaceBeforeParens: Custom
35+
SpaceBeforeParensOptions:
36+
AfterControlStatements: true
37+
AfterForeachMacros: true
38+
AfterFunctionDefinitionName: false
39+
AfterFunctionDeclarationName: false
40+
AfterIfMacros: true
41+
AfterOverloadedOperator: false
42+
AfterRequiresInClause: false
43+
AfterRequiresInExpression: false
44+
BeforeNonEmptyParentheses: false
45+
SpaceAfterCStyleCast: false
46+
SpaceAfterLogicalNot: false
47+
SpaceAfterTemplateKeyword: false
48+
SpaceAroundPointerQualifiers: Default
49+
SpaceBeforeAssignmentOperators: true
50+
SpaceBeforeCaseColon: false
51+
SpaceBeforeCpp11BracedList: true
52+
SpaceBeforeCtorInitializerColon: true
53+
SpaceBeforeInheritanceColon: true
54+
SpaceBeforeRangeBasedForLoopColon: true
55+
SpaceBeforeSquareBrackets: false
56+
SpaceInEmptyBlock: false
57+
SpaceInEmptyParentheses: false
58+
# ??
59+
#SpacesBeforeTrailingComments: -1
60+
SpacesInAngles: Never
61+
SpacesInConditionalStatement: false
62+
SpacesInContainerLiterals: true
63+
SpacesInCStyleCastParentheses: false
64+
SpacesInLineCommentPrefix:
65+
Minimum: 1
66+
Maximum: -1
67+
IndentCaseBlocks: false
68+
IndentCaseLabels: false
69+
AlignAfterOpenBracket: DontAlign
70+
BreakConstructorInitializers: BeforeComma
71+
AlwaysBreakTemplateDeclarations: true
72+
NamespaceIndentation: None
73+
AlignArrayOfStructures: None
74+
AlignConsecutiveAssignments:
75+
Enabled: false
76+
AcrossEmptyLines: false
77+
AcrossComments: false
78+
AlignCompound: false
79+
PadOperators: false
80+
AlignConsecutiveBitFields:
81+
Enabled: false
82+
AcrossEmptyLines: false
83+
AcrossComments: false
84+
AlignCompound: false
85+
PadOperators: false
86+
AlignConsecutiveDeclarations:
87+
Enabled: false
88+
AcrossEmptyLines: false
89+
AcrossComments: false
90+
AlignCompound: false
91+
PadOperators: false
92+
AlignConsecutiveMacros:
93+
Enabled: false
94+
AcrossEmptyLines: true
95+
AcrossComments: false
96+
AlignCompound: false
97+
PadOperators: false
98+
AlignEscapedNewlines: DontAlign
99+
AlignOperands: Align
100+
AlignTrailingComments: false
101+
# ??
102+
AllowAllArgumentsOnNextLine: false
103+
AllowAllParametersOfDeclarationOnNextLine: true
104+
AllowShortBlocksOnASingleLine: Empty
105+
AllowShortCaseLabelsOnASingleLine: false
106+
AllowShortEnumsOnASingleLine: true
107+
# AllowShortIfStatementsOnASingleLine: Nevers
108+
AllowShortLambdasOnASingleLine: All
109+
AllowShortLoopsOnASingleLine: false
110+
AlwaysBreakAfterDefinitionReturnType: None
111+
AlwaysBreakAfterReturnType: None
112+
AlwaysBreakBeforeMultilineStrings: false
113+
BinPackArguments: true
114+
BinPackParameters: true
115+
BitFieldColonSpacing: After
116+
BreakBeforeBinaryOperators: NonAssignment
117+
BreakBeforeConceptDeclarations: Always
118+
BreakBeforeTernaryOperators: true
119+
BreakInheritanceList: BeforeColon
120+
BreakStringLiterals: true
121+
CompactNamespaces: false
122+
Cpp11BracedListStyle: true
123+
PointerAlignment: Right
124+
QualifierAlignment: Leave
125+
ReferenceAlignment: Pointer
126+
DerivePointerAlignment: false
127+
DisableFormat: false
128+
EmptyLineAfterAccessModifier: Leave
129+
MaxEmptyLinesToKeep: 1
130+
EmptyLineBeforeAccessModifier: LogicalBlock
131+
ExperimentalAutoDetectBinPacking: false
132+
Macros:
133+
- >-
134+
PyObject_HEAD_INIT(type)={
135+
{ 0xFFFFFFFF },
136+
(type)
137+
},
138+
- >-
139+
PyVarObject_HEAD_INIT(type, size)={
140+
{
141+
{ 0xFFFFFFFF },
142+
(type)
143+
},
144+
(size)
145+
},
146+
ForEachMacros:
147+
- foreach
148+
- Q_FOREACH
149+
StatementAttributeLikeMacros:
150+
- Q_EMIT
151+
StatementMacros:
152+
- Q_UNUSED
153+
- QT_REQUIRE_VERSION
154+
- Q_OBJECT
155+
- PyObject_HEAD
156+
IndentAccessModifiers: false
157+
IndentExternBlock: AfterExternBlock
158+
IndentGotoLabels: true
159+
IndentRequiresClause: true
160+
IndentWrappedFunctionNames: false
161+
InsertBraces: false
162+
InsertTrailingCommas: None
163+
KeepEmptyLinesAtTheStartOfBlocks: true
164+
# ???
165+
LambdaBodyIndentation: OuterScope
166+
PackConstructorInitializers: BinPack
167+
RemoveBracesLLVM: false
168+
RequiresClausePosition: OwnLine
169+
SeparateDefinitionBlocks: Leave
170+
ShortNamespaceLines: 1
171+
SortUsingDeclarations: false
172+
SpacesInParentheses: false
173+
SpacesInSquareBrackets: false
174+
Standard: Latest

run-clang-format.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -xeuo pipefail
3+
which -a clang-format-20 > /dev/null \
4+
|| (echo -e "20.0.0\n$(clang-format${1+-$1} --version | grep -Eo '([0-9]+\.[0-9]+\.[0-9]+)')" | sort -CV ) \
5+
|| { echo "use '${0} <clang-format-version-not-less-than-20>' to call exact proper version" ; exit 1 ; }
6+
7+
IGNORED_DIRS=(
8+
"./generated_cpp_50"
9+
"./generated_cpp_511"
10+
"./generated_cpp_515"
11+
"./generated_cpp_53"
12+
"./generated_cpp_54"
13+
"./generated_cpp_56"
14+
"./examples"
15+
"./build"
16+
)
17+
18+
IGNORE_CMD=""
19+
20+
for DIR in "${IGNORED_DIRS[@]}"; do
21+
IGNORE_CMD+=" -path $DIR -o"
22+
done
23+
24+
IGNORE_CMD=${IGNORE_CMD% -o}
25+
26+
find . \( $IGNORE_CMD \) -prune -o -name '*.cpp' -print0 -o -name '*.h' -print0 | xargs -0 clang-format-20 --style=file -i

0 commit comments

Comments
 (0)