Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cinder ClangFormat
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Stroustrup
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Always
...

How to use ClangFormat with Cinder

Install ClangFormat via your platform's package manager. On windows, download the installer and Visual Studio plugin from LLVM.

Download the .clang-format file from this Gist and save it to the root directory of your Cinder repo.

Format whole files from Terminal

clang-format -i -style=file [<file> ...]

From Sublime Text 3

Download the Clang Format plugin from Package Control (or manually).

Run the Clang Format: Select Style command and choose File. This will instruct clang-format to search up the directory tree and use the first .clang-format file it finds.

Select a few lines of source code and run Clang Format: Format Selection.

From Xcode

Check out ClangFormat-Xcode.

Known issues

These are things that differ from Cinder's code style but cannot be specified in ClangFormat.

  • A space is not inserted after the ! boolean operator.
  • Cinder has no enforced maximum line length, so array declarations tend to stay on one line.

Improvements

If you find a place where this file fails to match Cinder's coding style, please fork this Gist and leave a comment!

@heisters

This comment has been minimized.

Copy link

@heisters heisters commented Mar 12, 2020

thanks Ryan!

@notlion

This comment has been minimized.

Copy link
Owner Author

@notlion notlion commented Mar 15, 2020

No problem, Ian! You'll likely need to modify this as it was written for an older version of ClangFormat. It could probably be updated to use some of the newer features. I hope this is a good starting point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.