|
| 1 | +# Google C++ Style Guide 代码格式化配置 |
| 2 | +# 基于 clang-format 的 Google 预设风格 |
| 3 | + |
| 4 | +BasedOnStyle: Google |
| 5 | + |
| 6 | +# 语言设置 |
| 7 | +Language: Cpp |
| 8 | + |
| 9 | +# 缩进设置 |
| 10 | +IndentWidth: 2 |
| 11 | +TabWidth: 2 |
| 12 | +UseTab: Never |
| 13 | +ContinuationIndentWidth: 4 |
| 14 | + |
| 15 | +# 列宽 |
| 16 | +ColumnLimit: 120 |
| 17 | + |
| 18 | +# 指针和引用对齐 |
| 19 | +PointerAlignment: Left |
| 20 | +ReferenceAlignment: Left |
| 21 | + |
| 22 | +# 命名空间 |
| 23 | +NamespaceIndentation: None |
| 24 | +FixNamespaceComments: true |
| 25 | + |
| 26 | +# 括号样式 |
| 27 | +AllowShortIfStatementsOnASingleLine: false |
| 28 | +AllowShortLoopsOnASingleLine: false |
| 29 | +AllowShortFunctionsOnASingleLine: Empty |
| 30 | +AllowShortBlocksOnASingleLine: false |
| 31 | +AllowShortCaseLabelsOnASingleLine: false |
| 32 | + |
| 33 | +# 括号 |
| 34 | +BraceWrapping: |
| 35 | + AfterClass: true |
| 36 | + AfterControlStatement: true |
| 37 | + AfterEnum: true |
| 38 | + AfterFunction: true |
| 39 | + AfterNamespace: false |
| 40 | + AfterStruct: true |
| 41 | + AfterUnion: true |
| 42 | + AfterExternBlock: false |
| 43 | + BeforeCatch: true |
| 44 | + BeforeElse: true |
| 45 | + BeforeWhile: false |
| 46 | + IndentBraces: false |
| 47 | + SplitEmptyFunction: true |
| 48 | + SplitEmptyRecord: true |
| 49 | + SplitEmptyNamespace: true |
| 50 | + |
| 51 | +# 包含文件排序 |
| 52 | +SortIncludes: true |
| 53 | +IncludeBlocks: Regroup |
| 54 | + |
| 55 | +# 空格 |
| 56 | +SpaceAfterCStyleCast: false |
| 57 | +SpaceAfterTemplateKeyword: true |
| 58 | +SpaceBeforeAssignmentOperators: true |
| 59 | +SpaceBeforeCpp11BracedList: false |
| 60 | +SpaceBeforeCtorInitializerColon: true |
| 61 | +SpaceBeforeInheritanceColon: true |
| 62 | +SpaceBeforeParens: ControlStatements |
| 63 | +SpaceBeforeRangeBasedForLoopColon: true |
| 64 | +SpaceInEmptyParentheses: false |
| 65 | +SpacesBeforeTrailingComments: 2 |
| 66 | +SpacesInAngles: false |
| 67 | +SpacesInCStyleCastParentheses: false |
| 68 | +SpacesInContainerLiterals: true |
| 69 | +SpacesInParentheses: false |
| 70 | +SpacesInSquareBrackets: false |
| 71 | + |
| 72 | +# 换行 |
| 73 | +AlwaysBreakAfterReturnType: None |
| 74 | +AlwaysBreakBeforeMultilineStrings: false |
| 75 | +BreakBeforeBinaryOperators: None |
| 76 | +BreakBeforeBraces: Attach |
| 77 | +BreakBeforeTernaryOperators: true |
| 78 | +BreakConstructorInitializersBeforeComma: false |
| 79 | +BreakAfterJavaFieldAnnotations: false |
| 80 | +BreakStringLiterals: true |
| 81 | + |
| 82 | +# 其他 |
| 83 | +AlignAfterOpenBracket: Align |
| 84 | +AlignConsecutiveAssignments: false |
| 85 | +AlignConsecutiveDeclarations: false |
| 86 | +AlignEscapedNewlines: Right |
| 87 | +AlignOperands: true |
| 88 | +AlignTrailingComments: true |
| 89 | +BinPackArguments: true |
| 90 | +BinPackParameters: true |
| 91 | +CompactNamespaces: false |
| 92 | +ConstructorInitializerAllOnOneLineOrOnePerLine: false |
| 93 | +DerivePointerAlignment: false |
| 94 | +DisableFormat: false |
| 95 | +ExperimentalAutoDetectBinPacking: false |
| 96 | +ForEachMacros: |
| 97 | + - foreach |
| 98 | + - Q_FOREACH |
| 99 | + - BOOST_FOREACH |
| 100 | +IncludeIsMainRegex: '([-_](test|unittest))?$' |
| 101 | +IndentCaseLabels: true |
| 102 | +IndentPPDirectives: None |
| 103 | +KeepEmptyLinesAtTheStartOfBlocks: false |
| 104 | +MacroBlockBegin: '' |
| 105 | +MacroBlockEnd: '' |
| 106 | +MaxEmptyLinesToKeep: 1 |
| 107 | +PenaltyBreakAssignment: 2 |
| 108 | +PenaltyBreakBeforeFirstCallParameter: 1 |
| 109 | +PenaltyBreakComment: 300 |
| 110 | +PenaltyBreakFirstLessLess: 120 |
| 111 | +PenaltyBreakString: 1000 |
| 112 | +PenaltyBreakTemplateDeclaration: 10 |
| 113 | +PenaltyExcessCharacter: 1000000 |
| 114 | +PenaltyReturnTypeOnItsOwnLine: 200 |
| 115 | +ReflowComments: true |
| 116 | +SortUsingDeclarations: true |
| 117 | +Standard: Auto |
| 118 | + |
0 commit comments