Last active
April 30, 2021 20:55
-
-
Save seanmiddleditch/15f5f070f6589f7bd4298747fb01d4ac to your computer and use it in GitHub Desktop.
This file contains 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
## General Options ## | |
# Indentation for all files | |
ColumnLimit: 0 | |
IndentWidth: 4 | |
TabWidth: 4 | |
UseTab: Never | |
## C++ Options ## | |
--- | |
Language: Cpp | |
Standard: c++17 | |
# Indentation and line wrapping | |
AccessModifierOffset: -4 | |
ConstructorInitializerIndentWidth: 4 | |
ContinuationIndentWidth: 4 | |
IndentCaseLabels: true | |
IndentWrappedFunctionNames: false | |
NamespaceIndentation: All | |
PenaltyBreakBeforeFirstCallParameter: 19 | |
PenaltyBreakComment: 300 | |
PenaltyBreakFirstLessLess: 120 | |
PenaltyBreakString: 1000 | |
PenaltyExcessCharacter: 1000000 | |
PenaltyReturnTypeOnItsOwnLine: 60 | |
KeepEmptyLinesAtTheStartOfBlocks: true | |
MaxEmptyLinesToKeep: 1 | |
# Spacing | |
SpaceAfterCStyleCast: false | |
SpaceAfterTemplateKeyword: true | |
SpaceBeforeAssignmentOperators: true | |
SpaceBeforeCpp11BracedList: false | |
SpaceBeforeParens: ControlStatements | |
SpaceInEmptyParentheses: false | |
SpacesBeforeTrailingComments: 1 | |
SpacesInAngles: false | |
SpacesInCStyleCastParentheses: false | |
SpacesInContainerLiterals: true | |
SpacesInParentheses: false | |
SpacesInSquareBrackets: false | |
# Alignment | |
AlignAfterOpenBracket: AlwaysBreak | |
AlignConsecutiveAssignments: false | |
AlignConsecutiveDeclarations: false | |
AlignEscapedNewlinesLeft: false | |
AlignOperands: Align | |
AlignTrailingComments: true | |
AllowAllParametersOfDeclarationOnNextLine: true | |
AllowShortBlocksOnASingleLine: true | |
AllowShortCaseLabelsOnASingleLine: true | |
AllowShortFunctionsOnASingleLine: Inline | |
AllowShortIfStatementsOnASingleLine: false | |
AllowShortLoopsOnASingleLine: false | |
AlwaysBreakAfterReturnType: None | |
AlwaysBreakBeforeMultilineStrings: false | |
AlwaysBreakTemplateDeclarations: true | |
PointerAlignment: Left | |
# Braces and line breaks | |
BreakBeforeBraces: Custom | |
BraceWrapping: | |
AfterCaseLabel: true | |
AfterClass: true | |
AfterControlStatement: Always | |
AfterEnum: true | |
AfterFunction: true | |
AfterNamespace: true | |
AfterStruct: true | |
AfterUnion: true | |
AfterExternBlock: true | |
BeforeElse: true | |
BeforeLambdaBody: true | |
IndentBraces: false | |
SplitEmptyFunction: true | |
SplitEmptyRecord: true | |
SplitEmptyNamespace: true | |
BinPackArguments: true | |
BinPackParameters: true | |
BreakBeforeBinaryOperators: NonAssignment | |
BreakBeforeTernaryOperators: true | |
BreakConstructorInitializers : BeforeComma | |
BreakInheritanceList: BeforeComma | |
BreakStringLiterals: true | |
ConstructorInitializerAllOnOneLineOrOnePerLine: true | |
Cpp11BracedListStyle: true | |
ReflowComments: true |
This file contains 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
struct test { int x; const char* name; }; | |
// is it possible to get clang-format to maintain the following | |
// code style? I've tried many tweaks of the accompanying | |
// .clang-format file; no dice. | |
// | |
// desired format, opening brace on new line, block indentation | |
// | |
static test values[] = | |
{ | |
{1, "test"}, | |
{2, "bob"}, | |
{3, "widget"}, | |
{4, "margaret"}, | |
}; | |
// | |
// best I can seem to do, but which The Company(tm) is apparently morally opposed to (I kid): | |
// | |
static test values_cuddled[] = { | |
{1, "test"}, | |
{2, "bob"}, | |
{3, "widget"}, | |
{4, "margaret"}, | |
}; | |
// | |
// what clang-format does if I try to manually break the brace without disabling Cpp11BracedListStyle... yuck | |
// | |
static test values_wat[] = | |
{ | |
{1, "test"}, | |
{2, "bob"}, | |
{3, "widget"}, | |
{4, "margaret"}, | |
}; | |
// | |
// what I'm recommending we do... sigh | |
// | |
// clang-format off | |
static test values_ok_i_guess[] = | |
{ | |
{1, "test"}, | |
{2, "bob"}, | |
{3, "widget"}, | |
{4, "margaret"}, | |
}; | |
// clang-format on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment