New option g:vimwiki_key_mappings to enable/disable key mappings.

All key mappings have the option of being disabled but the <Plug>
definitions are still available for user customization. Key sequences
are no longer overwritten if a mapping already exists. Fixes #671,
fixes #425.
This commit is contained in:
Rane Brown
2019-04-26 21:17:35 -06:00
parent e84dcbfa25
commit 4106cb7bc7
5 changed files with 532 additions and 414 deletions

View File

@ -70,3 +70,22 @@ else
endfunc
endif
" a:mode single character indicating the mode as defined by :h maparg
" a:key the key sequence to map
" a:plug the plug command the key sequence should be mapped to
" a:1 optional argument to override the uniqueness checks
" this can be used to map different keys to the same <Plug> definition
" This function maps a key sequence to a <Plug> command using the arguments
" described above. If there is already a mapping to the <Plug> command or
" the assigned keys are already mapped then nothing is done.
function vimwiki#u#map_key(mode, key, plug, ...)
if a:0 > 0 && a:1 == 1
if maparg(a:key, a:mode) ==# ''
exe a:mode . 'map ' . a:key . ' ' . a:plug
endif
else
if !hasmapto(a:plug) && maparg(a:key, a:mode) ==# ''
exe a:mode . 'map ' . a:key . ' ' . a:plug
endif
endif
endfunction