Skip to content

Commit debb430

Browse files
henrikssnsalkinium
authored andcommitted
[tools] Add clang-format style
1 parent dc56af2 commit debb430

File tree

3 files changed

+178
-0
lines changed

3 files changed

+178
-0
lines changed

.clang-format

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
AccessModifierOffset: -4
2+
AlignAfterOpenBracket: Align
3+
AlignConsecutiveMacros: true
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlines: Left
7+
AlignOperands: true
8+
AlignTrailingComments: true
9+
AllowAllArgumentsOnNextLine: true
10+
AllowAllConstructorInitializersOnNextLine: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: true
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: Inline
15+
AllowShortLambdasOnASingleLine: All
16+
AllowShortIfStatementsOnASingleLine: WithoutElse
17+
AllowShortLoopsOnASingleLine: true
18+
AlwaysBreakAfterDefinitionReturnType: None
19+
AlwaysBreakAfterReturnType: All
20+
AlwaysBreakBeforeMultilineStrings: true
21+
AlwaysBreakTemplateDeclarations: Yes
22+
BinPackArguments: true
23+
BinPackParameters: true
24+
BraceWrapping:
25+
AfterCaseLabel: false
26+
AfterClass: true
27+
AfterControlStatement: true
28+
AfterEnum: true
29+
AfterFunction: true
30+
AfterNamespace: true
31+
AfterObjCDeclaration: false
32+
AfterStruct: true
33+
AfterUnion: false
34+
AfterExternBlock: false
35+
BeforeCatch: false
36+
BeforeElse: false
37+
IndentBraces: false
38+
SplitEmptyFunction: false
39+
SplitEmptyRecord: false
40+
SplitEmptyNamespace: false
41+
BreakBeforeBinaryOperators: None
42+
BreakBeforeBraces: Custom
43+
BreakBeforeInheritanceComma: false
44+
BreakInheritanceList: BeforeColon
45+
BreakBeforeTernaryOperators: true
46+
BreakConstructorInitializersBeforeComma: false
47+
BreakConstructorInitializers: BeforeColon
48+
BreakAfterJavaFieldAnnotations: false
49+
BreakStringLiterals: true
50+
ColumnLimit: 100
51+
CommentPragmas: '^ IWYU pragma:'
52+
CompactNamespaces: false
53+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
54+
ConstructorInitializerIndentWidth: 4
55+
ContinuationIndentWidth: 4
56+
Cpp11BracedListStyle: true
57+
DeriveLineEnding: true
58+
DerivePointerAlignment: true
59+
DisableFormat: false
60+
ExperimentalAutoDetectBinPacking: false
61+
FixNamespaceComments: true
62+
ForEachMacros:
63+
- foreach
64+
- Q_FOREACH
65+
- BOOST_FOREACH
66+
IncludeBlocks: Regroup
67+
IncludeCategories:
68+
- Regex: '^<ext/.*\.h>'
69+
Priority: 2
70+
SortPriority: 0
71+
- Regex: '^<.*\.h>'
72+
Priority: 1
73+
SortPriority: 0
74+
- Regex: '^<.*'
75+
Priority: 2
76+
SortPriority: 0
77+
- Regex: '.*'
78+
Priority: 3
79+
SortPriority: 0
80+
IncludeIsMainRegex: '([-_](test|unittest))?$'
81+
IncludeIsMainSourceRegex: ''
82+
IndentCaseLabels: true
83+
IndentGotoLabels: true
84+
IndentPPDirectives: None
85+
IndentWidth: 4
86+
IndentWrappedFunctionNames: false
87+
JavaScriptQuotes: Leave
88+
JavaScriptWrapImports: true
89+
KeepEmptyLinesAtTheStartOfBlocks: true
90+
MacroBlockBegin: ''
91+
MacroBlockEnd: ''
92+
MaxEmptyLinesToKeep: 1
93+
NamespaceIndentation: None
94+
ObjCBinPackProtocolList: Never
95+
ObjCBlockIndentWidth: 2
96+
ObjCSpaceAfterProperty: false
97+
ObjCSpaceBeforeProtocolList: true
98+
PenaltyBreakAssignment: 2
99+
PenaltyBreakBeforeFirstCallParameter: 1
100+
PenaltyBreakComment: 300
101+
PenaltyBreakFirstLessLess: 120
102+
PenaltyBreakString: 1000
103+
PenaltyBreakTemplateDeclaration: 10
104+
PenaltyExcessCharacter: 1000000
105+
PenaltyReturnTypeOnItsOwnLine: 200
106+
PointerAlignment: Right
107+
RawStringFormats:
108+
- Language: Cpp
109+
Delimiters:
110+
- cc
111+
- CC
112+
- cpp
113+
- Cpp
114+
- CPP
115+
- 'c++'
116+
- 'C++'
117+
CanonicalDelimiter: ''
118+
BasedOnStyle: google
119+
- Language: TextProto
120+
Delimiters:
121+
- pb
122+
- PB
123+
- proto
124+
- PROTO
125+
EnclosingFunctions:
126+
- EqualsProto
127+
- EquivToProto
128+
- PARSE_PARTIAL_TEXT_PROTO
129+
- PARSE_TEST_PROTO
130+
- PARSE_TEXT_PROTO
131+
- ParseTextOrDie
132+
- ParseTextProtoOrDie
133+
CanonicalDelimiter: ''
134+
BasedOnStyle: google
135+
ReflowComments: true
136+
SortIncludes: true
137+
SortUsingDeclarations: true
138+
SpaceAfterCStyleCast: false
139+
SpaceAfterLogicalNot: false
140+
SpaceAfterTemplateKeyword: false
141+
SpaceBeforeAssignmentOperators: true
142+
SpaceBeforeCpp11BracedList: false
143+
SpaceBeforeCtorInitializerColon: true
144+
SpaceBeforeInheritanceColon: true
145+
SpaceBeforeParens: ControlStatements
146+
SpaceBeforeRangeBasedForLoopColon: true
147+
SpaceInEmptyBlock: false
148+
SpaceInEmptyParentheses: false
149+
SpacesBeforeTrailingComments: 2
150+
SpacesInAngles: false
151+
SpacesInConditionalStatement: false
152+
SpacesInContainerLiterals: true
153+
SpacesInCStyleCastParentheses: false
154+
SpacesInParentheses: false
155+
SpacesInSquareBrackets: false
156+
SpaceBeforeSquareBrackets: false
157+
Standard: Cpp11
158+
StatementMacros:
159+
- Q_UNUSED
160+
- QT_REQUIRE_VERSION
161+
TabWidth: 4
162+
UseCRLF: false
163+
UseTab: ForContinuationAndIndentation

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ insert_final_newline = true
1111

1212
[*.md]
1313
trim_trailing_whitespace = false
14+
15+
[*.{lb,py}]
16+
indent_style = space
17+
indent_size = 4

tools/scripts/clang-format.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Copyright (c) 2020, Erik Henriksson
3+
#
4+
# This file is part of the modm project.
5+
#
6+
# This Source Code Form is subject to the terms of the Mozilla Public
7+
# License, v. 2.0. If a copy of the MPL was not distributed with this
8+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
#----------------------------------------------------------------------------
10+
11+
git diff --name-only --diff-filter=A -C -M develop | grep -e "\.\(c\|h\|hpp\|cpp\)\$" | xargs clang-format -i "$@"

0 commit comments

Comments
 (0)