mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-20 02:56:10 -07:00
Fix <Plug>-based on-demand-loading on visual mode
This commit is contained in:
parent
7f1ec7b12b
commit
f1c5157e35
11
plug.vim
11
plug.vim
@ -141,10 +141,11 @@ function! plug#end()
|
|||||||
for cmd in commands
|
for cmd in commands
|
||||||
if cmd =~ '^<Plug>.\+'
|
if cmd =~ '^<Plug>.\+'
|
||||||
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
|
if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i'))
|
||||||
for [mode, prefix] in [['i', "<C-O>"], ['', '']]
|
for [mode, map_prefix, key_prefix] in
|
||||||
|
\ [['i', "<C-O>", ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
|
||||||
execute printf(
|
execute printf(
|
||||||
\ "%snoremap <silent> %s %s:call <SID>lod_map(%s, %s)<CR>",
|
\ "%snoremap <silent> %s %s:call <SID>lod_map(%s, %s, '%s')<CR>",
|
||||||
\ mode, cmd, prefix, string(cmd), string(plug))
|
\ mode, cmd, map_prefix, string(cmd), string(plug), key_prefix)
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
elseif !exists(':'.cmd)
|
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)
|
execute printf("%s%s%s %s", (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_map(map, plug)
|
function! s:lod_map(map, plug, prefix)
|
||||||
execute 'unmap '.a:map
|
execute 'unmap '.a:map
|
||||||
execute 'iunmap '.a:map
|
execute 'iunmap '.a:map
|
||||||
call s:lod(a:plug, ['plugin', 'ftdetect', 'after'])
|
call s:lod(a:plug, ['plugin', 'ftdetect', 'after'])
|
||||||
@ -233,7 +234,7 @@ function! s:lod_map(map, plug)
|
|||||||
endif
|
endif
|
||||||
let extra .= nr2char(c)
|
let extra .= nr2char(c)
|
||||||
endwhile
|
endwhile
|
||||||
call feedkeys(substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
|
call feedkeys(a:prefix . substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:add(...)
|
function! s:add(...)
|
||||||
|
Loading…
Reference in New Issue
Block a user