From 57142c2c112a31435300f89a5f1b3160b7c30b34 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Tue, 29 Oct 2024 14:04:27 +0100 Subject: [PATCH] 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. --- .clang-format | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2113e49 --- /dev/null +++ b/.clang-format @@ -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