From 91076ee9d5c25b024ed9c9fc5dae09a99b98a684 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sat, 19 Feb 2011 17:12:47 +1300 Subject: [PATCH] Let kind2scope and scope2kind be auto-generated from each other in user-defs --- plugin/tagbar.vim | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 35e8c76..ec89354 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -742,9 +742,25 @@ function! s:GetUserTypeDefs() call filter(deflist, 'v:val =~ "^tagbar_type_"') let defdict = {} - for def in deflist - let type = substitute(def, '^tagbar_type_', '', '') - execute 'let defdict["' . type . '"] = g:' . def + for defstr in deflist + let type = substitute(defstr, '^tagbar_type_', '', '') + execute 'let defdict["' . type . '"] = g:' . defstr + endfor + + " If the user only specified one of kind2scope and scope2kind use it to + " generate the other one + for def in values(defdict) + if has_key(def, 'kind2scope') && !has_key(def, 'scope2kind') + let def.scope2kind = {} + for [key, value] in items(def.kind2scope) + let def.scope2kind[value] = key + endfor + elseif has_key(def, 'scope2kind') && !has_key(def, 'kind2scope') + let def.kind2scope = {} + for [key, value] in items(def.scope2kind) + let def.kind2scope[value] = key + endfor + endif endfor return defdict