Use runtime only when the file is not found in the plugin directory (#434)

There can be multiple files that matches the pattern (e.g.
syntax/foo.vim) in &runtimepath.
This commit is contained in:
Junegunn Choi 2016-03-03 10:53:34 +09:00
parent b082ae3847
commit 16902f9003

View file

@ -150,11 +150,14 @@ function! s:to_s(v)
endfunction endfunction
function! s:source(from, ...) function! s:source(from, ...)
let found = 0
for pattern in a:000 for pattern in a:000
for vim in s:lines(globpath(a:from, pattern)) for vim in s:lines(globpath(a:from, pattern))
execute 'source' s:esc(vim) execute 'source' s:esc(vim)
let found = 1
endfor endfor
endfor endfor
return found
endfunction endfunction
function! s:assoc(dict, key, val) function! s:assoc(dict, key, val)
@ -426,7 +429,9 @@ function! s:lod(names, types, ...)
call s:source(rtp, dir.'/**/*.vim') call s:source(rtp, dir.'/**/*.vim')
endfor endfor
for pat in a:000 for pat in a:000
if !s:source(rtp, pat)
execute 'runtime' pat execute 'runtime' pat
endif
endfor endfor
if exists('#User#'.name) if exists('#User#'.name)
execute 'doautocmd User' name execute 'doautocmd User' name