Skip to content

Commit

Permalink
Use runtime only when the file is not found in the plugin directory (#…
Browse files Browse the repository at this point in the history
…434)

There can be multiple files that matches the pattern (e.g.
syntax/foo.vim) in &runtimepath.
  • Loading branch information
junegunn committed Mar 3, 2016
1 parent b082ae3 commit 16902f9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,14 @@ function! s:to_s(v)
endfunction

function! s:source(from, ...)
let found = 0
for pattern in a:000
for vim in s:lines(globpath(a:from, pattern))
execute 'source' s:esc(vim)
let found = 1
endfor
endfor
return found
endfunction

function! s:assoc(dict, key, val)
Expand Down Expand Up @@ -426,7 +429,9 @@ function! s:lod(names, types, ...)
call s:source(rtp, dir.'/**/*.vim')
endfor
for pat in a:000
execute 'runtime' pat
if !s:source(rtp, pat)
execute 'runtime' pat
endif
endfor
if exists('#User#'.name)
execute 'doautocmd User' name
Expand Down

2 comments on commit 16902f9

@junegunn
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm still not sure about this. runtime is only required when after/syntax is found, but syntax is not. It's unnecessary if both are not present. But syntax files usually does not progress if b:current_syntax is already set, so maybe it's okay?

@junegunn
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.