On-demand loading for imaps of <Plug> mappings
This commit is contained in:
parent
06ced6b640
commit
aca17edd1c
1 changed files with 7 additions and 3 deletions
10
plug.vim
10
plug.vim
|
@ -115,9 +115,12 @@ function! plug#end()
|
||||||
let commands = type(plug.on) == 1 ? [plug.on] : plug.on
|
let commands = type(plug.on) == 1 ? [plug.on] : plug.on
|
||||||
for cmd in commands
|
for cmd in commands
|
||||||
if cmd =~ '^<Plug>.\+'
|
if cmd =~ '^<Plug>.\+'
|
||||||
if empty(mapcheck(cmd))
|
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
|
||||||
execute printf(
|
for [mode, prefix] in [['i', "<C-O>"], ['', '']]
|
||||||
\ "noremap <silent> %s :call <SID>lod_map(%s, %s)<CR>", cmd, string(cmd), string(plug))
|
execute printf(
|
||||||
|
\ "%snoremap <silent> %s %s:call <SID>lod_map(%s, %s)<CR>",
|
||||||
|
\ mode, cmd, prefix, string(cmd), string(plug))
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
elseif !exists(':'.cmd)
|
elseif !exists(':'.cmd)
|
||||||
execute printf(
|
execute printf(
|
||||||
|
@ -166,6 +169,7 @@ endfunction
|
||||||
|
|
||||||
function! s:lod_map(map, plug)
|
function! s:lod_map(map, plug)
|
||||||
execute 'unmap '.a:map
|
execute 'unmap '.a:map
|
||||||
|
execute 'iunmap '.a:map
|
||||||
call s:lod(a:plug)
|
call s:lod(a:plug)
|
||||||
let extra = ''
|
let extra = ''
|
||||||
while 1
|
while 1
|
||||||
|
|
Loading…
Reference in a new issue