|
| 1 | +--- |
| 2 | + |
| 3 | +# Documentation on clang-format options here: |
| 4 | +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html |
| 5 | + |
| 6 | +Language: Cpp |
| 7 | +Standard: c++20 |
| 8 | + |
| 9 | +# Google style is a good starting point; modifiers attempt to match style |
| 10 | +# guide here: https://github.com/ceph/ceph/blob/main/CodingStyle |
| 11 | +BasedOnStyle: Google |
| 12 | +IndentWidth: 2 |
| 13 | +TabWidth: 8 |
| 14 | +UseTab: Never |
| 15 | +MaxEmptyLinesToKeep: 2 |
| 16 | +ContinuationIndentWidth: 4 |
| 17 | + |
| 18 | +# The intended impact here is to allow up to 96 characters, but break at 80 if |
| 19 | +# 96 is exceeded. |
| 20 | +ColumnLimit: 80 |
| 21 | + |
| 22 | +# The "Penalty" concept in clang-format is not well |
| 23 | +# documented, see here for more: https://stackoverflow.com/questions/26635370 |
| 24 | +# |
| 25 | +# Note that the penalties are not numbers of characters, they act more like |
| 26 | +# decision weights. |
| 27 | +PenaltyExcessCharacter: 50 |
| 28 | +PenaltyBreakAssignment: 50 |
| 29 | +PenaltyBreakBeforeFirstCallParameter: 50 |
| 30 | +PenaltyBreakOpenParenthesis: 50 |
| 31 | + |
| 32 | +# Brace wrapping to match style guide |
| 33 | +BreakBeforeBraces: Custom |
| 34 | +BraceWrapping: |
| 35 | + AfterCaseLabel: false |
| 36 | + AfterClass: false |
| 37 | + AfterControlStatement: Never |
| 38 | + AfterEnum: false |
| 39 | + AfterFunction: true |
| 40 | + AfterNamespace: false |
| 41 | + AfterStruct: false |
| 42 | + BeforeCatch: false |
| 43 | + BeforeElse: false |
| 44 | + BeforeLambdaBody: false |
| 45 | + SplitEmptyFunction: false |
| 46 | + SplitEmptyRecord: false |
| 47 | + SplitEmptyNamespace: false |
| 48 | + |
| 49 | +# Access modifiers indent/outdent specified relative to body, use -2 to |
| 50 | +# align to braces. Also do not indent case blocks. Finally, an emply line |
| 51 | +# should always precede "private:" or "public:" or "protected:" |
| 52 | +AccessModifierOffset: -2 |
| 53 | +IndentCaseLabels: false |
| 54 | +EmptyLineBeforeAccessModifier: Always |
| 55 | +ConstructorInitializerIndentWidth: 2 |
| 56 | + |
| 57 | +#Always break after an open bracket, if the parameters don’t fit on a single line |
| 58 | +AlignAfterOpenBracket: AlwaysBreak |
| 59 | + |
| 60 | +# Newline escapes should be aligned and located at the leftmost alignment |
| 61 | +AlignEscapedNewlines: Left |
| 62 | + |
| 63 | +# Align after operands across continuation into multiple lines for binary and |
| 64 | +# ternary. |
| 65 | +AlignOperands: Align |
| 66 | + |
| 67 | +# Do not align trailing comments across multiple lines. Note that this only applies |
| 68 | +# to the single-line comment style using "//". Block inlines are always left alone. |
| 69 | +AlignTrailingComments: false |
| 70 | + |
| 71 | +# If the function declaration doesn’t fit on a line, allow putting all parameters of a |
| 72 | +# function declaration onto the next line even if BinPackParameters is OnePerLine |
| 73 | +AllowAllParametersOfDeclarationOnNextLine: false |
| 74 | + |
| 75 | +# Do not allow short enums on a single line. |
| 76 | +AllowShortEnumsOnASingleLine: false |
| 77 | + |
| 78 | +# Only merge functions defined inside a class. Implies empty |
| 79 | +AllowShortFunctionsOnASingleLine: All |
| 80 | + |
| 81 | +# Never put short ifs on the same line. |
| 82 | +AllowShortIfStatementsOnASingleLine: false |
| 83 | + |
| 84 | +# If true, "while (true) continue;" can be put on a single line |
| 85 | +AllowShortLoopsOnASingleLine: false |
| 86 | + |
| 87 | +# Always break after the return type of function definitions. |
| 88 | +AlwaysBreakAfterReturnType: AllDefinitions |
| 89 | + |
| 90 | +# Always break after template declaration. |
| 91 | +AlwaysBreakTemplateDeclarations: Yes |
| 92 | + |
| 93 | +# If false, a function declaration’s or function definition’s parameters |
| 94 | +# will either all be on the same line or will have one line each. |
| 95 | +BinPackArguments: true |
| 96 | +BinPackParameters: false |
| 97 | + |
| 98 | +# The break should always be after the binary and ternary operands. |
| 99 | +BreakBeforeBinaryOperators: None |
| 100 | +BreakBeforeTernaryOperators: true |
| 101 | + |
| 102 | +# Break constructor initializers before the colon and after the commas. |
| 103 | +# Constructor() |
| 104 | +# : initializer1(), |
| 105 | +# initializer2() |
| 106 | +BreakConstructorInitializers: AfterColon |
| 107 | + |
| 108 | +# Pad the braced list with spaces inside the braces. |
| 109 | +Cpp11BracedListStyle: true |
| 110 | + |
| 111 | +# Where to put the & and the * in the case of pointers/references. |
| 112 | +DerivePointerAlignment: false |
| 113 | +PointerAlignment: Left |
| 114 | + |
| 115 | +# Keep empty lines at end of file. |
| 116 | +KeepEmptyLinesAtEOF: false |
| 117 | + |
| 118 | +# Keep empty lines at start of a block. |
| 119 | +KeepEmptyLinesAtTheStartOfBlocks: true |
| 120 | + |
| 121 | +# Align lambda body relative to the lambda signature. |
| 122 | +LambdaBodyIndentation: Signature |
| 123 | + |
| 124 | +# No indent in namespaces. |
| 125 | +NamespaceIndentation: None |
| 126 | + |
| 127 | +# No way to specify C vs C++ style comment for namespace closure, so just |
| 128 | +# leave them alone. |
| 129 | +FixNamespaceComments: true |
| 130 | + |
| 131 | +# 1 space before trailing comments |
| 132 | +SpacesBeforeTrailingComments: 1 |
| 133 | + |
| 134 | +# Colon spacing should always be '"key" : "value"' |
| 135 | +BitFieldColonSpacing: Both |
| 136 | + |
| 137 | +# Do not break up strings into multi-line strings. This becomes a problem when |
| 138 | +# multi-line strings with no spaces are broken. |
| 139 | +BreakStringLiterals: true |
| 140 | + |
| 141 | +# C-tor should always break before the : and again before the {} in cases where |
| 142 | +# otherwise the c-tor could theoretically be one-lined. In the case where the |
| 143 | +# initializer list is short enough to fit on one line after the wrap, do not break |
| 144 | +# into individual lines. |
| 145 | +# Note NextLineOnly requires clang-format >= 15 |
| 146 | +PackConstructorInitializers: NextLineOnly |
| 147 | + |
| 148 | +# includes are sorted based on the other suboptions below |
| 149 | +SortIncludes: true |
| 150 | +# Merge multiple #include blocks together and sort as one. Then split into groups based on |
| 151 | +# category priority. |
| 152 | +IncludeBlocks: Regroup |
| 153 | +# Regular expressions denoting the different #include categories used for ordering #includes. |
| 154 | +IncludeCategories: |
| 155 | + - Regex: 'debug.h' |
| 156 | + Priority: 4 |
| 157 | + - Regex: '\"\./[^/]+\"' |
| 158 | + Priority: 1 |
| 159 | + - Regex: '\"[^/]+\"' |
| 160 | + Priority: 8 |
| 161 | + - Regex: 'boost' |
| 162 | + Priority: 5 |
| 163 | + - Regex: '<.*\.h' |
| 164 | + Priority: 2 |
| 165 | + - Regex: '<' |
| 166 | + Priority: 3 |
| 167 | + - Regex: '.*' |
| 168 | + Priority: 6 |
| 169 | + |
| 170 | +# use "template <>" instead of "template<>" |
| 171 | +SpaceAfterTemplateKeyword: true |
| 172 | + |
| 173 | +# Always pad assignments with a space, like "variable = 2;". |
| 174 | +SpaceBeforeAssignmentOperators: true |
| 175 | + |
| 176 | +# Turn off comment reflow entirely |
| 177 | +# TODO: This was done to prevent undoing good formatting of doxygen @brief @param |
| 178 | +# etc multi-line comments (similar to this comment). Investigate comment |
| 179 | +# pragmas to leave these alone? |
| 180 | +ReflowComments: false |
| 181 | + |
| 182 | +# There should always be an empty line between method definiton blocks. |
| 183 | +SeparateDefinitionBlocks: Always |
| 184 | + |
| 185 | +# The penalty for each line break introduced inside a comment. |
| 186 | +PenaltyBreakComment: 0 |
| 187 | + |
| 188 | +# How many spaces are allowed at the start of a line comment. To disable the maximum |
| 189 | +# set it to -1, apart from that the maximum takes precedence over the minimum |
| 190 | +SpacesInLineCommentPrefix: |
| 191 | + Minimum: 1 |
| 192 | + Maximum: -1 |
| 193 | + |
| 194 | +--- |
| 195 | + |
| 196 | +Language: Proto |
| 197 | + |
| 198 | +# Google style is a good starting point; |
| 199 | +BasedOnStyle: Google |
| 200 | +IndentWidth: 2 |
| 201 | + |
| 202 | +# The intended impact here is to allow up to 96 characters, but break at 80 if |
| 203 | +# 96 is exceeded. The "Penalty" concept in clang-format is not well |
| 204 | +# documented, see here for more: https://stackoverflow.com/questions/26635370 |
| 205 | +ColumnLimit: 80 |
| 206 | +PenaltyExcessCharacter: 50 |
| 207 | + |
| 208 | +# Turn off comment reflow entirely |
| 209 | +# TODO: This was done to prevent undoing user-defined formatting of multi-line |
| 210 | +# comments. |
| 211 | +ReflowComments: false |
| 212 | + |
| 213 | +--- |
| 214 | +Language: Json |
| 215 | + |
| 216 | +# Google style is a good starting point |
| 217 | +BasedOnStyle: Google |
| 218 | +IndentWidth: 2 |
| 219 | +MaxEmptyLinesToKeep: 2 |
0 commit comments