From f1c5157e35242facfeb9339f9b19279c90a70d68 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 7 Jul 2014 19:06:20 +0900 Subject: [PATCH] Fix -based on-demand-loading on visual mode --- plug.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plug.vim b/plug.vim index 779c2ee..5ae65be 100644 --- a/plug.vim +++ b/plug.vim @@ -141,10 +141,11 @@ function! plug#end() for cmd in commands if cmd =~ '^.\+' if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) - for [mode, prefix] in [['i', ""], ['', '']] + for [mode, map_prefix, key_prefix] in + \ [['i', "", ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] execute printf( - \ "%snoremap %s %s:call lod_map(%s, %s)", - \ mode, cmd, prefix, string(cmd), string(plug)) + \ "%snoremap %s %s:call lod_map(%s, %s, '%s')", + \ mode, cmd, map_prefix, string(cmd), string(plug), key_prefix) endfor endif elseif !exists(':'.cmd) @@ -221,7 +222,7 @@ function! s:lod_cmd(cmd, bang, l1, l2, args, plug) execute printf("%s%s%s %s", (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) endfunction -function! s:lod_map(map, plug) +function! s:lod_map(map, plug, prefix) execute 'unmap '.a:map execute 'iunmap '.a:map call s:lod(a:plug, ['plugin', 'ftdetect', 'after']) @@ -233,7 +234,7 @@ function! s:lod_map(map, plug) endif let extra .= nr2char(c) endwhile - call feedkeys(substitute(a:map, '^', "\", '') . extra) + call feedkeys(a:prefix . substitute(a:map, '^', "\", '') . extra) endfunction function! s:add(...)