Add plug#load() (#48)
This commit is contained in:
parent
d0c94a9b08
commit
f1b8832a13
20
plug.vim
20
plug.vim
|
@ -266,6 +266,26 @@ function! s:reorg_rtp()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
function! plug#load(...)
|
||||
if a:0 == 0
|
||||
return s:err('Argument missing: plugin name(s) required')
|
||||
endif
|
||||
if !exists('g:plugs')
|
||||
return s:err('plug#begin is not called')
|
||||
endif
|
||||
let unknowns = filter(copy(a:000), '!has_key(g:plugs, v:val)')
|
||||
if !empty(unknowns)
|
||||
let s = len(unknowns) > 1 ? 's' : ''
|
||||
return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', ')))
|
||||
end
|
||||
for name in a:000
|
||||
call s:lod(g:plugs[name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
silent! doautocmd BufRead
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:lod(plug, types)
|
||||
let rtp = s:rtp(a:plug)
|
||||
call s:add_rtp(rtp)
|
||||
|
|
|
@ -771,6 +771,32 @@ Execute (plug#helptags):
|
|||
AssertEqual 1, plug#helptags()
|
||||
Assert filereadable(expand('$PWD/xxx/doc/tags'))
|
||||
|
||||
**********************************************************************
|
||||
~ plug#load()
|
||||
**********************************************************************
|
||||
|
||||
Execute (plug#load - invalid arguments):
|
||||
AssertEqual 0, plug#load()
|
||||
AssertEqual 0, plug#load('non-existent-plugin')
|
||||
AssertEqual 0, plug#load('non-existent-plugin', 'another-non-existent-plugin')
|
||||
AssertEqual 1, plug#load('xxx')
|
||||
AssertEqual 0, plug#load('xxx', 'non-existent-plugin')
|
||||
AssertEqual 0, plug#load('non-existent-plugin', 'xxx')
|
||||
|
||||
Execute (plug#load):
|
||||
call plug#begin()
|
||||
Plug 'junegunn/rust.vim', { 'on': [] }
|
||||
call plug#end()
|
||||
PlugInstall
|
||||
q
|
||||
|
||||
setf xxx
|
||||
f test.rs
|
||||
Log &filetype
|
||||
|
||||
AssertEqual 1, plug#load('rust.vim')
|
||||
AssertEqual 'rust', &filetype
|
||||
|
||||
Before:
|
||||
Execute (Cleanup):
|
||||
silent! call system('rm -rf '.temp_plugged)
|
||||
|
|
Loading…
Reference in New Issue
Block a user