From aca17edd1c3d37f3287c9a42f81b198f389e4eed Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 12 Feb 2014 03:11:13 +0900 Subject: [PATCH] On-demand loading for imaps of mappings --- plug.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plug.vim b/plug.vim index e3df7f7..9e48053 100644 --- a/plug.vim +++ b/plug.vim @@ -115,9 +115,12 @@ function! plug#end() let commands = type(plug.on) == 1 ? [plug.on] : plug.on for cmd in commands if cmd =~ '^.\+' - if empty(mapcheck(cmd)) - execute printf( - \ "noremap %s :call lod_map(%s, %s)", cmd, string(cmd), string(plug)) + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + for [mode, prefix] in [['i', ""], ['', '']] + execute printf( + \ "%snoremap %s %s:call lod_map(%s, %s)", + \ mode, cmd, prefix, string(cmd), string(plug)) + endfor endif elseif !exists(':'.cmd) execute printf( @@ -166,6 +169,7 @@ endfunction function! s:lod_map(map, plug) execute 'unmap '.a:map + execute 'iunmap '.a:map call s:lod(a:plug) let extra = '' while 1