Do not trigger BufRead if not necessary

Close #490
This commit is contained in:
Junegunn Choi 2016-05-23 22:22:43 +09:00
parent eb25f320a0
commit 765a2d21d3
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -402,6 +402,17 @@ function! s:doautocmd(...)
endif
endfunction
function! s:dobufread(names)
for name in a:names
let path = s:rtp(g:plugs[name]).'/**'
for dir in ['ftdetect', 'ftplugin']
if len(finddir(dir, path))
return s:doautocmd('BufRead')
endif
endfor
endfor
endfunction
function! plug#load(...)
if a:0 == 0
return s:err('Argument missing: plugin name(s) required')
@ -417,7 +428,7 @@ function! plug#load(...)
for name in a:000
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
endfor
call s:doautocmd('BufRead')
call s:dobufread(a:000)
return 1
endfunction
@ -467,13 +478,13 @@ endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:doautocmd('BufRead')
call s:dobufread(a:names)
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, names, prefix)
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
call s:doautocmd('BufRead')
call s:dobufread(a:names)
let extra = ''
while 1
let c = getchar(0)