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: 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