Skip to content

Commit d390c07

Browse files
committed
Add a .clang-format with our style
1 parent cc4f8bc commit d390c07

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.clang-format

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This file is an example configuration for clang-format 5.0.
2+
#
3+
# Note that this style definition should only be understood as a hint
4+
# for writing new code. The rules are still work-in-progress and does
5+
# not yet exactly match the style we have in the existing code.
6+
7+
# C Language specifics
8+
Language: Cpp
9+
10+
# Use tabs whenever we need to fill whitespace that spans at least from one tab
11+
# stop to the next one.
12+
#
13+
# These settings are mirrored in .editorconfig. Keep them in sync.
14+
UseTab: ForIndentation
15+
TabWidth: 8
16+
IndentWidth: 8
17+
ContinuationIndentWidth: 8
18+
ColumnLimit: 80
19+
20+
AlignAfterOpenBracket: AlwaysBreak
21+
AlignEscapedNewlines: Left
22+
AlignTrailingComments: false
23+
24+
# Allow putting parameters onto the next line
25+
AllowAllArgumentsOnNextLine: false
26+
AllowAllParametersOfDeclarationOnNextLine: false
27+
28+
# Don't allow short braced statements to be on a single line
29+
# if (a) not if (a) return;
30+
# return;
31+
AllowShortBlocksOnASingleLine: false
32+
AllowShortFunctionsOnASingleLine: None
33+
AllowShortLoopsOnASingleLine: false
34+
AllowShortLambdasOnASingleLine: None
35+
36+
# Pack as many parameters or arguments onto the same line as possible
37+
# int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
38+
# int cccc);
39+
BinPackArguments: true
40+
BinPackParameters: false
41+
42+
BreakBeforeBraces: Linux
43+
BreakBeforeBinaryOperators: None
44+
BreakBeforeTernaryOperators: false
45+
BreakStringLiterals: false
46+
47+
# The number of spaces before trailing line comments (// - comments).
48+
# This does not affect trailing block comments (/* - comments).
49+
SpacesBeforeTrailingComments: 1
50+
51+
# Don't insert spaces in casts
52+
# x = (int32) y; not x = ( int32 ) y;
53+
SpacesInCStyleCastParentheses: false
54+
55+
# Don't insert spaces inside container literals
56+
# var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
57+
SpacesInContainerLiterals: false
58+
59+
# Don't insert spaces after '(' or before ')'
60+
# f(arg); not f( arg );
61+
SpacesInParentheses: false
62+
63+
# Don't insert spaces after '[' or before ']'
64+
# int a[5]; not int a[ 5 ];
65+
SpacesInSquareBrackets: false
66+
67+
# Insert a space after '{' and before '}' in struct initializers
68+
Cpp11BracedListStyle: false
69+
70+
# A list of macros that should be interpreted as foreach loops instead of as
71+
# function calls.
72+
ForEachMacros:
73+
- 'git_array_foreach'
74+
- 'git_vector_foreach'
75+
76+
# The maximum number of consecutive empty lines to keep.
77+
MaxEmptyLinesToKeep: 1
78+
79+
# No empty line at the start of a block.
80+
KeepEmptyLinesAtTheStartOfBlocks: false
81+
82+
# Penalties
83+
# This decides what order things should be done if a line is too long
84+
PenaltyBreakAssignment: 10
85+
PenaltyBreakBeforeFirstCallParameter: 30
86+
PenaltyBreakComment: 10
87+
PenaltyBreakFirstLessLess: 0
88+
PenaltyBreakString: 10
89+
PenaltyExcessCharacter: 100
90+
PenaltyReturnTypeOnItsOwnLine: 60
91+
92+
SortIncludes: false

0 commit comments

Comments
 (0)