Skip to content

Commit

Permalink
Add clang-format config.
Browse files Browse the repository at this point in the history
I'm going to try it.  I'm not completely happy with the formatting I can
get out of clang-format, but I've been wanting _something_ for so long.

My main remaining gripe is with the use of braces.  I have a simple rule
for those: feel free to leave out the braces on a single-statement block
_so long as matched if/else blocks are formatted identically._  That
does not seem to be something that clang-format can do.

The next-biggest gripe is with alignment and indentation:

    return std::vector<errorhandler *>{std::begin(m_errorhandlers),
                                       std::end(m_errorhandlers)};

That's just horrible.  I don't want that first argument on the same
line as the opening brace — if you've got a list of things that won't
fit the line, start breaking lines right _before_ the first item, so the
structure remains clear at a glance.  Nor do I like creative horizontal
alignment — indent or don't indent, but don't go padding to some
arbitrary width.

It seems that I can turn these horrors off in the configuration, but
only with parentheses, not with braces.  ☹
  • Loading branch information
jtv committed Dec 31, 2019
1 parent 71fceb2 commit d1d850f
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Language: Cpp

AlignAfterOpenBracket: AlwaysBreak
# AllowAllArgumentsOnNextLine: true
# AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
# AllowShortIfStatementsOnASingleLine: WithoutElse
# AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
# AlwaysBreakTemplateDeclarations: No
BinPackArguments: true
BinPackParameters: true
BreakBeforeBraces: Custom
BraceWrapping:
# AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyNamespace: false
SplitEmptyRecord: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
# BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 79
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
# NamespaceIndentation: All
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
# SpaceBeforeCpp11BracedList: false
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# SpaceBeforeParents: ControlStatements
# SpaceBeforeRangedBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
UseTab: Never
---

0 comments on commit d1d850f

Please sign in to comment.