# For more information, see:
#
#   https://clang.llvm.org/docs/ClangFormat.html
#   https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
---

BasedOnStyle: GNU

# Line width: https://developer.gimp.org/core/coding_style/#line-width
# FIXME: set to 0 because Penalty* rules annoys who follows 80 char limit
ColumnLimit: 0
# Our column limit is more around 80 characters but we want to avoid
# this rule to be over-agressive. So for clang-format, let's use a
# higher limit. Then let's put some biggish penalties on breaking on
# assignment, or parentheses, or other similar cases. Actually with such
# limits, if clang-format really ends up re-formatting, there might be
# something better to do code-wise (i.e. we might be in an akwardly
# over-nested block case).
# ColumnLimit: 80
# PenaltyBreakAssignment: 60
# PenaltyBreakBeforeFirstCallParameter: 100
# PenaltyBreakOpenParenthesis: 40
# PenaltyExcessCharacter: 1
# Strings are more often longer by usage, so let's give these slightly
# more space to breath.
# PenaltyBreakString: 60
# PenaltyReturnTypeOnItsOwnLine: 50

# Whitespaces / Indentation: https://developer.gimp.org/core/coding_style/#indentation
IndentWidth: 2
UseTab: Never

# Whitespaces / Horizontal spaces: https://developer.gimp.org/core/coding_style/#horizontal-spaces
SpaceBeforeParens: Always
SpaceAfterLogicalNot: true
SpaceAfterCStyleCast: true
AllowShortIfStatementsOnASingleLine: Never
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: None

# Braces / Switch: https://developer.gimp.org/core/coding_style/#switch
BreakBeforeBraces: GNU

# Conditions: https://developer.gimp.org/core/coding_style/#conditions
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false

# Variables: https://developer.gimp.org/core/coding_style/#variables-declaration-and-definition
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
AlignConsecutiveBitFields: AcrossComments
PointerAlignment: Right

# Functions: https://developer.gimp.org/core/coding_style/#functions
AlignAfterOpenBracket: Align
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AlwaysBreakAfterReturnType: AllDefinitions
BinPackArguments: true
BinPackParameters: AlwaysOnePerLine

# Macros: https://developer.gimp.org/core/coding_style/#macros
AlignConsecutiveMacros: AcrossComments
AlignEscapedNewlines: Left

# Structures: https://developer.gimp.org/core/coding_style/#structures
AlignArrayOfStructures: Left
