[英]Clang Format Issue with multiline function declaration parameters
Clang Format 一直在这样做:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something>
inSomething,
int x,
int y );
当我希望它这样做时:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,
int inSomeIndex,
std::shared_ptr<Something> inSomething,
int x,
int y );
请注意,它在符号inSomething
之前添加了换行符和缩进。 似乎总是导致这种行为的模板类型。
我怎样才能阻止它这样做?
这是我当前的 .clang 格式:
BasedOnStyle: LLVM
Language: Cpp
AccessModifierOffset: -4
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: true
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DerivePointerBinding: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
PointerBindsToType: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
Standard: Cpp11
TabWidth: 8
UseTab: Never
编辑:我使用的是我获得的铛格式的Xcode插件这里在github上2016年7月(第一次安装恶魔然后铛格式插件与Aclatraz)。 我不完全确定 clang-format 二进制文件在哪里,因此还没有看到插件附带的版本号。
但是,根据下面的建议,我使用 Homebrew 安装了 clang-format,它给了我 3.9.0 版。 然后我将 Xcode 插件设置为“使用系统 clang-format”,我得到了想要的结果,所以我想它一定是一个错误。
在 ubuntu 16.04 和 clang-format 3.8 上你的情况对我来说似乎很好
安装 clang-format-3.8
sudo apt-get install clang-format-3.8
在~/.vimrc
map <F3> :pyf /usr/share/vim/addons/syntax/clang-format-3.8.py<cr> imap <F3> <Co>:pyf /usr/share/vim/addons/syntax/clang-format-3.8.py<cr>
使用@OP 的 .clang 格式和源代码
mkdir ~/test vim ~/test/.clang-format vim ~/test/test.cpp
在vim中格式化test.cpp(使用F3),然后结果:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree, int inSomeIndex, std::shared_ptr<Something> inSomething, int x, int y );
我认为这是由ColumnLimit
引起的。 我认为这是一个错误......我有这个问题,我通过改变这个变量解决了它。 尝试设置:
ColumnLimit: 0
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree, int inSomeIndex, std::shared_ptr<Something>" has 117+-3 chars in dependence of computing invisible chars.
的长度bool importSomethingIn( const boost::property_tree::ptree& inBoostTree, int inSomeIndex, std::shared_ptr<Something>" has 117+-3 chars in dependence of computing invisible chars.
是 117+-3 ColumnLimit: 120
已设置,这是可能的原因之一,我认为,它已被削减。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.