Skip to content
Snippets Groups Projects

ESP Style Guide clang-format configuration

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Bom, David Jonathan

    Do you have style, and format your code in a neat way - say like 1TBS?

    And do you really don't want to spend time thinking about the horrid ESP style guide?

    clang-format to the rescue!

    Just run clang-format -style=file -i test.c after copying this configuration to a parent directory of the source. (the name .clang-format is important)

    If you're plagued by your OCD bcs you miss your newline at the EOF, you'll have to manually echo >>test.c after formatting, since clang-format seems to unconditionally remove them :'(

    Edited
    .clang-format 4.58 KiB
    ---
    Language:        Cpp
    # BasedOnStyle:  LLVM
    AccessModifierOffset: -2
    AlignAfterOpenBracket: Align
    AlignConsecutiveMacros: None
    AlignConsecutiveAssignments: None
    AlignConsecutiveBitFields: None
    AlignConsecutiveDeclarations: None
    AlignEscapedNewlines: Right
    AlignOperands:   Align
    AlignTrailingComments: true
    AllowAllArgumentsOnNextLine: true
    AllowAllConstructorInitializersOnNextLine: true
    AllowAllParametersOfDeclarationOnNextLine: true
    AllowShortEnumsOnASingleLine: false
    AllowShortBlocksOnASingleLine: Never
    AllowShortCaseLabelsOnASingleLine: false
    AllowShortFunctionsOnASingleLine: Empty
    AllowShortLambdasOnASingleLine: Empty
    AllowShortIfStatementsOnASingleLine: Never
    AllowShortLoopsOnASingleLine: false
    AlwaysBreakAfterDefinitionReturnType: None
    AlwaysBreakAfterReturnType: None
    AlwaysBreakBeforeMultilineStrings: false
    AlwaysBreakTemplateDeclarations: MultiLine
    AttributeMacros:
      - __capability
    BinPackArguments: true
    BinPackParameters: true
    BraceWrapping:
      AfterCaseLabel:  true
      AfterClass:      true
      AfterControlStatement: Never
      AfterEnum:       true
      AfterFunction:   true
      AfterNamespace:  true
      AfterObjCDeclaration: true
      AfterStruct:     true
      AfterUnion:      true
      AfterExternBlock: true
      BeforeCatch:     true
      BeforeElse:      true
      BeforeLambdaBody: true
      BeforeWhile:     true
      IndentBraces:    false
      SplitEmptyFunction: true
      SplitEmptyRecord: true
      SplitEmptyNamespace: true
    BreakBeforeBinaryOperators: None
    BreakBeforeConceptDeclarations: true
    BreakBeforeBraces: Allman
    BreakBeforeInheritanceComma: false
    BreakInheritanceList: BeforeColon
    BreakBeforeTernaryOperators: true
    BreakConstructorInitializersBeforeComma: false
    BreakConstructorInitializers: BeforeColon
    BreakAfterJavaFieldAnnotations: false
    BreakStringLiterals: true
    ColumnLimit:     120
    CommentPragmas:  '^ IWYU pragma:'
    CompactNamespaces: false
    ConstructorInitializerAllOnOneLineOrOnePerLine: false
    ConstructorInitializerIndentWidth: 2
    ContinuationIndentWidth: 2
    Cpp11BracedListStyle: true
    DeriveLineEnding: true
    DerivePointerAlignment: false
    DisableFormat:   false
    EmptyLineBeforeAccessModifier: LogicalBlock
    ExperimentalAutoDetectBinPacking: false
    FixNamespaceComments: true
    ForEachMacros:
      - foreach
      - Q_FOREACH
      - BOOST_FOREACH
    StatementAttributeLikeMacros:
      - Q_EMIT
    IncludeBlocks:   Preserve
    IncludeCategories:
      - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
        Priority:        2
        SortPriority:    0
        CaseSensitive:   false
      - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
        Priority:        3
        SortPriority:    0
        CaseSensitive:   false
      - Regex:           '.*'
        Priority:        1
        SortPriority:    0
        CaseSensitive:   false
    IncludeIsMainRegex: '(Test)?$'
    IncludeIsMainSourceRegex: ''
    IndentCaseLabels: true
    IndentCaseBlocks: false
    IndentGotoLabels: true
    IndentPPDirectives: None
    IndentExternBlock: AfterExternBlock
    IndentRequires:  false
    IndentWidth:     2
    IndentWrappedFunctionNames: false
    InsertTrailingCommas: None
    JavaScriptQuotes: Leave
    JavaScriptWrapImports: true
    KeepEmptyLinesAtTheStartOfBlocks: true
    MacroBlockBegin: ''
    MacroBlockEnd:   ''
    MaxEmptyLinesToKeep: 1
    NamespaceIndentation: None
    ObjCBinPackProtocolList: Auto
    ObjCBlockIndentWidth: 2
    ObjCBreakBeforeNestedBlockParam: true
    ObjCSpaceAfterProperty: false
    ObjCSpaceBeforeProtocolList: true
    PenaltyBreakAssignment: 2
    PenaltyBreakBeforeFirstCallParameter: 19
    PenaltyBreakComment: 300
    PenaltyBreakFirstLessLess: 120
    PenaltyBreakString: 1000
    PenaltyBreakTemplateDeclaration: 10
    PenaltyExcessCharacter: 1000000
    PenaltyReturnTypeOnItsOwnLine: 60
    PenaltyIndentedWhitespace: 0
    PointerAlignment: Left
    ReflowComments:  true
    SortIncludes:    true
    SortJavaStaticImport: Before
    SortUsingDeclarations: true
    SpaceAfterCStyleCast: false
    SpaceAfterLogicalNot: false
    SpaceAfterTemplateKeyword: true
    SpaceBeforeAssignmentOperators: true
    SpaceBeforeCaseColon: false
    SpaceBeforeCpp11BracedList: false
    SpaceBeforeCtorInitializerColon: true
    SpaceBeforeInheritanceColon: true
    SpaceBeforeParens: ControlStatements
    SpaceAroundPointerQualifiers: Default
    SpaceBeforeRangeBasedForLoopColon: true
    SpaceInEmptyBlock: false
    SpaceInEmptyParentheses: false
    SpacesBeforeTrailingComments: 1
    SpacesInAngles:  false
    SpacesInConditionalStatement: false
    SpacesInContainerLiterals: true
    SpacesInCStyleCastParentheses: false
    SpacesInParentheses: false
    SpacesInSquareBrackets: false
    SpaceBeforeSquareBrackets: false
    BitFieldColonSpacing: Both
    Standard:        Latest
    StatementMacros:
      - Q_UNUSED
      - QT_REQUIRE_VERSION
    TabWidth:        8
    UseCRLF:         false
    UseTab:          Never
    WhitespaceSensitiveMacros:
      - STRINGIZE
      - PP_STRINGIZE
      - BOOST_PP_STRINGIZE
      - NS_SWIFT_NAME
      - CF_SWIFT_NAME
    ...
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment