Align Array Brace Init on new lines

63 Views Asked by At

I have the following snippet:

ID3D11SamplerState* samplers[] = {
    linear_sampler.Get(),
    nullptr,
    nullptr,
    nullptr,
    nullptr
};

I want to keep Array initializers like this. However, clang-format puts all values on a single line like so :

ID3D11SamplerState* samplers[] = {linear_sampler.Get(), nullptr, nullptr, nullptr, nullptr};

How can I avoid that?

My clang-format looks like this:

---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignOperands: false
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: None
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: Yes
BraceWrapping: 
  AfterCaseLabel: false
  AfterClass: false
  AfterControlStatement: false
  AfterEnum: false
  AfterFunction: false
  AfterNamespace: false
  AfterStruct: false
  AfterUnion: false
  AfterExternBlock: false
  BeforeCatch: true
  BeforeElse: true
  BeforeLambdaBody: false
  BeforeWhile: true
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
ColumnLimit: 400
ContinuationIndentWidth: 4
IncludeCategories: 
  - Regex: ^<.*
    Priority: 1
  - Regex: ^".*
    Priority: 2
  - Regex: .*
    Priority: 3
IncludeIsMainRegex: ([-_](test|unittest))?$
IndentCaseLabels: true
IndentWidth: 4
IndentRequires: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PointerAlignment: Left
AlignArrayOfStructures : Left
SpaceAfterTemplateKeyword: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: false
SpacesInContainerLiterals: false
Standard: Auto
TabWidth: 4
UseTab: Always
...

I already use AlignArrayOfStructures : Left and it does not help, since my Array is a pointer array, not an array of structures.

0

There are 0 best solutions below