-
-
Save YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4 to your computer and use it in GitHub Desktop.
| AccessModifierOffset: -2 | |
| AlignAfterOpenBracket: BlockIndent # New in v14. For earlier clang-format versions, use AlwaysBreak instead. | |
| AlignConsecutiveMacros: false | |
| AlignConsecutiveAssignments: false | |
| AlignConsecutiveDeclarations: false | |
| AlignEscapedNewlines: DontAlign | |
| AlignOperands: false | |
| AlignTrailingComments: false | |
| AllowAllArgumentsOnNextLine: false | |
| AllowAllConstructorInitializersOnNextLine: false | |
| AllowAllParametersOfDeclarationOnNextLine: false | |
| AllowShortBlocksOnASingleLine: Empty | |
| AllowShortCaseLabelsOnASingleLine: false | |
| AllowShortFunctionsOnASingleLine: Empty | |
| AllowShortIfStatementsOnASingleLine: Never | |
| AllowShortLambdasOnASingleLine: All | |
| AllowShortLoopsOnASingleLine: false | |
| AlwaysBreakAfterReturnType: None | |
| AlwaysBreakBeforeMultilineStrings: true | |
| AlwaysBreakTemplateDeclarations: Yes | |
| BinPackArguments: false | |
| BinPackParameters: false | |
| BreakBeforeBinaryOperators: NonAssignment | |
| BreakBeforeBraces: Attach | |
| BreakBeforeTernaryOperators: true | |
| BreakConstructorInitializers: AfterColon | |
| BreakInheritanceList: AfterColon | |
| BreakStringLiterals: false | |
| ColumnLimit: 80 | |
| CompactNamespaces: false | |
| ConstructorInitializerAllOnOneLineOrOnePerLine: true | |
| ConstructorInitializerIndentWidth: 4 | |
| ContinuationIndentWidth: 4 | |
| Cpp11BracedListStyle: true | |
| DerivePointerAlignment: false | |
| FixNamespaceComments: true | |
| IncludeBlocks: Regroup | |
| IncludeCategories: | |
| - Regex: '^<ext/.*\.h>' | |
| Priority: 2 | |
| SortPriority: 0 | |
| CaseSensitive: false | |
| - Regex: '^<.*\.h>' | |
| Priority: 1 | |
| SortPriority: 0 | |
| CaseSensitive: false | |
| - Regex: '^<.*' | |
| Priority: 2 | |
| SortPriority: 0 | |
| CaseSensitive: false | |
| - Regex: '.*' | |
| Priority: 3 | |
| SortPriority: 0 | |
| CaseSensitive: false | |
| IncludeIsMainRegex: '([-_](test|unittest))?$' | |
| IndentCaseLabels: true | |
| IndentPPDirectives: BeforeHash | |
| IndentWidth: 4 | |
| IndentWrappedFunctionNames: false | |
| KeepEmptyLinesAtTheStartOfBlocks: false | |
| MaxEmptyLinesToKeep: 1 | |
| NamespaceIndentation: Inner | |
| PointerAlignment: Left | |
| ReferenceAlignment: Left # New in v13. int &name ==> int& name | |
| ReflowComments: false | |
| SeparateDefinitionBlocks: Always # New in v14. | |
| SortIncludes: true | |
| SortUsingDeclarations: true | |
| SpaceAfterCStyleCast: false | |
| SpaceAfterLogicalNot: false | |
| SpaceAfterTemplateKeyword: false | |
| SpaceBeforeAssignmentOperators: true | |
| SpaceBeforeCpp11BracedList: true | |
| SpaceBeforeCtorInitializerColon: true | |
| SpaceBeforeInheritanceColon: false | |
| SpaceBeforeParens: ControlStatements | |
| SpaceBeforeRangeBasedForLoopColon: true | |
| SpaceInEmptyParentheses: false | |
| SpacesBeforeTrailingComments: 1 | |
| SpacesInAngles: false | |
| SpacesInCStyleCastParentheses: false | |
| SpacesInContainerLiterals: false | |
| SpacesInParentheses: false | |
| SpacesInSquareBrackets: false | |
| Standard: Cpp11 | |
| TabWidth: 4 | |
| UseTab: Never |
When clang-format 16 is widely supported, you could consider adding BreakAfterAttributes: Always
thank you so much for this :)
@YodaEmbedding According to https://doc.rust-lang.org/nightly/style-guide/#comments, SpacesBeforeTrailingComments should be set to 1, not 2; to quote: “Prefer to put a comment on its own line. Where a comment follows code, put a single space before it. […]”.
Setting this to 1 also incidentally fixes the formatting of said comments for me when using tabs instead of spaces.
Here's a more rust-like .clang-format in https://gist.github.com/julyfun/8a739e0529818a4a41bf1762e6859fbf
I created this after reading through https://doc.rust-lang.org/nightly/style-guide , as well as a rust-like .clang-tidy here: https://github.com/SJTU-RoboMaster-Team/style-team/blob/main/.clang-tidy
@julyfun Awesome, thanks for sharing! By the way, it appears that Cpp11 is a deprecated alias for Latest, so it's probably best to avoid using it: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#standard
Edit: Also, according to the documentation above, AllowAllConstructorInitializersOnNextLine and ConstructorInitializerAllOnOneLineOrOnePerLine are also deprecated.
gorgeous. thanks alot!
👍🏻