diff --git a/plug.vim b/plug.vim index edeeda6..f7564ea 100644 --- a/plug.vim +++ b/plug.vim @@ -426,7 +426,10 @@ function! s:dobufread(names) let path = s:rtp(g:plugs[name]).'/**' for dir in ['ftdetect', 'ftplugin'] if len(finddir(dir, path)) - return s:doautocmd('BufRead') + if exists('#BufRead') + doautocmd BufRead + endif + return endif endfor endfor diff --git a/test/regressions.vader b/test/regressions.vader index 9c11f65..88a8a4f 100644 --- a/test/regressions.vader +++ b/test/regressions.vader @@ -304,17 +304,19 @@ Execute (#474: Load ftdetect files in filetypedetect augroup): bd ********************************************************************** -Execute (#489 On-demand loading with 'on' option should trigger BufRead autocmd): +Execute (#489/#587 On-demand loading with 'on' option should trigger BufRead autocmd w/o nomodeline): call plug#begin('$PLUG_FIXTURES') Plug 'ftplugin-msg', { 'on': 'XXX' } call plug#end() tabnew a.java + call setline(1, '// vim: set filetype=lava:') redir => out silent! XXX redir END Assert stridx(out, 'ftplugin-java') >= 0 - q + AssertEqual 'lava', &filetype + q! ********************************************************************** Execute (Cursor moved to another window during post-update hook):