-
Notifications
You must be signed in to change notification settings - Fork 307
/
.clang-format
119 lines (111 loc) · 3.22 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Language: Cpp
Standard: c++20
ColumnLimit: 100
WhitespaceSensitiveMacros:
# clang format doesn't understand TypeScript, so make sure it doesn't mangle
# overrides and additional definitions
- JSG_TS_OVERRIDE
- JSG_TS_DEFINE
- JSG_STRUCT_TS_OVERRIDE
- JSG_STRUCT_TS_DEFINE
AllowShortFunctionsOnASingleLine: Empty
SortIncludes: true
IncludeBlocks: Regroup
IncludeCategories:
# c++ system headers
- Regex: <[a-zA-Z0-9_]+>
Priority: 5
# kj/capnp headers
- Regex: <(kj|capnp)/.+>
Priority: 4
# workerd headers
- Regex: <workerd/.+>
Priority: 2
# 3rd party headers
- Regex: <.+>
Priority: 3
# local headers
- Regex: '".*"'
Priority: 1
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
IndentWidth: 2
IndentCaseBlocks: false
IndentCaseLabels: true
PointerAlignment: Left
DerivePointerAlignment: true
# Move public and private in by a half-indentation. This makes
# diffs and Github code reviews more readable by letting you
# see which class the diff snippet is part of.
AccessModifierOffset: -1
# Really "Attach" but empty braces aren't split.
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
Cpp11BracedListStyle: true
AlignAfterOpenBracket: DontAlign
AlignOperands: DontAlign
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakStringLiterals: false
BinPackArguments: true
BinPackParameters: false
BracedInitializerIndentWidth: 2
BreakInheritanceList: BeforeColon
ContinuationIndentWidth: 4
IfMacros:
[
"KJ_SWITCH_ONEOF",
"KJ_CASE_ONEOF",
"KJ_IF_MAYBE",
"KJ_IF_SOME",
"CFJS_RESOURCE_TYPE",
]
LambdaBodyIndentation: OuterScope
Macros:
- "KJ_MAP(x,y)=[y](auto x)"
- "JSG_VISITABLE_LAMBDA(x,y,z)=[x,y](z)"
# The WhitespaceSensitiveMacros solution is flaky, adding the following ensures no formatting:
- "JSG_TS_OVERRIDE(x)=enum class"
- "JSG_TS_DEFINE(x)=enum class"
- "JSG_STRUCT_TS_OVERRIDE(x)=enum class"
- "JSG_STRUCT_TS_DEFINE(x)=enum class"
PenaltyReturnTypeOnItsOwnLine: 1000
PackConstructorInitializers: CurrentLine
ReflowComments: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: false
SpaceBeforeCpp11BracedList: false
SpacesBeforeTrailingComments: 2
---
# Some files with embedded typescript are incorrectly recognized by clang-format as Objective-C
# This is because the C/C++ macro expansion step happens after the language recognition step, so
# when trying to parse the file, the c++ parser fails with incorrect syntax and a fallback to
# the Objective-C parser is used.
# This is a workaround to hide the warning.
# TODO: Remove this once we have a better solution.
Language: ObjC
DisableFormat: true