-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.clang-format
69 lines (62 loc) · 1.83 KB
/
.clang-format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Run manually to reformat a file:
# clang-format -i --style=file <file>
Language: Cpp
BasedOnStyle: Google
# 缩进和格式控制
IndentWidth: 4
ColumnLimit: 0
TabWidth: 4
UseTab: Never
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: false
# 大括号和空格
BreakBeforeBraces: Attach
SpacesBeforeTrailingComments: 1
AlignTrailingComments: true
SpaceBeforeParens: ControlStatements
SpaceAfterTemplateKeyword: true
SpaceBeforeInheritanceColon: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeCpp11BracedList: false
ReflowComments: true
# 函数相关
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: Yes
# 对齐和缩进
IndentCaseLabels: true
NamespaceIndentation: Inner
AccessModifierOffset: 0
PointerAlignment: Left
ReferenceAlignment: Left
DerivePointerAlignment: false
EmptyLineBeforeAccessModifier: Always
InsertNewlineAtEOF: true
# 包含文件排序
SortIncludes: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"{{fileBasenameNoExtension}}\.(h|hpp)"$' # 当前目录的头文件
Priority: 1
SortPriority: 0
- Regex: '^<.*\.(h|hpp)>' # C 系统头文件
Priority: 2
SortPriority: 0
- Regex: '^<.*>' # C++ 标准库头文件
Priority: 2
SortPriority: 1
- Regex: '^".*\.(h|hpp)"' # 项目头文件
Priority: 3
SortPriority: 0
- Regex: '.*' # 其他头文件
Priority: 4
SortPriority: 0
# 构造函数初始化列表格式
BreakConstructorInitializers: BeforeColon
ConstructorInitializerIndentWidth: 4
PackConstructorInitializers: Never
# 操作符换行
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true