# .clang-format — C++ code style for Zedda
# Based on Google style with modifications for the Zedda codebase.
# Run: clang-format -i src/**/*.cpp include/zedda/*.hpp

---
Language: Cpp
Standard: c++17

# Indentation
IndentWidth: 4
TabWidth: 4
UseTab: Never
ContinuationIndentWidth: 4
AccessModifierOffset: -4

# Braces
BreakBeforeBraces: Custom
BraceWrapping:
  AfterClass: true
  AfterControlStatement: false
  AfterEnum: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false
  SplitEmptyFunction: false
  SplitEmptyRecord: false

# Line length
ColumnLimit: 100

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true

# Spaces
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false

# Short forms
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false

# Includes
IncludeBlocks: Regroup
IncludeCategories:
  # C++ standard library
  - Regex: '^<[^/]+>$'
    Priority: 1
  # Zedda headers
  - Regex: '^"zedda/'
    Priority: 3
  # Other project headers
  - Regex: '^".*$'
    Priority: 2

# Misc
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
