clang-format
application/octet-stream
Filename: clang-format
Type: application/octet-stream
Part: 0
# See https://clang.llvm.org/docs/ClangFormat.html
# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# See https://github.com/timescale/timescaledb/blob/main/.clang-format
---
BasedOnStyle: LLVM
Language: Cpp
# UseTab should be Always, else spaces can sneak in in nested function params:
UseTab: Always
TabWidth: 4
IndentWidth: 4
# Complicated ereport() indentation is screwed without this:
ContinuationIndentWidth: 8
SpacesBeforeTrailingComments: 1
# Line things up
AccessModifierOffset: -2 # outdent `public:`, etc
DerivePointerAlignment: false
PointerAlignment: Right # char *foo, char &bar
# This aligns function declarations, which seems bad, but I can't figure out a way to align variables at the start of
# functions and not get this:
AlignConsecutiveDeclarations: false
ReflowComments: false
# It even aligns function arguments to each other when a function declaration is isolated from other declarations, so
# that workaround won't do -- have to live with it.
AlignConsecutiveAssignments: false
AlignAfterOpenBracket: Align
NamespaceIndentation: All
AlignOperands: true
# Whitespace can break things up, but IMV is never useful at the start of a
# block:
KeepEmptyLinesAtTheStartOfBlocks: false
AlignEscapedNewlines: Right
# Not worth it, since you never get anything on the first line of an over-long "elog(ERROR, "..." ":
BreakStringLiterals: false
AllowAllArgumentsOnNextLine: false # Applies to function call sites
AllowAllParametersOfDeclarationOnNextLine: false # Applies to function declarations only
BinPackArguments: false # Applies to function call sites
BinPackParameters: true # Applies to function declarations and definitions
ExperimentalAutoDetectBinPacking: true
# Put "postgres.h" and "postgres_undefs.h" first in a group of includes:
SortIncludes: true
IncludeIsMainSourceRegex: '(postgres\.h)$'
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 1
- Regex: 'postgres.h'
Priority: 2
SortPriority: 2
- Regex: '.*'
Priority: 3
SortPriority: 3
# (Note that these header settings are optimized for sorting headers in alphabetical order, without breaking groupings
# that are already there, while avoiding allowing clangd's --header-insertion= feature to add needed #include files to
# the top of the .c file, before postgres.h is included first)
# Braces
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: true
AlwaysBreakAfterReturnType: AllDefinitions
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
BreakBeforeBraces: Custom
# This makes sure that || and && are last on line within a multi-line if statement:
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
ColumnLimit: 78
IndentCaseLabels: true
IndentPPDirectives: None # do not indent preprocessor directives after the '#'
MaxEmptyLinesToKeep: 1
SpaceAfterCStyleCast: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeAssignmentOperators: true
SpaceInEmptyParentheses: false
SpaceBeforeParens: ControlStatements
IndentWrappedFunctionNames: false # we do not indent the function name in the declaration
AlignTrailingComments: true
ForEachMacros:
- foreach
- forboth
- for_each_cell
- for_each_cell_compat
- for_both_cell
- forthree
# The penalty for breaking around an assignment operator:
PenaltyBreakAssignment: 0
# The penalty for breaking a function call after call:
PenaltyBreakBeforeFirstCallParameter: 5
#PenaltyIndentedWhitespace: 50
# The penalty for each line break introduced inside a comment:
PenaltyBreakComment: 10
# The penalty for breaking before the first <<:
PenaltyBreakFirstLessLess: 0
# The penalty for each line break introduced inside a string literal:
PenaltyBreakString: 20
# The penalty for each character outside of the column limit:
PenaltyExcessCharacter: 20
# Penalty for putting the return type of a function onto its own line:
PenaltyReturnTypeOnItsOwnLine: 200
PenaltyBreakOpenParenthesis: 200
...