mirror of
https://github.com/preservim/tagbar.git
synced 2025-02-13 03:13:17 +08:00
Let kind2scope and scope2kind be auto-generated from each other in user-defs
This commit is contained in:
parent
1b5f3a4e84
commit
91076ee9d5
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user