# RunAnywhere Engines - Clang Format Configuration
# Mirrors core/.clang-format to keep engine plugin
# sources (llamacpp, sherpa, onnx, qhexrt, neurt, cloud, common)
# on the same style as the C ABI/headers
# they implement. Editing this file? Keep it in lockstep with
# core/.clang-format and runtimes/.clang-format.

BasedOnStyle: Google

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

# Line length
ColumnLimit: 100

# Braces
BreakBeforeBraces: Attach
BraceWrapping:
  AfterClass: false
  AfterControlStatement: Never
  AfterEnum: false
  AfterFunction: false
  AfterNamespace: false
  AfterStruct: false
  AfterUnion: false
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false

# Functions
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: Empty

# Include sorting
IncludeBlocks: Regroup
IncludeCategories:
  # Main header (same name as source file)
  - Regex: '"[^/]*\.h"'
    Priority: 1
  # Project headers (rac_*)
  - Regex: '"rac_.*\.h"'
    Priority: 2
  # runanywhere-core headers (ra_*)
  - Regex: '"(ra_|runanywhere).*\.h"'
    Priority: 3
  # Third-party headers
  - Regex: '<[^/]*\.h>'
    Priority: 4
  # System headers
  - Regex: '<.*>'
    Priority: 5
SortIncludes: CaseSensitive

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

# Namespaces
NamespaceIndentation: None
CompactNamespaces: false
FixNamespaceComments: true

# Pointers and References
DerivePointerAlignment: false
PointerAlignment: Left
ReferenceAlignment: Left

# Empty lines
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1

# Other
AllowAllParametersOfDeclarationOnNextLine: true
BinPackArguments: true
BinPackParameters: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

# C/C++ specific
Language: Cpp
Standard: c++20

# Penalties (for line breaking decisions)
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
