[英]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.