update clang format to use better formatting rules

This commit is contained in:
2025-07-03 10:41:50 +02:00
parent f4b1b46b49
commit da8e8c1450

View File

@@ -1,30 +1,31 @@
# Copyright (c) 2025 Quinn
# Licensed under the MIT Licence. See LICENSE for details
--- ---
# --------------------------- # ---------------------------
# general style settings # general style settings
# --------------------------- # ---------------------------
BasedOnStyle: '' BasedOnStyle: GNU
Standard: Auto Standard: Auto
ColumnLimit: 0 ColumnLimit: 0
LineEnding: LF LineEnding: LF
UseTab: ForContinuationAndIndentation UseTab: ForContinuationAndIndentation
TabWidth: 4 TabWidth: 8
IndentWidth: 4 IndentWidth: 8
ContinuationIndentWidth: 4 ContinuationIndentWidth: 8
AccessModifierOffset: -4
# --------------------------- # ---------------------------
# alignment options # alignment options
# --------------------------- # ---------------------------
AlignAfterOpenBracket: DontAlign AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: Left AlignOperands: DontAlign
AlignTrailingComments: true
AlignConsecutiveMacros: AcrossEmptyLines AlignConsecutiveMacros: AcrossEmptyLines
AlignEscapedNewlines: Left
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: None AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: AcrossEmptyLines AlignConsecutiveBitFields: AcrossEmptyLines
AlignConsecutiveDeclarations: None AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left AlignConsecutiveShortCaseStatements:
AlignOperands: DontAlign Enabled: true
AlignTrailingComments: Always
# --------------------------- # ---------------------------
# short constructs on a single line # short constructs on a single line
@@ -40,16 +41,14 @@ AllowShortLoopsOnASingleLine: true
# --------------------------- # ---------------------------
# break and wrapping options # break and wrapping options
# --------------------------- # ---------------------------
AlwaysBreakBeforeMultilineStrings: true AlwaysBreakBeforeMultilineStrings: false
BreakAfterReturnType: Automatic AlwaysBreakAfterReturnType: Automatic
BreakTemplateDeclarations: MultiLine BreakTemplateDeclarations: false
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Never BreakBeforeConceptDeclarations: Never
BreakBeforeBraces: Attach BreakBeforeBraces: Custom
BreakInheritanceList: BeforeColon BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeColon BreakStringLiterals: false
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
# --------------------------- # ---------------------------
# brace wrapping configuration # brace wrapping configuration
@@ -70,23 +69,23 @@ BraceWrapping:
BeforeLambdaBody: false BeforeLambdaBody: false
BeforeWhile: false BeforeWhile: false
IndentBraces: false IndentBraces: false
SplitEmptyFunction: false SplitEmptyFunction: true
SplitEmptyRecord: false SplitEmptyRecord: true
SplitEmptyNamespace: false SplitEmptyNamespace: true
# --------------------------- # ---------------------------
# constructor initializer and parameter packing options # constructor initializer and parameter packing options
# --------------------------- # ---------------------------
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 8
PackConstructorInitializers: BinPack PackConstructorInitializers: NextLine
BinPackParameters: true BinPackParameters: true
BinPackArguments: false BinPackArguments: true
# --------------------------- # ---------------------------
# pointer alignment # pointer alignment
# --------------------------- # ---------------------------
DerivePointerAlignment: false DerivePointerAlignment: false
PointerAlignment: Left PointerAlignment: Right
ReferenceAlignment: Pointer ReferenceAlignment: Pointer
QualifierAlignment: Right QualifierAlignment: Right
@@ -110,68 +109,37 @@ IncludeCategories:
SortPriority: 0 SortPriority: 0
CaseSensitive: true CaseSensitive: true
# ---------------------------
# macro and language-specific settings
# ---------------------------
AttributeMacros:
- __capability
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
# --------------------------- # ---------------------------
# additional formatting and sorting details # additional formatting and sorting details
# --------------------------- # ---------------------------
FixNamespaceComments: false
MaxEmptyLinesToKeep: 2
ReflowComments: true
RemoveBracesLLVM: false
AllowAllArgumentsOnNextLine: false AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false
EmptyLineAfterAccessModifier: Never EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
MaxEmptyLinesToKeep: 4
ReflowComments: true
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Leave SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1 ShortNamespaceLines: 1
SortIncludes: CaseSensitive SortIncludes: CaseSensitive
SortJavaStaticImport: Before SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric SortUsingDeclarations: false
# --------------------------- # ---------------------------
# spacing options # spacing options
# --------------------------- # ---------------------------
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false SpaceBeforeCaseColon: false
Cpp11BracedListStyle: true
SpaceBeforeCpp11BracedList: false SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true SpaceInEmptyBlock: true
SpacesInParens: Custom SpacesInParens: Custom
@@ -183,7 +151,8 @@ SpacesInParensOptions:
SpacesBeforeTrailingComments: 1 SpacesBeforeTrailingComments: 1
SpacesInAngles: Never SpacesInAngles: Never
SpacesInConditionalStatement: false SpacesInConditionalStatement: false
SpacesInContainerLiterals: true SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix: SpacesInLineCommentPrefix:
Minimum: 1 Minimum: 1
Maximum: 1 Maximum: 1
@@ -192,26 +161,26 @@ SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both BitFieldColonSpacing: Both
# ---------------------------
# penalty settings
# ---------------------------
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60
# --------------------------- # ---------------------------
# indentation details # indentation details
# --------------------------- # ---------------------------
IndentAccessModifiers: false IndentAccessModifiers: false
IndentCaseLabels: false IndentCaseLabels: false
IndentCaseBlocks: false IndentCaseBlocks: false
IndentGotoLabels: true IndentGotoLabels: false
IndentExternBlock: AfterExternBlock IndentExternBlock: AfterExternBlock
IndentRequiresClause: false IndentRequiresClause: false
IndentPPDirectives: None IndentPPDirectives: None
PPIndentWidth: 1 PPIndentWidth: 1
---
# ---------------------------
# Objective-C specific settings
# ---------------------------
Language: ObjC
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
... ...