diff --git a/autoload/vimwiki/u.vim b/autoload/vimwiki/u.vim index 0f072a0..a51d13c 100644 --- a/autoload/vimwiki/u.vim +++ b/autoload/vimwiki/u.vim @@ -76,24 +76,20 @@ endif " 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. +" if a:1==2 then the mapping is not specific i.e. it is global function vimwiki#u#map_key(mode, key, plug, ...) 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 ' . l:bo . a:key . ' ' . a:plug - endif - else + " global mappings if !hasmapto(a:plug) && maparg(a:key, a:mode) ==# '' - exe a:mode . 'map ' . l:bo . a:key . ' ' . a:plug + exe a:mode . 'map ' . a:key . ' ' . a:plug + endif + elseif a:0 && a:1 == 1 + " vimwiki buffer mappings, repeat mapping to the same definition + exe a:mode . 'map ' . a:key . ' ' . a:plug + else + " vimwiki buffer mappings + if !hasmapto(a:plug) + exe a:mode . 'map ' . a:key . ' ' . a:plug endif endif endfunction diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 2ae77e1..64b4f4a 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -487,20 +487,20 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists) " change symbol for bulleted lists for s:char in vimwiki#vars#get_syntaxlocal('bullet_types') - if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'') && maparg('gl'.s:char, 'n') ==# '' + if !hasmapto(':VimwikiChangeSymbolTo '.s:char.'') exe 'noremap gl'.s:char.' :VimwikiChangeSymbolTo '.s:char.'' endif - if !hasmapto(':VimwikiChangeSymbolInListTo '.s:char.'') && maparg('gL'.s:char, 'n') ==# '' + if !hasmapto(':VimwikiChangeSymbolInListTo '.s:char.'') exe 'noremap gL'.s:char.' :VimwikiChangeSymbolInListTo '.s:char.'' endif endfor " change symbol for numbered lists for s:typ in vimwiki#vars#get_syntaxlocal('number_types') - if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'') && maparg('gl'.s:typ, 'n') ==# '' + if !hasmapto(':VimwikiChangeSymbolTo '.s:typ.'') exe 'noremap gl'.s:typ[0].' :VimwikiChangeSymbolTo '.s:typ.'' endif - if !hasmapto(':VimwikiChangeSymbolInListTo '.s:typ.'') && maparg('gL'.s:typ, 'n') ==# '' + if !hasmapto(':VimwikiChangeSymbolInListTo '.s:typ.'') exe 'noremap gL'.s:typ[0].' :VimwikiChangeSymbolInListTo '.s:typ.'' endif endfor @@ -510,16 +510,12 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists) " Valid only if langmap is a comma separated pairs of chars let s:l_o = matchstr(&langmap, '\C,\zs.\zeo,') if s:l_o - if maparg(s:l_o, 'n') ==# '' - exe 'nnoremap '.s:l_o.' :call vimwiki#lst#kbd_o()a' - endif + exe 'nnoremap '.s:l_o.' :call vimwiki#lst#kbd_o()a' endif let s:l_O = matchstr(&langmap, '\C,\zs.\zeO,') if s:l_O - if maparg(s:l_O, 'n') ==# '' - exe 'nnoremap '.s:l_O.' :call vimwiki#lst#kbd_O()a' - endif + exe 'nnoremap '.s:l_O.' :call vimwiki#lst#kbd_O()a' endif endif endif @@ -538,12 +534,8 @@ endfunction " insert mode table mappings if str2nr(vimwiki#vars#get_global('key_mappings').table_mappings) - if maparg('', 'i') ==# '' - inoremap vimwiki#tbl#kbd_tab() - endif - if maparg('', 'i') ==# '' - inoremap vimwiki#tbl#kbd_shift_tab() - endif + inoremap vimwiki#tbl#kbd_tab() + inoremap vimwiki#tbl#kbd_shift_tab() endif " table formatting definitions