@@ -147,189 +147,10 @@ function styleJson({
147
147
UseTab,
148
148
} : ClangFormatOptions ) : Record < string , unknown > {
149
149
// Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration
150
+ const defaultConfig = require ( './default-formatter-config.json' ) ; // 1. require the JSON
150
151
return {
151
- AccessModifierOffset : - 2 ,
152
- AlignAfterOpenBracket : 'Align' ,
153
- AlignArrayOfStructures : 'None' ,
154
- AlignConsecutiveAssignments : 'None' ,
155
- AlignConsecutiveBitFields : 'None' ,
156
- AlignConsecutiveDeclarations : 'None' ,
157
- AlignConsecutiveMacros : 'None' ,
158
- AlignEscapedNewlines : 'DontAlign' ,
159
- AlignOperands : 'Align' ,
160
- AlignTrailingComments : true ,
161
- AllowAllArgumentsOnNextLine : true ,
162
- AllowAllConstructorInitializersOnNextLine : true ,
163
- AllowAllParametersOfDeclarationOnNextLine : true ,
164
- AllowShortBlocksOnASingleLine : 'Always' ,
165
- AllowShortCaseLabelsOnASingleLine : true ,
166
- AllowShortEnumsOnASingleLine : true ,
167
- AllowShortFunctionsOnASingleLine : 'Empty' ,
168
- AllowShortIfStatementsOnASingleLine : 'AllIfsAndElse' ,
169
- AllowShortLambdasOnASingleLine : 'Empty' ,
170
- AllowShortLoopsOnASingleLine : true ,
171
- AlwaysBreakAfterDefinitionReturnType : 'None' ,
172
- AlwaysBreakAfterReturnType : 'None' ,
173
- AlwaysBreakBeforeMultilineStrings : false ,
174
- AlwaysBreakTemplateDeclarations : 'No' ,
175
- AttributeMacros : [ '__capability' ] ,
176
- BasedOnStyle : 'LLVM' ,
177
- BinPackArguments : true ,
178
- BinPackParameters : true ,
179
- BitFieldColonSpacing : 'Both' ,
180
- BraceWrapping : {
181
- AfterCaseLabel : false ,
182
- AfterClass : false ,
183
- AfterControlStatement : 'Never' ,
184
- AfterEnum : false ,
185
- AfterFunction : false ,
186
- AfterNamespace : false ,
187
- AfterObjCDeclaration : false ,
188
- AfterStruct : false ,
189
- AfterUnion : false ,
190
- AfterExternBlock : false ,
191
- BeforeCatch : false ,
192
- BeforeElse : false ,
193
- BeforeLambdaBody : false ,
194
- BeforeWhile : false ,
195
- IndentBraces : false ,
196
- SplitEmptyFunction : true ,
197
- SplitEmptyRecord : true ,
198
- SplitEmptyNamespace : true ,
199
- } ,
200
- BreakAfterJavaFieldAnnotations : false ,
201
- BreakBeforeBinaryOperators : 'NonAssignment' ,
202
- BreakBeforeBraces : 'Attach' ,
203
- BreakBeforeConceptDeclarations : false ,
204
- BreakBeforeInheritanceComma : false ,
205
- BreakBeforeTernaryOperators : true ,
206
- BreakConstructorInitializers : 'BeforeColon' ,
207
- BreakConstructorInitializersBeforeComma : false ,
208
- BreakInheritanceList : 'BeforeColon' ,
209
- BreakStringLiterals : false ,
210
- ColumnLimit : 0 ,
211
- CommentPragmas : '' ,
212
- CompactNamespaces : false ,
213
- ConstructorInitializerAllOnOneLineOrOnePerLine : false ,
214
- ConstructorInitializerIndentWidth : 2 ,
215
- ContinuationIndentWidth : 2 ,
216
- Cpp11BracedListStyle : false ,
217
- DeriveLineEnding : true ,
218
- DerivePointerAlignment : true ,
219
- DisableFormat : false ,
220
- EmptyLineAfterAccessModifier : 'Leave' ,
221
- EmptyLineBeforeAccessModifier : 'Leave' ,
222
- ExperimentalAutoDetectBinPacking : false ,
223
- FixNamespaceComments : false ,
224
- ForEachMacros : [ 'foreach' , 'Q_FOREACH' , 'BOOST_FOREACH' ] ,
225
- IfMacros : [ 'KJ_IF_MAYBE' ] ,
226
- IncludeBlocks : 'Preserve' ,
227
- IncludeCategories : [
228
- {
229
- Regex : '^"(llvm|llvm-c|clang|clang-c)/' ,
230
- Priority : 2 ,
231
- SortPriority : 0 ,
232
- CaseSensitive : false ,
233
- } ,
234
- {
235
- Regex : '^(<|"(gtest|gmock|isl|json)/)' ,
236
- Priority : 3 ,
237
- SortPriority : 0 ,
238
- CaseSensitive : false ,
239
- } ,
240
- { Regex : '.*' , Priority : 1 , SortPriority : 0 , CaseSensitive : false } ,
241
- ] ,
242
- IncludeIsMainRegex : '' ,
243
- IncludeIsMainSourceRegex : '' ,
244
- IndentAccessModifiers : false ,
245
- IndentCaseBlocks : true ,
246
- IndentCaseLabels : true ,
247
- IndentExternBlock : 'Indent' ,
248
- IndentGotoLabels : false ,
249
- IndentPPDirectives : 'None' ,
250
- IndentRequires : true ,
251
- IndentWidth : 2 ,
252
- IndentWrappedFunctionNames : false ,
253
- InsertTrailingCommas : 'None' ,
254
- JavaScriptQuotes : 'Leave' ,
255
- JavaScriptWrapImports : true ,
256
- KeepEmptyLinesAtTheStartOfBlocks : true ,
257
- LambdaBodyIndentation : 'Signature' ,
258
- Language : 'Cpp' ,
259
- MacroBlockBegin : '' ,
260
- MacroBlockEnd : '' ,
261
- MaxEmptyLinesToKeep : 100000 ,
262
- NamespaceIndentation : 'None' ,
263
- ObjCBinPackProtocolList : 'Auto' ,
264
- ObjCBlockIndentWidth : 2 ,
265
- ObjCBreakBeforeNestedBlockParam : true ,
266
- ObjCSpaceAfterProperty : false ,
267
- ObjCSpaceBeforeProtocolList : true ,
268
- PPIndentWidth : - 1 ,
269
- PackConstructorInitializers : 'BinPack' ,
270
- PenaltyBreakAssignment : 1 ,
271
- PenaltyBreakBeforeFirstCallParameter : 1 ,
272
- PenaltyBreakComment : 1 ,
273
- PenaltyBreakFirstLessLess : 1 ,
274
- PenaltyBreakOpenParenthesis : 1 ,
275
- PenaltyBreakString : 1 ,
276
- PenaltyBreakTemplateDeclaration : 1 ,
277
- PenaltyExcessCharacter : 1 ,
278
- PenaltyIndentedWhitespace : 1 ,
279
- PenaltyReturnTypeOnItsOwnLine : 1 ,
280
- PointerAlignment : 'Right' ,
281
- QualifierAlignment : 'Leave' ,
282
- ReferenceAlignment : 'Pointer' ,
283
- ReflowComments : false ,
284
- RemoveBracesLLVM : false ,
285
- SeparateDefinitionBlocks : 'Leave' ,
286
- ShortNamespaceLines : 0 ,
287
- SortIncludes : 'Never' ,
288
- SortJavaStaticImport : 'Before' ,
289
- SortUsingDeclarations : false ,
290
- SpaceAfterCStyleCast : false ,
291
- SpaceAfterLogicalNot : false ,
292
- SpaceAfterTemplateKeyword : false ,
293
- SpaceAroundPointerQualifiers : 'Default' ,
294
- SpaceBeforeAssignmentOperators : true ,
295
- SpaceBeforeCaseColon : false ,
296
- SpaceBeforeCpp11BracedList : false ,
297
- SpaceBeforeCtorInitializerColon : true ,
298
- SpaceBeforeInheritanceColon : true ,
299
- SpaceBeforeParens : 'ControlStatements' ,
300
- SpaceBeforeParensOptions : {
301
- AfterControlStatements : true ,
302
- AfterForeachMacros : true ,
303
- AfterFunctionDefinitionName : false ,
304
- AfterFunctionDeclarationName : false ,
305
- AfterIfMacros : true ,
306
- AfterOverloadedOperator : false ,
307
- BeforeNonEmptyParentheses : false ,
308
- } ,
309
- SpaceBeforeRangeBasedForLoopColon : true ,
310
- SpaceBeforeSquareBrackets : false ,
311
- SpaceInEmptyBlock : false ,
312
- SpaceInEmptyParentheses : false ,
313
- SpacesBeforeTrailingComments : 2 ,
314
- SpacesInAngles : 'Leave' ,
315
- SpacesInCStyleCastParentheses : false ,
316
- SpacesInConditionalStatement : false ,
317
- SpacesInContainerLiterals : false ,
318
- SpacesInLineCommentPrefix : { Minimum : 0 , Maximum : - 1 } ,
319
- SpacesInParentheses : false ,
320
- SpacesInSquareBrackets : false ,
321
- Standard : 'Auto' ,
322
- StatementAttributeLikeMacros : [ 'Q_EMIT' ] ,
323
- StatementMacros : [ 'Q_UNUSED' , 'QT_REQUIRE_VERSION' ] ,
324
- TabWidth,
325
- UseCRLF : false ,
152
+ ...defaultConfig ,
153
+ TabWidth, // 2. override the default values with the user-defined ones
326
154
UseTab,
327
- WhitespaceSensitiveMacros : [
328
- 'STRINGIZE' ,
329
- 'PP_STRINGIZE' ,
330
- 'BOOST_PP_STRINGIZE' ,
331
- 'NS_SWIFT_NAME' ,
332
- 'CF_SWIFT_NAME' ,
333
- ] ,
334
155
} ;
335
156
}
0 commit comments