From b6f47e40202a8f0cecee3d8bed1c385e682034b6 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Fri, 5 Apr 2013 11:57:57 +1300 Subject: [PATCH] Simplify getusertypes() function --- autoload/tagbar.vim | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index be64274..b4ce7a7 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3596,21 +3596,15 @@ endfunction " tagbar#getusertypes() {{{2 function! tagbar#getusertypes() abort - redir => defs - silent execute 'let g:' - redir END + let userdefs = filter(copy(g:), 'v:key =~ "^tagbar_type_"') - let deflist = split(defs, '\n') - call map(deflist, 'substitute(v:val, ''^\S\+\zs.*'', "", "")') - call filter(deflist, 'v:val =~ "^tagbar_type_"') - - let defdict = {} - for defstr in deflist - let type = substitute(defstr, '^tagbar_type_', '', '') - let defdict[type] = g:{defstr} + let typedict = {} + for [key, val] in items(userdefs) + let type = substitute(key, '^tagbar_type_', '', '') + let typedict[type] = val endfor - return defdict + return typedict endfunction " tagbar#autoopen() {{{2