Last active
April 26, 2025 15:27
-
-
Save rdev/edcb07a56d5bd88f4a35bf2b5df9e8a2 to your computer and use it in GitHub Desktop.
Sensible Metal formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BasedOnStyle: WebKit # WebKit is the least deranged baseline | |
| IndentWidth: 2 # 2-space indents | |
| ContinuationIndentWidth: 2 # also 2-space for broken lines | |
| AlignAfterOpenBracket: BlockIndent # indent blocks under open paren/bracket | |
| NamespaceIndentation: All # always indent inside namespaces | |
| IndentCaseLabels: true # pushes `case` one level in | |
| IndentCaseBlocks: true # statements under the label get one more indent | |
| BreakBeforeBraces: Custom # manually specify brace rules | |
| BraceWrapping: | |
| AfterFunction: false # function body brace on same line | |
| AfterControlStatement: false # no newline after if/while/for | |
| AfterNamespace: false # namespace braces on same line | |
| AfterClass: false # class braces on same line | |
| AfterStruct: false # struct braces on same line | |
| AfterUnion: false # union braces on same line | |
| AfterEnum: false # enum braces on same line | |
| IndentBraces: false # don't further indent inside braces | |
| BeforeElse: false # else stays on same line as closing brace | |
| BeforeCatch: false # catch stays on same line as closing brace | |
| SortIncludes: true # alphabetize and regroup includes | |
| IncludeBlocks: Regroup # inserts blank line between groups if priority changes | |
| IncludeCategories: | |
| - Regex: '^<.*>$' | |
| Priority: 1 # system headers in first block | |
| SortPriority: -1 # negative sort priority to ensure angle brackets come first | |
| - Regex: '^"[^./][^"]*"' | |
| Priority: 1 # same priority, no blank line | |
| SortPriority: 0 # higher sort priority, comes after angle brackets | |
| - Regex: '^"[.]{1,2}/' | |
| Priority: 2 # local relative includes in separate block | |
| SortPriority: 0 # sort alphabetically within this block | |
| PenaltyBreakBeforeFirstCallParameter: 1000 # very high cost to break fn call early | |
| AllowAllParametersOfDeclarationOnNextLine: true # allow fn decl params to fully wrap | |
| BreakFunctionDefinitionParameters: false # prefer keeping all fn def params together | |
| AllowShortIfStatementsOnASingleLine: false # no `if (x) return;` one-liners because readability matters | |
| AllowShortLoopsOnASingleLine: false # no one-line loops either | |
| InsertBraces: true # always add braces even for 1-line blocks | |
| SpaceBeforeParens: ControlStatements # space only for control flow (if/while/etc) | |
| SpacesInParentheses: false # no spaces inside parentheses | |
| SpaceAfterCStyleCast: true # `(type) expr` with space after cast | |
| BinPackParameters: false # one parameter per line if wrapping | |
| BinPackArguments: false # one argument per line if wrapping | |
| ColumnLimit: 100 # soft line length limit (not 80 bc we're not barbarians) | |
| IndentExternBlock: Indent # indent contents of extern "C" | |
| UseTab: Never # spaces only | |
| PointerAlignment: Left # `int* ptr`, not `int *ptr` | |
| ReferenceAlignment: Right # but `float &radius`, not `float& radius` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment