Skip to content

Instantly share code, notes, and snippets.

@Pharap
Created July 4, 2018 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pharap/f376130bc48864133d97aeceff7e2939 to your computer and use it in GitHub Desktop.
Save Pharap/f376130bc48864133d97aeceff7e2939 to your computer and use it in GitHub Desktop.
A .clang-format to follow my personal preferred coding style
#
# Copyright (C) 2018 Pharap (@Pharap)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# For more info about clang-format files see:
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
#
# Language Rules
#
Language: Cpp
Standard: Cpp11
#
# General Rules
#
DisableFormat: false
#
# Tab Rules
#
#UseTab: ForContinuationAndIndentation
UseTab: Always
TabWidth: 4
ColumnLimit: 0
#
# Indent Amounts
#
IndentWidth: 4
ContinuationIndentWidth: 4
ConstructorInitializerIndentWidth: 4
AccessModifierOffset: 0
#
# Indent And Brace Rules
#
BreakBeforeBraces: Allman
# BreakBeforeBraces: Custom
# BraceWrapping:
# AfterClass: true
# AfterControlStatement: true
# AfterEnum: true
# AfterFunction: true
# AfterNamespace: true
# AfterStruct: true
# AfterUnion: true
# AfterExtern: true
# BeforeCatch: true
# BeforeElse: true
# IndentBraces: false
# SplitEmptyRecord: true
# SplitEmptyNamespace: true
# AfterObjCDecleration: true
IndentCaseLabels: true
IndentPPDirectives: None
IndentWrappedFunctionNames: false
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
#
# Include Rules
#
SortIncludes: false
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<^[.]*>'
Priority: 1
- Regex: '^<.*>'
Priority: 2
- Regex: '".*"'
Priority: 3
#
# Alignment Rules
#
PointerAlignment: Middle
DerivePointerAlignment: false
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: false
AlignOperands: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
#
# Single Line Rules
#
ConstructorInitializerAllOnOneLineOrOnePerLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
#
# Argument Packing Rules
#
BinPackArguments: false
BinPackParameters: false
ExperimentalAutoDetectBinPacking: false
#
# Namespace Rules
#
CompactNamespaces: false
FixNamespaceComments: false
NamespaceIndentation: All
SortUsingDeclarations: false
#
# Empty Line Rules
#
MaxEmptyLinesToKeep: 2
KeepEmptyLinesAtTheStartOfBlocks: false
#
# Macro Rules
#
MacroBlockBegin: "^BEGIN_.*$"
MacroBlockEnd: "^END_.*$"
#
# Penalty Rules
#
PenaltyBreakAssignment: 0
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyBreakComment: 0
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 0
PenaltyBreakTemplateDeclaration: 0
PenaltyExcessCharacter: 0
PenaltyReturnTypeOnItsOwnLine: 0
#
# Comment Rules
#
ReflowComments: false
SpacesBeforeTrailingComments: 1
#
# Space rules
#
Cpp11BracedListStyle: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeRangeBasedForLoopColon: true
SpacesInContainerLiterals: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeParens: false
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
#
# Undecided Rules
#
# BreakStringLiterals: true
# CommentPragmas: ""
# RawStringFormats:
# ForEachMacros: []
# IncludeIsMainRegex: ""
#
# Javascript Rules
#
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: false
#
# Objective C Rules
#
# ObjCBinPackProtocolList: Auto
# ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment