add clang-format configuration

This will ensure our coding style is more clearly defined and allow
contibutors to auto-format their code, bringing some more consistency.
This commit is contained in:
Arnaud Ferraris
2024-10-29 14:04:27 +01:00
parent 99aa7e2bf7
commit 57142c2c11

48
.clang-format Normal file
View File

@@ -0,0 +1,48 @@
BasedOnStyle: LLVM
ColumnLimit: 100
IndentWidth: 4
IndentGotoLabels: false
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: None
AlignConsecutiveMacros: AcrossEmptyLines
AlignConsecutiveDeclarations:
Enabled: true
# Available only with clang-format 20+
# AlignFunctionDeclarations: true
AlignFunctionPointers: true
# Ensure we either have all args/params on a single line,
# or only one per line
BinPackArguments: false
BinPackParameters: false
# To be changed for clang-format 20+
# BinPackParameters: OnePerLine
# Avoid single-line enums/functions/ifs/loops/etc
AllowShortBlocksOnASingleLine: Never
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortCaseExpressionOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
BreakBeforeBinaryOperators: None
# Ensure function opening brackets are on their own line
BreakBeforeBraces: Linux
# Available only with clang-format 20+
# BreakBinaryOperations: OnePerLine
InsertNewlineAtEOF: true
# Don't be too strict on line lengths
PenaltyExcessCharacter: 10
# Prefer breaking arguments list over putting a function call
# on its own line after an assignment
PenaltyBreakAssignment: 200
PenaltyBreakBeforeFirstCallParameter: 200
# Ensure we never ever have the return type on a single line
PenaltyReturnTypeOnItsOwnLine: 1000