File
Blob: .clang-format
| 1 | Language: Cpp |
| 2 | Standard: c++20 |
| 3 | ColumnLimit: 100 |
| 4 | |
| 5 | WhitespaceSensitiveMacros: |
| 6 | # clang format doesn't understand TypeScript, so make sure it doesn't mangle |
| 7 | # overrides and additional definitions |
| 8 | - JSG_TS_OVERRIDE |
| 9 | - JSG_TS_DEFINE |
| 10 | - JSG_STRUCT_TS_OVERRIDE |
| 11 | - JSG_STRUCT_TS_DEFINE |
| 12 | AllowShortFunctionsOnASingleLine: Empty |
| 13 | |
| 14 | SortIncludes: true |
| 15 | IncludeBlocks: Regroup |
| 16 | IncludeCategories: |
| 17 | # c++ system headers |
| 18 | - Regex: <[a-zA-Z0-9_]+> |
| 19 | Priority: 5 |
| 20 | # kj/capnp headers |
| 21 | - Regex: <(kj|capnp)/.+> |
| 22 | Priority: 4 |
| 23 | # workerd headers |
| 24 | - Regex: <workerd/.+> |
| 25 | Priority: 2 |
| 26 | # 3rd party headers |
| 27 | - Regex: <.+> |
| 28 | Priority: 3 |
| 29 | # local headers |
| 30 | - Regex: '".*"' |
| 31 | Priority: 1 |
| 32 | |
| 33 | AllowShortIfStatementsOnASingleLine: true |
| 34 | AllowShortLoopsOnASingleLine: true |
| 35 | AllowShortBlocksOnASingleLine: Empty |
| 36 | |
| 37 | IndentWidth: 2 |
| 38 | IndentCaseBlocks: false |
| 39 | IndentCaseLabels: true |
| 40 | PointerAlignment: Left |
| 41 | DerivePointerAlignment: true |
| 42 | |
| 43 | # Move public and private in by a half-indentation. This makes |
| 44 | # diffs and Github code reviews more readable by letting you |
| 45 | # see which class the diff snippet is part of. |
| 46 | AccessModifierOffset: -1 |
| 47 | |
| 48 | # Really "Attach" but empty braces aren't split. |
| 49 | BreakBeforeBraces: Custom |
| 50 | BraceWrapping: |
| 51 | AfterCaseLabel: false |
| 52 | AfterClass: false |
| 53 | AfterControlStatement: Never |
| 54 | AfterEnum: false |
| 55 | AfterFunction: false |
| 56 | AfterNamespace: false |
| 57 | AfterObjCDeclaration: false |
| 58 | AfterStruct: false |
| 59 | AfterUnion: false |
| 60 | AfterExternBlock: false |
| 61 | BeforeCatch: false |
| 62 | BeforeElse: false |
| 63 | BeforeLambdaBody: false |
| 64 | BeforeWhile: false |
| 65 | IndentBraces: false |
| 66 | SplitEmptyFunction: false |
| 67 | SplitEmptyRecord: false |
| 68 | SplitEmptyNamespace: false |
| 69 | |
| 70 | Cpp11BracedListStyle: true |
| 71 | |
| 72 | AlignAfterOpenBracket: DontAlign |
| 73 | AlignOperands: DontAlign |
| 74 | AlignTrailingComments: |
| 75 | Kind: Always |
| 76 | OverEmptyLines: 0 |
| 77 | AlwaysBreakAfterReturnType: None |
| 78 | AlwaysBreakTemplateDeclarations: Yes |
| 79 | BreakStringLiterals: false |
| 80 | BinPackArguments: true |
| 81 | BinPackParameters: false |
| 82 | BracedInitializerIndentWidth: 2 |
| 83 | BreakInheritanceList: BeforeColon |
| 84 | ContinuationIndentWidth: 4 |
| 85 | IfMacros: |
| 86 | [ |
| 87 | "KJ_SWITCH_ONEOF", |
| 88 | "KJ_CASE_ONEOF", |
| 89 | "KJ_IF_MAYBE", |
| 90 | "KJ_IF_SOME", |
| 91 | "CFJS_RESOURCE_TYPE", |
| 92 | ] |
| 93 | LambdaBodyIndentation: OuterScope |
| 94 | Macros: |
| 95 | - "KJ_MAP(x,y)=[y](auto x)" |
| 96 | - "JSG_VISITABLE_LAMBDA(x,y,z)=[x,y](z)" |
| 97 | # The WhitespaceSensitiveMacros solution is flaky, adding the following ensures no formatting: |
| 98 | - "JSG_TS_OVERRIDE(x)=enum class" |
| 99 | - "JSG_TS_DEFINE(x)=enum class" |
| 100 | - "JSG_STRUCT_TS_OVERRIDE(x)=enum class" |
| 101 | - "JSG_STRUCT_TS_DEFINE(x)=enum class" |
| 102 | PenaltyReturnTypeOnItsOwnLine: 1000 |
| 103 | PackConstructorInitializers: CurrentLine |
| 104 | ReflowComments: false |
| 105 | SpaceBeforeCtorInitializerColon: false |
| 106 | SpaceBeforeInheritanceColon: false |
| 107 | SpaceBeforeParens: ControlStatementsExceptControlMacros |
| 108 | SpaceBeforeRangeBasedForLoopColon: false |
| 109 | SpaceBeforeCpp11BracedList: false |
| 110 | SpacesBeforeTrailingComments: 2 |
| 111 | --- |
| 112 | # Some files with embedded typescript are incorrectly recognized by clang-format as Objective-C |
| 113 | # This is because the C/C++ macro expansion step happens after the language recognition step, so |
| 114 | # when trying to parse the file, the c++ parser fails with incorrect syntax and a fallback to |
| 115 | # the Objective-C parser is used. |
| 116 | # This is a workaround to hide the warning. |
| 117 | # TODO: Remove this once we have a better solution. |
| 118 | Language: ObjC |
| 119 | DisableFormat: true |