|
| 1 | +# ----------------------------------------------------------------------------- |
| 2 | +# mcpp-community C++ Style Configuration |
| 3 | +# |
| 4 | +# This configuration follows the style specification defined in: |
| 5 | +# https://github.com/mcpp-community/mcpp-style-ref |
| 6 | +# |
| 7 | +# Maintained by: mcpp-community |
| 8 | +# ----------------------------------------------------------------------------- |
| 9 | + |
| 10 | +Language: Cpp # Apply configuration to C++ |
| 11 | + |
| 12 | +# ----------------------------------------------------------------------------- |
| 13 | +# Language Standard |
| 14 | +# ----------------------------------------------------------------------------- |
| 15 | +Standard: Latest # Always use the latest supported C++ standard |
| 16 | + |
| 17 | +# ----------------------------------------------------------------------------- |
| 18 | +# Indentation |
| 19 | +# ----------------------------------------------------------------------------- |
| 20 | +IndentWidth: 4 # Use 4 spaces for indentation |
| 21 | +TabWidth: 4 # Visual width of tab |
| 22 | +UseTab: Never # Never use tabs |
| 23 | + |
| 24 | +# ----------------------------------------------------------------------------- |
| 25 | +# Line Width |
| 26 | +# ----------------------------------------------------------------------------- |
| 27 | +ColumnLimit: 100 # Maximum line width |
| 28 | + |
| 29 | +# ----------------------------------------------------------------------------- |
| 30 | +# Spaces |
| 31 | +# ----------------------------------------------------------------------------- |
| 32 | +SpaceBeforeParens: ControlStatements # Space before parentheses for control statements (if/for/while); function calls remain tight |
| 33 | +SpacesInContainerLiterals: true # Enforce spaces in container literals |
| 34 | +SpaceBeforeAssignmentOperators: true # Add space before assignment operators |
| 35 | +SpacesInParentheses: false # No extra spaces inside parentheses |
| 36 | +PointerAlignment: Left # Pointer/reference attaches to type |
| 37 | +QualifierAlignment: Left # Place qualifiers like const to the left |
| 38 | + |
| 39 | +# ----------------------------------------------------------------------------- |
| 40 | +# Braces |
| 41 | +# ----------------------------------------------------------------------------- |
| 42 | +BreakBeforeBraces: Attach # Opening brace stays on same line |
| 43 | +AllowShortFunctionsOnASingleLine: Empty # Allow empty functions like `void f() {}` |
| 44 | +AllowShortIfStatementsOnASingleLine: Never # Disallow single-line if statements |
| 45 | +AllowShortBlocksOnASingleLine: Empty # Allow empty blocks on one line |
| 46 | +AllowShortLoopsOnASingleLine: false # Disallow one-line loops |
| 47 | + |
| 48 | +# ----------------------------------------------------------------------------- |
| 49 | +# Constructor Initializer List |
| 50 | +# ----------------------------------------------------------------------------- |
| 51 | +BreakConstructorInitializers: BeforeColon # Keep initializer list compact when short |
| 52 | +ConstructorInitializerAllOnOneLineOrOnePerLine: true # Allow compact initializer lists |
| 53 | +BreakConstructorInitializersBeforeComma: false # Do not break before commas |
| 54 | + |
| 55 | +# ----------------------------------------------------------------------------- |
| 56 | +# Access Modifiers |
| 57 | +# ----------------------------------------------------------------------------- |
| 58 | +AccessModifierOffset: -4 # Align access modifiers with class indentation |
| 59 | +EmptyLineBeforeAccessModifier: Never # Do not insert empty line before access specifiers |
| 60 | +EmptyLineAfterAccessModifier: Never # Do not insert empty line after access specifiers |
| 61 | + |
| 62 | +# ----------------------------------------------------------------------------- |
| 63 | +# Namespace Formatting |
| 64 | +# ----------------------------------------------------------------------------- |
| 65 | +NamespaceIndentation: None # Do not indent contents inside namespace |
| 66 | +FixNamespaceComments: true # Enforce closing namespace comments |
| 67 | +CompactNamespaces: true # Prefer namespace a::b instead of nested namespaces |
| 68 | + |
| 69 | +# ----------------------------------------------------------------------------- |
| 70 | +# Switch / Case Formatting |
| 71 | +# ----------------------------------------------------------------------------- |
| 72 | +IndentCaseLabels: true # Indent case/default labels |
| 73 | +IndentCaseBlocks: true # Indent statements inside case blocks |
| 74 | + |
| 75 | +# ----------------------------------------------------------------------------- |
| 76 | +# Includes |
| 77 | +# ----------------------------------------------------------------------------- |
| 78 | +SortIncludes: true # Automatically sort includes |
| 79 | +IncludeBlocks: Regroup # Regroup include blocks |
| 80 | +IncludeCategories: |
| 81 | + - Regex: "^<.*>" # Standard / third-party headers |
| 82 | + Priority: 1 |
| 83 | + - Regex: '^".*"' # Project headers |
| 84 | + Priority: 2 |
| 85 | + |
| 86 | +# ----------------------------------------------------------------------------- |
| 87 | +# Comment Alignment |
| 88 | +# ----------------------------------------------------------------------------- |
| 89 | +AlignTrailingComments: true # Align trailing comments |
| 90 | +SpacesBeforeTrailingComments: 2 # Two spaces before trailing comments |
| 91 | + |
| 92 | +# ----------------------------------------------------------------------------- |
| 93 | +# Parameter Formatting |
| 94 | +# ----------------------------------------------------------------------------- |
| 95 | +BinPackParameters: true # Allow parameters on same line |
| 96 | +BinPackArguments: true # Allow arguments on same line |
| 97 | + |
| 98 | +# ----------------------------------------------------------------------------- |
| 99 | +# Template Formatting |
| 100 | +# ----------------------------------------------------------------------------- |
| 101 | +AlwaysBreakTemplateDeclarations: Yes # Always place template declarations on their own line |
| 102 | + |
| 103 | +# ----------------------------------------------------------------------------- |
| 104 | +# Operator Line Breaking |
| 105 | +# ----------------------------------------------------------------------------- |
| 106 | +BreakBeforeBinaryOperators: None # Break after operators |
| 107 | + |
| 108 | +# ----------------------------------------------------------------------------- |
| 109 | +# Method Chain Formatting |
| 110 | +# ----------------------------------------------------------------------------- |
| 111 | +PenaltyBreakBeforeFirstCallParameter: 10000 # Avoid breaking chained calls unless necessary |
| 112 | + |
| 113 | +# ----------------------------------------------------------------------------- |
| 114 | +# Lambda Formatting |
| 115 | +# ----------------------------------------------------------------------------- |
| 116 | +AllowShortLambdasOnASingleLine: All # Allow short lambdas on one line |
| 117 | + |
| 118 | +# ----------------------------------------------------------------------------- |
| 119 | +# Using Declarations |
| 120 | +# ----------------------------------------------------------------------------- |
| 121 | +SortUsingDeclarations: true # Automatically sort using declarations |
| 122 | + |
| 123 | +# ----------------------------------------------------------------------------- |
| 124 | +# Return Type Formatting |
| 125 | +# ----------------------------------------------------------------------------- |
| 126 | +AlwaysBreakAfterReturnType: None # Break return type only when exceeding ColumnLimit |
| 127 | + |
| 128 | +# ----------------------------------------------------------------------------- |
| 129 | +# Concepts / Requires |
| 130 | +# ----------------------------------------------------------------------------- |
| 131 | +RequiresClausePosition: OwnLine # Force requires clause to a new line |
| 132 | +IndentRequiresClause: false # Do not indent requires clause |
0 commit comments