1

I'm trying to format my code this way :

int foo(int a,
        int b,
        int c)
{
}

However, all my attempts led to this results :

int foo(int a,
   int b,
   int c)
{
}

Here is my clang-format configuration, running on Manjaro :

# Under Visual studio, the plugin https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.ClangFormat makes the use of the clang formatter easier.

Language: Cpp

AccessModifierOffset: -4 
AlignAfterOpenBracket: Align #AlwaysBreak 
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true 
AlignEscapedNewlines: Left 
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always 
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All 
AllowShortIfStatementsOnASingleLine: Always 
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true 

BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: None 
BreakBeforeBraces: Allman 
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon 
BreakInheritanceList: AfterColon 
BreakStringLiterals: true

ColumnLimit: 120
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4

ContinuationIndentWidth: 4
Cpp11BracedListStyle: true

DerivePointerAlignment: false

FixNamespaceComments: true

IndentCaseLabels: false
IndentPPDirectives: BeforeHash   
IndentWidth: 4
IndentWrappedFunctionNames: false


KeepEmptyLinesAtTheStartOfBlocks: false

MaxEmptyLinesToKeep: 1

NamespaceIndentation: Inner 

PointerAlignment: Middle 

ReflowComments: true

SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false


TabWidth: 4
UseTab: Never 

## Penalites: This decides what order things should be done if a line is too long. 
## For instance, using the policies specified here:  https://stackoverflow.com/questions/26635370/in-clang-format-what-do-the-penalties-do

PenaltyBreakAssignment: 5
PenaltyBreakBeforeFirstCallParameter: 5
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyBreakTemplateDeclaration : 30
PenaltyExcessCharacter: 30
PenaltyReturnTypeOnItsOwnLine: 30

Does anyone knows how to force this alignement ?

FYI, already tried : Clang-format: Align Function Parameter Names and clang-format: break function parameters

Thanks a lot

Cheers

User123456
  • 11
  • 2
  • This [answer](https://stackoverflow.com/a/38393028/8372853) to the question you linked to; you need to set `AlignConsecutiveDeclarations: true`, but you have `false`. – cigien May 28 '20 at 12:53

1 Answers1

0

As I said, I already tried these solutions without success... Setting AlignConsecutiveDeclarations to true generates

Scene(const std::filesystem::path           scene_directory,
    Object3D *                            parent,
    Magnum::SceneGraph::DrawableGroup3D * group);

EDIT 1 : Found out the issue ! It was induced by my IDE for some unknown reasons. Copy pasting into a text editor shows the formatting is correct.. Thanks for the help !

User123456
  • 11
  • 2