vimwiki

Personal wiki for vim
git clone https://github.com/vimwiki/vimwiki.git
Log | Files | Refs | README | LICENSE

commit 50a3c78c87899ba2eacdb4d0798b311df9ccfffd
parent bb15cd1aff432afd7b92cc45115ff55f96f9da83
Author: Rane Brown <rane.brown@gmail.com>
Date:   Mon, 29 Apr 2019 23:03:00 -0600

Ensure key mappings defined in ftplugin are buffer specific.

The changes made with #686 did not ensure the ftplugin mappings were
specific to the buffer containing a Vimwiki file. This resulted in
undesired keymappings with no defined behavior since the <Plug>
definition was buffer specific.

Diffstat:
Mautoload/vimwiki/u.vim | 16++++++++++++----
Mplugin/vimwiki.vim | 18+++++++++---------
2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/autoload/vimwiki/u.vim b/autoload/vimwiki/u.vim @@ -73,19 +73,27 @@ 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 +" a:1 optional argument with the following functionality: +" if a:1==1 then the hasmapto(<Plug>) check is skipped. " this can be used to map different keys to the same <Plug> definition +" if a:1==2 then the mapping is not <buffer> specific " 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 a:0 && a:1 == 2 + let l:bo = '' + else + let l:bo = '<buffer> ' + endif + + if a:0 && a:1 == 1 if maparg(a:key, a:mode) ==# '' - exe a:mode . 'map ' . a:key . ' ' . a:plug + exe a:mode . 'map ' . l:bo . a:key . ' ' . a:plug endif else if !hasmapto(a:plug) && maparg(a:key, a:mode) ==# '' - exe a:mode . 'map ' . a:key . ' ' . a:plug + exe a:mode . 'map ' . l:bo . a:key . ' ' . a:plug endif endif endfunction diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim @@ -399,15 +399,15 @@ let s:map_prefix = vimwiki#vars#get_global('map_prefix') " default global key mappings if str2nr(vimwiki#vars#get_global('key_mappings').global) - call vimwiki#u#map_key('n', s:map_prefix . 'w', '<Plug>VimwikiIndex') - call vimwiki#u#map_key('n', s:map_prefix . 't', '<Plug>VimwikiTabIndex') - call vimwiki#u#map_key('n', s:map_prefix . 's', '<Plug>VimwikiUISelect') - call vimwiki#u#map_key('n', s:map_prefix . 'i', '<Plug>VimwikiDiaryIndex') - call vimwiki#u#map_key('n', s:map_prefix . '<Leader>i', '<Plug>VimwikiDiaryGenerateLinks') - call vimwiki#u#map_key('n', s:map_prefix . '<Leader>w', '<Plug>VimwikiMakeDiaryNote') - call vimwiki#u#map_key('n', s:map_prefix . '<Leader>t', '<Plug>VimwikiTabMakeDiaryNote') - call vimwiki#u#map_key('n', s:map_prefix . '<Leader>y', '<Plug>VimwikiMakeYesterdayDiaryNote') - call vimwiki#u#map_key('n', s:map_prefix . '<Leader>m', '<Plug>VimwikiMakeTomorrowDiaryNote') + call vimwiki#u#map_key('n', s:map_prefix . 'w', '<Plug>VimwikiIndex', 2) + call vimwiki#u#map_key('n', s:map_prefix . 't', '<Plug>VimwikiTabIndex', 2) + call vimwiki#u#map_key('n', s:map_prefix . 's', '<Plug>VimwikiUISelect', 2) + call vimwiki#u#map_key('n', s:map_prefix . 'i', '<Plug>VimwikiDiaryIndex', 2) + call vimwiki#u#map_key('n', s:map_prefix . '<Leader>i', '<Plug>VimwikiDiaryGenerateLinks', 2) + call vimwiki#u#map_key('n', s:map_prefix . '<Leader>w', '<Plug>VimwikiMakeDiaryNote', 2) + call vimwiki#u#map_key('n', s:map_prefix . '<Leader>t', '<Plug>VimwikiTabMakeDiaryNote', 2) + call vimwiki#u#map_key('n', s:map_prefix . '<Leader>y', '<Plug>VimwikiMakeYesterdayDiaryNote', 2) + call vimwiki#u#map_key('n', s:map_prefix . '<Leader>m', '<Plug>VimwikiMakeTomorrowDiaryNote', 2) endif