Skip to content

Commit 7f8fdd0

Browse files
authored
Ignore useless use of on-demand loading (#786)
1 parent 8ed2617 commit 7f8fdd0

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

plug.vim

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ function! s:ask_no_interrupt(...)
193193
endtry
194194
endfunction
195195

196+
function! s:lazy(plug, opt)
197+
return has_key(a:plug, a:opt) &&
198+
\ (empty(s:to_a(a:plug[a:opt])) ||
199+
\ !isdirectory(a:plug.dir) ||
200+
\ len(s:glob(s:rtp(a:plug), 'plugin')) ||
201+
\ len(s:glob(s:rtp(a:plug), 'after/plugin')))
202+
endfunction
203+
196204
function! plug#end()
197205
if !exists('g:plugs')
198206
return s:err('Call plug#begin() first')
@@ -214,7 +222,7 @@ function! plug#end()
214222
continue
215223
endif
216224
let plug = g:plugs[name]
217-
if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for')
225+
if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for')
218226
let s:loaded[name] = 1
219227
continue
220228
endif

test/regressions.vader

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Execute (#130 Proper cleanup of on-demand loading triggers):
4141
Plug 'junegunn/vim-emoji', { 'on': ['EmojiCommand', 'EmojiCommand2', '<Plug>(EmojiMapping)'] }
4242
call plug#end()
4343
PlugInstall | q
44+
call mkdir(g:plugs['vim-emoji'].dir.'/after/plugin', 'p')
4445

4546
Assert exists(':EmojiCommand'), 'EmojiCommand not defined'
4647
Assert exists(':EmojiCommand2'), 'EmojiCommand2 not defined'

test/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ DOC
8787
make_dirs z2/ z2
8888

8989
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
90-
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
90+
mkdir -p "$PLUG_FIXTURES"/ftplugin-msg/{plugin,ftplugin}
9191
echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
9292
echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
9393

0 commit comments

Comments
 (0)