Skip to content

Commit 7e172cb

Browse files
committed
Add support for lists and quote values in dict
This adds support for lists in the clang format options dictionary. These are required for some settings such as 'ForEachMacros' and 'IncludeCategories' Also quote values since they will otherwise break if they contain a colon (:)
1 parent 157cfe8 commit 7e172cb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

autoload/clang_format.vim

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set cpo&vim
33

44
let s:on_windows = has('win32') || has('win64')
55
let s:dict_t = type({})
6+
let s:list_t = type([])
67
if exists('v:true')
78
let s:bool_t = type(v:true)
89
else
@@ -44,12 +45,12 @@ endfunction
4445
function! s:create_keyvals(key, val) abort
4546
if type(a:val) == s:dict_t
4647
return a:key . ': {' . s:stringize_options(a:val) . '}'
48+
elseif type(a:val) == s:bool_t
49+
return a:key . (a:val == v:true ? ': true' : ': false')
50+
elseif type(a:val) == s:list_t
51+
return a:key . ': [' . join(a:val,',') . ']'
4752
else
48-
if type(a:val) == s:bool_t
49-
return a:key . (a:val == v:true ? ': true' : ': false')
50-
else
51-
return a:key . ': ' . a:val
52-
endif
53+
return a:key . ': ''' . a:val . ''''
5354
endif
5455
endfunction
5556

0 commit comments

Comments
 (0)