Skip to content

Instantly share code, notes, and snippets.

@lunkums
Last active February 18, 2025 20:07
Show Gist options
  • Save lunkums/a526840d372ae6af9ee4cbeb1d0245c1 to your computer and use it in GitHub Desktop.
Save lunkums/a526840d372ae6af9ee4cbeb1d0245c1 to your computer and use it in GitHub Desktop.
Personal .clang-format settings
---
# ==============================================================================
# Prettier-style formatting
# Tested with clang-format version 17
# ==============================================================================
AccessModifierOffset: -1
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignConsecutiveShortCaseStatements:
Enabled: false
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: Never
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseExpressionOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: true
AllowShortNamespacesOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackLongBracedList: false
BinPackParameters: false
BitFieldColonSpacing: Both
BreakAdjacentStringLiterals: false
BreakAfterAttributes: Always
BreakAfterReturnType: Automatic
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: Allowed
BreakBeforeInlineASMColon: Always
BreakBeforeTemplateCloser: true
BreakBeforeTernaryOperators: true
BreakBinaryOperations: RespectPrecedence
BreakConstructorInitializers: AfterColon
BreakFunctionDefinitionParameters: false
BreakInheritanceList: AfterColon
BreakStringLiterals: false
BreakTemplateDeclarations: Yes
ColumnLimit: 80
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Never
FixNamespaceComments: false
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExportBlock: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentRequiresClause: false
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: true
IntegerLiteralSeparator:
Binary: 0
Decimal: 0
Hex: 0
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
Language: Cpp
LineEnding: LF
MainIncludeChar: Any
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PPIndentWidth: -1
PackConstructorInitializers: CurrentLine
PenaltyReturnTypeOnItsOwnLine: 1000
QualifierAlignment: Leave
ReflowComments: false
RemoveBracesLLVM: false
RemoveParentheses: Leave # Prettier removes unnecessary parentheses, but this setting can lead to incorrect code
RemoveSemicolon: false
RequiresClausePosition: WithPreceding
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1 # This option doesn't matter
SortUsingDeclarations: Never
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: false
SpacesInParens: Never
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 2
UseTab: Never
# ==============================================================================
# Personal preferences and convenience settings
# ==============================================================================
IncludeBlocks: Regroup
IncludeCategories:
- Regex: ^".*"$
Priority: 1
- Regex: ^<.*\.h>$
Priority: 2
- Regex: ^<.*>$
Priority: 3
# Consider "*" part of the type and prefer to keep it with the type name
PointerAlignment: Left
ReferenceAlignment: Left
SortIncludes: CaseInsensitive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment