1
0
mirror of https://github.com/gryf/tagbar.git synced 2025-12-17 19:40:27 +01:00

Make keybindings configurable, closes #159

This commit is contained in:
Jan Larres
2013-08-22 17:38:31 +12:00
parent 7ec151a7a9
commit c37d783d4f
3 changed files with 107 additions and 46 deletions

View File

@@ -44,7 +44,7 @@ endif
function! s:init_var(var, value) abort
if !exists('g:tagbar_' . a:var)
execute 'let g:tagbar_' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", 'g') . "'"
execute 'let g:tagbar_' . a:var . ' = ' . string(a:value)
endif
endfunction
@@ -67,6 +67,7 @@ let s:options = [
for [opt, val] in s:options
call s:init_var(opt, val)
endfor
unlet s:options
if !exists('g:tagbar_iconchars')
if has('multi_byte') && has('unix') && &encoding == 'utf-8' &&
@@ -77,6 +78,31 @@ if !exists('g:tagbar_iconchars')
endif
endif
let s:keymaps = [
\ ['jump', '<CR>'],
\ ['preview', 'p'],
\ ['nexttag', '<C-N>'],
\ ['prevtag', '<C-P>'],
\ ['showproto', '<Space>'],
\
\ ['openfold', ['+', '<kPlus>', 'zo']],
\ ['closefold', ['-', '<kMinus>', 'zc']],
\ ['togglefold', ['o', 'za']],
\ ['openallfolds', ['*', '<kMultiply>', 'zR']],
\ ['closeallfolds', ['=', 'zM']],
\
\ ['togglesort', 's'],
\ ['zoomwin', 'x'],
\ ['close', 'q'],
\ ['help', '<F1>'],
\ ]
for [map, key] in s:keymaps
call s:init_var('map_' . map, key)
unlet key
endfor
unlet s:keymaps
augroup TagbarSession
autocmd!
autocmd SessionLoadPost * nested call tagbar#RestoreSession()