Extend plug#load to process a list of names instead of varargs
Allows `call plug#load(keys(g:plugs))` for manually loading all plugins at once. Close #638.
This commit is contained in:
parent
06992bcfb9
commit
802b100415
5
plug.vim
5
plug.vim
|
@ -442,12 +442,13 @@ function! plug#load(...)
|
||||||
if !exists('g:plugs')
|
if !exists('g:plugs')
|
||||||
return s:err('plug#begin was not called')
|
return s:err('plug#begin was not called')
|
||||||
endif
|
endif
|
||||||
let unknowns = filter(copy(a:000), '!has_key(g:plugs, v:val)')
|
let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000
|
||||||
|
let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)')
|
||||||
if !empty(unknowns)
|
if !empty(unknowns)
|
||||||
let s = len(unknowns) > 1 ? 's' : ''
|
let s = len(unknowns) > 1 ? 's' : ''
|
||||||
return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', ')))
|
return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', ')))
|
||||||
end
|
end
|
||||||
let unloaded = filter(copy(a:000), '!get(s:loaded, v:val, 0)')
|
let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)')
|
||||||
if !empty(unloaded)
|
if !empty(unloaded)
|
||||||
for name in unloaded
|
for name in unloaded
|
||||||
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
|
|
|
@ -1141,6 +1141,12 @@ Execute (plug#load - invalid arguments):
|
||||||
AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
|
AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
|
||||||
AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
|
AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
|
||||||
|
|
||||||
|
Execute (plug#load - list argument (#638)):
|
||||||
|
redir => out
|
||||||
|
call plug#load(keys(g:plugs))
|
||||||
|
redir END
|
||||||
|
AssertEqual '', out
|
||||||
|
|
||||||
Execute (on: []):
|
Execute (on: []):
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug 'junegunn/rust.vim', { 'on': [] }
|
Plug 'junegunn/rust.vim', { 'on': [] }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user