Giter Site home page Giter Site logo

Comments (5)

Kypert avatar Kypert commented on May 23, 2024 1

Would you mind share the exact style_options? Did you make sure that you used Custom with upper-case C?

from vim-clang-format.

Kypert avatar Kypert commented on May 23, 2024

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.

irreallich avatar irreallich commented on May 23, 2024

@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.

irreallich avatar irreallich commented on May 23, 2024

@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.

Kypert avatar Kypert commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.