diff --git a/autoload/vimwiki/u.vim b/autoload/vimwiki/u.vim index f6adc4e..0f072a0 100644 --- 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() check is skipped. " this can be used to map different keys to the same definition +" if a:1==2 then the mapping is not specific " This function maps a key sequence to a command using the arguments " described above. If there is already a mapping to the 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 = ' ' + 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 index 8657e4a..b9e42a0 100644 --- 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', 'VimwikiIndex') - call vimwiki#u#map_key('n', s:map_prefix . 't', 'VimwikiTabIndex') - call vimwiki#u#map_key('n', s:map_prefix . 's', 'VimwikiUISelect') - call vimwiki#u#map_key('n', s:map_prefix . 'i', 'VimwikiDiaryIndex') - call vimwiki#u#map_key('n', s:map_prefix . 'i', 'VimwikiDiaryGenerateLinks') - call vimwiki#u#map_key('n', s:map_prefix . 'w', 'VimwikiMakeDiaryNote') - call vimwiki#u#map_key('n', s:map_prefix . 't', 'VimwikiTabMakeDiaryNote') - call vimwiki#u#map_key('n', s:map_prefix . 'y', 'VimwikiMakeYesterdayDiaryNote') - call vimwiki#u#map_key('n', s:map_prefix . 'm', 'VimwikiMakeTomorrowDiaryNote') + call vimwiki#u#map_key('n', s:map_prefix . 'w', 'VimwikiIndex', 2) + call vimwiki#u#map_key('n', s:map_prefix . 't', 'VimwikiTabIndex', 2) + call vimwiki#u#map_key('n', s:map_prefix . 's', 'VimwikiUISelect', 2) + call vimwiki#u#map_key('n', s:map_prefix . 'i', 'VimwikiDiaryIndex', 2) + call vimwiki#u#map_key('n', s:map_prefix . 'i', 'VimwikiDiaryGenerateLinks', 2) + call vimwiki#u#map_key('n', s:map_prefix . 'w', 'VimwikiMakeDiaryNote', 2) + call vimwiki#u#map_key('n', s:map_prefix . 't', 'VimwikiTabMakeDiaryNote', 2) + call vimwiki#u#map_key('n', s:map_prefix . 'y', 'VimwikiMakeYesterdayDiaryNote', 2) + call vimwiki#u#map_key('n', s:map_prefix . 'm', 'VimwikiMakeTomorrowDiaryNote', 2) endif