From d0c94a9b087545b4514732ab6e2a434011fee4e4 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 9 Aug 2014 12:02:03 +0900 Subject: [PATCH 1/3] Add plug#helptags() --- plug.vim | 8 ++++++-- test/run | 4 ++++ test/workflow.vader | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 3e56bd0..d011ed2 100644 --- a/plug.vim +++ b/plug.vim @@ -369,13 +369,17 @@ function! s:update(force, ...) call s:update_impl(1, a:force, a:000) endfunction -function! s:helptags() +function! plug#helptags() + if !exists('g:plugs') + return s:err('plug#begin is not called') + endif for spec in values(g:plugs) let docd = join([spec.dir, 'doc'], '/') if isdirectory(docd) silent! execute 'helptags '. s:esc(docd) endif endfor + return 1 endfunction function! s:syntax() @@ -508,7 +512,7 @@ endfunction function! s:finish(pull) call append(3, '- Finishing ... ') redraw - call s:helptags() + call plug#helptags() call plug#end() call setline(4, getline(4) . 'Done!') normal! gg diff --git a/test/run b/test/run index 82af603..33f0dea 100755 --- a/test/run +++ b/test/run @@ -30,6 +30,10 @@ EOF make_dirs xxx/ make_dirs xxx/after +mkdir xxx/doc +cat > xxx/doc/xxx.txt << DOC +hello *xxx* +DOC cat > /tmp/mini-vimrc << VIMRC set rtp+=vader.vim diff --git a/test/workflow.vader b/test/workflow.vader index 849cb7d..2a5534a 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -761,6 +761,16 @@ Execute (Filetype-based on-demand loading): setf xxx AssertEqual ['/ftdetect', 'after/ftdetect', '/plugin', 'after/plugin', '/ftplugin', 'after/ftplugin', '/indent', 'after/indent', '/syntax', 'after/syntax'], g:xxx +********************************************************************** +~ plug#helptags() +********************************************************************** + +Execute (plug#helptags): + silent! call delete(expand('$PWD/xxx/doc/tags')) + Assert !filereadable(expand('$PWD/xxx/doc/tags')) + AssertEqual 1, plug#helptags() + Assert filereadable(expand('$PWD/xxx/doc/tags')) + Before: Execute (Cleanup): silent! call system('rm -rf '.temp_plugged) From f1b8832a13666d7e6e715901945ad6163952a41d Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 9 Aug 2014 12:59:04 +0900 Subject: [PATCH 2/3] Add plug#load() (#48) --- plug.vim | 20 ++++++++++++++++++++ test/workflow.vader | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/plug.vim b/plug.vim index d011ed2..8756be4 100644 --- a/plug.vim +++ b/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) diff --git a/test/workflow.vader b/test/workflow.vader index 2a5534a..3350618 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -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) From e6cba2899794f53fd0a40bd547f3e22253b43efb Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 9 Aug 2014 13:11:41 +0900 Subject: [PATCH 3/3] Fix error messages --- plug.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 8756be4..1e44c27 100644 --- a/plug.vim +++ b/plug.vim @@ -271,7 +271,7 @@ function! plug#load(...) return s:err('Argument missing: plugin name(s) required') endif if !exists('g:plugs') - return s:err('plug#begin is not called') + return s:err('plug#begin was not called') endif let unknowns = filter(copy(a:000), '!has_key(g:plugs, v:val)') if !empty(unknowns) @@ -391,7 +391,7 @@ endfunction function! plug#helptags() if !exists('g:plugs') - return s:err('plug#begin is not called') + return s:err('plug#begin was not called') endif for spec in values(g:plugs) let docd = join([spec.dir, 'doc'], '/')