rhysd/vim-clang-format

How to configure nested flags?

pmalek opened this issue · 2 comments

Let's say I would like to configure BraceWrapping which as of documentation (http://clang.llvm.org/docs/ClangFormatStyleOptions.html) says is of type BraceWrappingFlags.

This setting will be taken into consideration when BreakBeforeBraces is set to BS_Custom.

I know how to use one-dimensional (as below) simple format but I have tried already several options how to use this nested style and I frankly do not know how to do that.

My exemplar format settings:

let g:clang_format#style_options = { 
            \ "AccessModifierOffset" : -2, 
            \ "AlignTrailingComments" : "true",
            \ "AlignAfterOpenBracket" : "true",
            \ "AlwaysBreakTemplateDeclarations" : "true",
            \ "AllowShortFunctionsOnASingleLine" : "Inline",
            \ "BreakBeforeBraces" : "Allman",
            \ "BinPackParameters" : "false",
            \ "Standard" : "C++11",                                                                                                                                                                                                            
            \ "ColumnLimit" : 100,
            \ "UseTab" : "Never" }
rhysd commented

You can use nested dictionary as below:

let g:clang_format#filetype_style_options = {
            \ 'javascript' : {},
            \ 'cpp' : {
            \     'AccessModifierOffset' : -4,
            \     'AlwaysBreakTemplateDeclarations' : 'true',
            \     'Standard' : 'C++11',
            \     'BreakBeforeBraces' : '"BS_Custom"',
            \     'BraceWrapping' : {
            \       'AfterFunction' : 'false',
            \       'AfterClass' : 'false',
            \     },
            \   },
            \ }

I copied

let g:clang_format#filetype_style_options = {
            \ 'javascript' : {},
            \ 'cpp' : {
            \     'AccessModifierOffset' : -4,
            \     'AlwaysBreakTemplateDeclarations' : 'true',
            \     'Standard' : 'C++11',
            \     'BreakBeforeBraces' : '"BS_Custom"',
            \     'BraceWrapping' : {
            \       'AfterFunction' : 'false',
            \       'AfterClass' : 'false',
            \     },
            \   },
            \ }

but I still got the same wrong