Skip to content

Commit d936cc2

Browse files
committed
Add clang-format as pre-commit hook
The format is the same as precice/precice
1 parent 9415e0e commit d936cc2

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

.clang-format

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: true
6+
AlignConsecutiveDeclarations: true
7+
AlignEscapedNewlines: Right
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: Empty
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: MultiLine
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BraceWrapping:
23+
AfterClass: false
24+
AfterControlStatement: false
25+
AfterEnum: false
26+
AfterFunction: true
27+
AfterNamespace: false
28+
AfterObjCDeclaration: false
29+
AfterStruct: false
30+
AfterUnion: false
31+
AfterExternBlock: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
SplitEmptyFunction: true
36+
SplitEmptyRecord: true
37+
SplitEmptyNamespace: true
38+
BreakBeforeBinaryOperators: None
39+
BreakBeforeBraces: Custom
40+
BreakBeforeInheritanceComma: false
41+
BreakInheritanceList: BeforeColon
42+
BreakBeforeTernaryOperators: true
43+
BreakConstructorInitializersBeforeComma: false
44+
BreakConstructorInitializers: BeforeColon
45+
BreakAfterJavaFieldAnnotations: false
46+
BreakStringLiterals: true
47+
ColumnLimit: 0
48+
CommentPragmas: '^ IWYU pragma:'
49+
CompactNamespaces: false
50+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
51+
ConstructorInitializerIndentWidth: 4
52+
ContinuationIndentWidth: 4
53+
Cpp11BracedListStyle: true
54+
DerivePointerAlignment: false
55+
DisableFormat: false
56+
ExperimentalAutoDetectBinPacking: false
57+
FixNamespaceComments: true
58+
ForEachMacros:
59+
- foreach
60+
- Q_FOREACH
61+
- BOOST_FOREACH
62+
IncludeBlocks: Preserve
63+
IncludeCategories:
64+
- Regex: '^(<|"(gtest|isl|json)/)'
65+
Priority: 1
66+
- Regex: '.*'
67+
Priority: 2
68+
- Regex: '.*'
69+
Priority: 1
70+
IncludeIsMainRegex: '$'
71+
IndentCaseLabels: false
72+
IndentPPDirectives: None
73+
IndentWidth: 2
74+
IndentWrappedFunctionNames: false
75+
JavaScriptQuotes: Leave
76+
JavaScriptWrapImports: true
77+
KeepEmptyLinesAtTheStartOfBlocks: true
78+
MacroBlockBegin: ''
79+
MacroBlockEnd: ''
80+
MaxEmptyLinesToKeep: 1
81+
NamespaceIndentation: None
82+
ObjCBinPackProtocolList: Auto
83+
ObjCBlockIndentWidth: 2
84+
ObjCSpaceAfterProperty: false
85+
ObjCSpaceBeforeProtocolList: true
86+
PenaltyBreakAssignment: 2
87+
PenaltyBreakBeforeFirstCallParameter: 19
88+
PenaltyBreakComment: 300
89+
PenaltyBreakFirstLessLess: 120
90+
PenaltyBreakString: 1000
91+
PenaltyBreakTemplateDeclaration: 10
92+
PenaltyExcessCharacter: 1000000
93+
PenaltyReturnTypeOnItsOwnLine: 100
94+
PointerAlignment: Right
95+
ReflowComments: true
96+
SortIncludes: true
97+
SortUsingDeclarations: true
98+
SpaceAfterCStyleCast: true
99+
SpaceAfterTemplateKeyword: true
100+
SpaceBeforeAssignmentOperators: true
101+
SpaceBeforeCpp11BracedList: false
102+
SpaceBeforeCtorInitializerColon: true
103+
SpaceBeforeInheritanceColon: true
104+
SpaceBeforeParens: ControlStatements
105+
SpaceBeforeRangeBasedForLoopColon: true
106+
SpaceInEmptyParentheses: false
107+
SpacesBeforeTrailingComments: 1
108+
SpacesInAngles: false
109+
SpacesInContainerLiterals: true
110+
SpacesInCStyleCastParentheses: false
111+
SpacesInParentheses: false
112+
SpacesInSquareBrackets: false
113+
Standard: Cpp11
114+
StatementMacros:
115+
- Q_UNUSED
116+
- QT_REQUIRE_VERSION
117+
TabWidth: 2
118+
UseTab: Never
119+
...

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ repos:
1616
hooks:
1717
- id: autopep8
1818
args: [ --in-place, --exit-code, --aggressive, --ignore=E402, --max-line-length=120 ]
19+
- repo: https://github.com/pre-commit/mirrors-clang-format
20+
rev: 'v8.0.1'
21+
hooks:
22+
- id: clang-format

0 commit comments

Comments
 (0)