Ignore useless use of on-demand loading (#786)
This commit is contained in:
parent
8ed2617ba0
commit
7f8fdd0444
3 changed files with 11 additions and 2 deletions
10
plug.vim
10
plug.vim
|
@ -193,6 +193,14 @@ function! s:ask_no_interrupt(...)
|
|||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:lazy(plug, opt)
|
||||
return has_key(a:plug, a:opt) &&
|
||||
\ (empty(s:to_a(a:plug[a:opt])) ||
|
||||
\ !isdirectory(a:plug.dir) ||
|
||||
\ len(s:glob(s:rtp(a:plug), 'plugin')) ||
|
||||
\ len(s:glob(s:rtp(a:plug), 'after/plugin')))
|
||||
endfunction
|
||||
|
||||
function! plug#end()
|
||||
if !exists('g:plugs')
|
||||
return s:err('Call plug#begin() first')
|
||||
|
@ -214,7 +222,7 @@ function! plug#end()
|
|||
continue
|
||||
endif
|
||||
let plug = g:plugs[name]
|
||||
if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
|
||||
if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for')
|
||||
let s:loaded[name] = 1
|
||||
continue
|
||||
endif
|
||||
|
|
|
@ -41,6 +41,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
|
|||
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
|
||||
call plug#end()
|
||||
PlugInstall | q
|
||||
call mkdir(g:plugs['vim-emoji'].dir.'/after/plugin', 'p')
|
||||
|
||||
Assert exists(':EmojiCommand'), 'EmojiCommand not defined'
|
||||
Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined'
|
||||
|
|
2
test/run
2
test/run
|
@ -87,7 +87,7 @@ DOC
|
|||
make_dirs z2/ z2
|
||||
|
||||
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
|
||||
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
|
||||
mkdir -p "$PLUG_FIXTURES"/ftplugin-msg/{plugin,ftplugin}
|
||||
echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
|
||||
echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
|
||||
|
||||
|
|
Loading…
Reference in a new issue