Comments (5)
Would you mind share the exact style_options? Did you make sure that you used Custom
with upper-case C
?
from vim-clang-format.
It seems like the continuation of the macro is treated as a new indentation level by clang-format, like adding another pair of { } would too. But ultimately, not much that this plugin can do for you in this scenario, I think.
from vim-clang-format.
@Kypert
thanks for your reply, I agree with you , it is the problem about how to use clang-format.
but in the plugin,
'BreakBeforeBraces' : 'Allman',
can be used to set up for the braces, and there are lots of sub settings after it if I set BreakBeforeBraces as 'custom', but I try to do so, the plugin report error
from vim-clang-format.
@Kypert
I am very sorry for the late reply now
I share two settings, the original issue can be reproduced both of them
the following is my settings now, BreakBeforeBraces is 'Allman'
25 let g:clang_format#code_style='llvm'
26 let g:clang_format#style_options = {}
27 let g:clang_format#style_options.TabWidth = 4
28 let g:clang_format#style_options.UseTab = 'Never'
29 let g:clang_format#style_options.IndentWidth = 4
30 let g:clang_format#style_options.IndentPPDirectives = 'BeforeHash'
31 let g:clang_format#style_options.AccessModifierOffset = -4
32 let g:clang_format#style_options.BreakBeforeBraces = 'Allman'
33 let g:clang_format#style_options.AllowShortIfStatementsOnASingleLine = 'false'
34 let g:clang_format#style_options.IndentCaseLabels = 'true'
35 let g:clang_format#style_options.AllowShortFunctionsOnASingleLine = 'false'
36 let g:clang_format#style_options.AlignConsecutiveDeclarations = 'true'
37 let g:clang_format#style_options.AlignConsecutiveMacros = 'true'
38 let g:clang_format#style_options.AlignTrailingComments = 'true'
39 let g:clang_format#style_options.BinPackArguments = 'false'
40 let g:clang_format#style_options.BinPackParameters = 'false'
41 let g:clang_format#style_options.ColumnLimit = '80'
42 let g:clang_format#style_options.Standard = 'C++11'
43 let g:clang_format#style_options.AlignEscapedNewlines = 'Right'
44 let g:clang_format#style_options.AlignConsecutiveAssignments = 'true'
the following is my test settings,
47 function! Vbackup_func()
48 let g:clang_format#code_style='llvm'
49 let g:clang_format#style_options = {
50 \ "TabWidth" : 4,
51 \ "UseTab" : 'Never',
52 \ "IndentWidth" : 4,
53 \ "IndentPPDirectives" : 'BeforeHash',
54 \ "AccessModifierOffset" : -4,
55 \ "AllowShortIfStatementsOnASingleLine" : 'false',
56 \ "IndentCaseLabels" : 'true',
57 \ "AlignConsecutiveDeclarations" : 'true',
58 \ "AlignConsecutiveMacros" : 'true',
59 \ "AlignTrailingComments" : 'true',
60 \ "BinPackArguments" : 'false' ,
61 \ "BinPackParameters" : 'false',
62 \ "ColumnLimit" : 80,
63 \ "Standard" : 'C++11',
64 \ "AlignEscapedNewlines" : 'Right',
65 \ "AlignConsecutiveAssignments" : 'true',
66 \ "AlignAfterOpenBracket" : 'DontAlign',
67 \ "BreakBeforeBraces" : 'Custom',
68 \ }
69
70 "\ "PPDirectiveIndentStyle" : 'None',
71
72 "let g:clang_format#style_options.BreakBeforeBraces = 'Allman'
73 if g:clang_format#style_options.BreakBeforeBraces == 'Custom'
74 ¦ "手动设置大括号之前的换行
75 ¦ let g:clang_format#style_options.BraceWrapping = {
76 ¦ \ "AfterClass" : 'true',
77 ¦ \ "AfterControlStatement" : 'true',
78 ¦ \ "AfterEnum" : 'true',
79 ¦ \ "AfterFunction" : 'true',
80 ¦ \ "AfterNamespace" : 'true',
81 ¦ \ "AfterObjCDeclaration" : 'true',
82 ¦ \ "AfterStruct" : 'true',
83 ¦ \ "AfterUnion" : 'true',
84 ¦ \ "AfterExternBlock" : 'true',
85 ¦ \ "BeforeCatch" : 'true',
86 ¦ \ "BeforeElse" : 'true',
87 ¦ \ "IndentBraces" : 'false',
88 ¦ \ "SplitEmptyFunction" : 'false',
89 ¦ \ "SplitEmptyRecord" : 'false',
90 ¦ \ "SplitEmptyNamespace" : 'false',
91 ¦ \ }
92 endif
93 endfunction
from vim-clang-format.
Sorry, i missed this reply. Yearly update :)
From my understanding, the plugin error
was when you tried to set the different BraceWrapping options, which is nested - but it looks like you have figured that part out.
When it comes to the indent after the escaped-newline in a macro, I think you have to turn to clang-format and request this option. I too am unable to find the suitable option knob for that in current clang-format version (was checking clang11).
from vim-clang-format.
Related Issues (20)
- How to write style_option??? HOT 8
- Can vim-clang-format correctly indent as I write code? HOT 2
- last edit mark is tampered after ClangFormat HOT 3
- Overriding an option from .clang-format HOT 1
- ClangFormatAutoEnable to only format surrounding unsaved buffer
- Error when running ClangFormat in neovim HOT 3
- Working with CUDA
- :ClangFormat kills vi HOT 1
- Recommend installation command
- There's a problem with formatting HOT 1
- selected code formatting in visual mode isnt working. HOT 1
- How can I disable auto_format_on_insert_leave in some special case
- stderr clang-format output got pasted into the source file
- Useful information
- Doesn't work on AstroNeoVim
- Failed to format cpp HOT 16
- Support vala langauge? HOT 3
- Bug: undo after ClangFormat does undo twice, erasing previous changes HOT 9
- Detect if file is formattable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-clang-format.