Llvm 多种语言的clang格式多基样式
在Llvm 多种语言的clang格式多基样式,llvm,clang-format,Llvm,Clang Format,在clangformat中,您可以通过创建名为.clangformat的文件来设置clangformat的默认选项 文档中提供的语法如下: --- # We'll use defaults from the LLVM style, but with 4 columns indentation. BasedOnStyle: LLVM IndentWidth: 4 --- Language: Cpp # Force pointers to the type for C++. DerivePointe
clangformat
中,您可以通过创建名为.clangformat
的文件来设置clangformat
的默认选项
文档中提供的语法如下:
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Left
---
Language: JavaScript
# Use 100 columns for JS.
ColumnLimit: 100
---
Language: Proto
# Don't format .proto files.
DisableFormat: true
---
Language: CSharp
# Use 100 columns for C#.
ColumnLimit: 100
...
但是,当我尝试将BasedOnStyle
变量应用于单个语言时,如下所示:
Language: C
BasedOnStyle: LLVM
Language: Cpp
BasedOnStyle: LLVM
Language: Java
BasedOnStyle: Google
Language: JavaScript
BasedOnStyle: Google
它似乎不起作用
问题是
是否可以对不同的语言使用不同的BasedOnStyle
如果是,我该怎么做
似乎BasedOnStyle
只定义语言的样式:Cpp
这可以通过以下命令显示:
clang-format -style=llvm -dump-config
上面的命令输出成功的样式语言:Cpp
。BasedOnStyle
的其他值也是如此
因此,如果BasedOnStyle
由Language
键和Cpp
以外的值继承,则clangformat
将失败
因此,不可能将不同的预定义样式(LLVM
,Google
等)应用于不同的语言。似乎BasedOnStyle
只定义了语言:Cpp
的样式
这可以通过以下命令显示:
clang-format -style=llvm -dump-config
上面的命令输出成功的样式语言:Cpp
。BasedOnStyle
的其他值也是如此
因此,如果BasedOnStyle
由Language
键和Cpp
以外的值继承,则clangformat
将失败
因此,不可能对不同的语言应用不同的预定义样式(LLVM
,Google
,等等)