Skip to content

Instantly share code, notes, and snippets.

@lunkums
Created August 29, 2024 20:37
Show Gist options
  • Save lunkums/e3a367ef812213888b833117e54ae2a5 to your computer and use it in GitHub Desktop.
Save lunkums/e3a367ef812213888b833117e54ae2a5 to your computer and use it in GitHub Desktop.
id Software-inspired .clang-format
---
UseTab: Never
TabWidth: 4
IndentWidth: 4
# Braces
BreakBeforeBraces: Attach
AllowShortIfStatementsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortEnumsOnASingleLine: false
# Spacing
SpaceBeforeParens: ControlStatements
SpacesInParentheses: true
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeRangeBasedForLoopColon: true
# Alignment
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignTrailingComments: true
# Indentation
IndentCaseLabels: true
NamespaceIndentation: None
# Line breaks
ColumnLimit: 100
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
# Pointer alignment
PointerAlignment: Left
# Function declarations
AllowAllParametersOfDeclarationOnNextLine: false
BinPackParameters: false
BinPackArguments: false
# Classes
AccessModifierOffset: -4
# Naming conventions can't be enforced by ClangFormat, but we can set some related options
FixNamespaceComments: true
# Other
SortIncludes: true
ReflowComments: true
InsertNewlineAtEOF: true
# Include statements
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment