4 Commits
0.6.0 ... 0.6.1

Author SHA1 Message Date
Junegunn Choi
425ef39db2 Fix #114 - &rtp should not contain empty path 2014-10-22 13:36:57 +09:00
Junegunn Choi
bd2cb9d2de Install frozen plugin if it's not found (#113) 2014-10-22 13:05:10 +09:00
Junegunn Choi
0263370bd1 Fix #112: Do not suppress messages from ftplugin 2014-10-19 14:45:19 +09:00
Junegunn Choi
4b3fbd1592 Workaround for PlugUpgrade error on Neovim (#111) 2014-10-18 11:26:05 +09:00
6 changed files with 125 additions and 52 deletions

View File

@@ -74,15 +74,15 @@ Reload .vimrc and `:PlugInstall` to install plugins.
### `Plug` options ### `Plug` options
| Option | Description | | Option | Description |
| -------------- | -------------------------------------------------------------------- | | -------------- | ------------------------------------------------ |
| `branch`/`tag` | Branch or tag of the repository to use | | `branch`/`tag` | Branch or tag of the repository to use |
| `rtp` | Subdirectory that contains Vim plugin | | `rtp` | Subdirectory that contains Vim plugin |
| `dir` | Custom directory for the plugin | | `dir` | Custom directory for the plugin |
| `do` | Post-update hook (string or funcref) | | `do` | Post-update hook (string or funcref) |
| `on` | On-demand loading: Commands or `<Plug>`-mappings | | `on` | On-demand loading: Commands or `<Plug>`-mappings |
| `for` | On-demand loading: File types | | `for` | On-demand loading: File types |
| `frozen` | Do not install/update plugin unless explicitly given as the argument | | `frozen` | Do not update unless explicitly specified |
### Global options ### Global options

View File

@@ -289,9 +289,10 @@ function! s:reorg_rtp()
let s:middle = get(s:, 'middle', &rtp) let s:middle = get(s:, 'middle', &rtp)
let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])')
let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), 'isdirectory(v:val)') let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), 'isdirectory(v:val)')
let &rtp = join(map(rtps, 's:escrtp(v:val)'), ',') let rtp = join(map(rtps, 's:escrtp(v:val)'), ',')
\ . substitute(','.s:middle.',', '^,,$', ',', '') \ . ','.s:middle.','
\ . join(map(afters, 's:escrtp(v:val)'), ',') \ . join(map(afters, 's:escrtp(v:val)'), ',')
let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g')
let s:prtp = &rtp let s:prtp = &rtp
if !empty(s:first_rtp) if !empty(s:first_rtp)
@@ -315,7 +316,7 @@ function! plug#load(...)
for name in a:000 for name in a:000
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
endfor endfor
silent! doautocmd BufRead doautocmd BufRead
return 1 return 1
endfunction endfunction
@@ -336,8 +337,8 @@ endfunction
function! s:lod_ft(pat, names) function! s:lod_ft(pat, names)
call s:lod(a:names, ['plugin', 'after/plugin']) call s:lod(a:names, ['plugin', 'after/plugin'])
execute 'autocmd! PlugLOD FileType' a:pat execute 'autocmd! PlugLOD FileType' a:pat
silent! doautocmd filetypeplugin FileType doautocmd filetypeplugin FileType
silent! doautocmd filetypeindent FileType doautocmd filetypeindent FileType
endfunction endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, name) function! s:lod_cmd(cmd, bang, l1, l2, args, name)
@@ -613,6 +614,11 @@ function! s:do(pull, force, todo)
endfunction endfunction
function! s:finish(pull) function! s:finish(pull)
let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen'))
if new_frozen
let s = new_frozen > 1 ? 's' : ''
call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s))
endif
call append(3, '- Finishing ... ') call append(3, '- Finishing ... ')
redraw redraw
call plug#helptags() call plug#helptags()
@@ -652,7 +658,7 @@ function! s:update_impl(pull, force, args) abort
\ remove(args, -1) : get(g:, 'plug_threads', 16) \ remove(args, -1) : get(g:, 'plug_threads', 16)
let managed = filter(copy(g:plugs), 's:is_managed(v:key)') let managed = filter(copy(g:plugs), 's:is_managed(v:key)')
let todo = empty(args) ? filter(managed, '!v:val.frozen') : let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
\ filter(managed, 'index(args, v:key) >= 0') \ filter(managed, 'index(args, v:key) >= 0')
if empty(todo) if empty(todo)
@@ -1268,12 +1274,7 @@ function! s:upgrade()
throw get(s:lines(output), -1, v:shell_error) throw get(s:lines(output), -1, v:shell_error)
endif endif
elseif has('ruby') elseif has('ruby')
ruby << EOF call s:upgrade_using_ruby(new)
require 'open-uri'
File.open(VIM::evaluate('new'), 'w') do |f|
f << open(VIM::evaluate('s:plug_src')).read
end
EOF
else else
return s:err('curl executable or ruby support not found') return s:err('curl executable or ruby support not found')
endif endif
@@ -1294,6 +1295,15 @@ EOF
endif endif
endfunction endfunction
function! s:upgrade_using_ruby(new)
ruby << EOF
require 'open-uri'
File.open(VIM::evaluate('a:new'), 'w') do |f|
f << open(VIM::evaluate('s:plug_src')).read
end
EOF
endfunction
function! s:upgrade_specs() function! s:upgrade_specs()
for spec in values(g:plugs) for spec in values(g:plugs)
let spec.frozen = get(spec, 'frozen', 0) let spec.frozen = get(spec, 'frozen', 0)

5
test/fixtures/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
fzf*
xxx
yyy
z1
z2

View File

@@ -0,0 +1 @@
echomsg 'ftplugin'

View File

@@ -5,18 +5,20 @@ cd ..
PLUG_SRC=$(pwd)/plug.vim PLUG_SRC=$(pwd)/plug.vim
cd - > /dev/null cd - > /dev/null
export PLUG_FIXTURES=$(pwd)/fixtures
if [ ! -d vader.vim ]; then if [ ! -d vader.vim ]; then
git clone https://github.com/junegunn/vader.vim.git git clone https://github.com/junegunn/vader.vim.git
fi fi
rm -rf fzf rm -rf $PLUG_FIXTURES/fzf
if [ ! -d fzf-staged ]; then if [ ! -d fzf-staged ]; then
git clone https://github.com/junegunn/fzf.git fzf-staged git clone https://github.com/junegunn/fzf.git $PLUG_FIXTURES/fzf-staged
fi fi
make_dirs() { make_dirs() {
mkdir -p "temp/$1" mkdir -p "$PLUG_FIXTURES/$1"
cd "temp/$1" cd "$PLUG_FIXTURES/$1"
mkdir -p autoload colors ftdetect ftplugin indent plugin syntax mkdir -p autoload colors ftdetect ftplugin indent plugin syntax
for d in *; do for d in *; do
[ -d $d ] || continue [ -d $d ] || continue
@@ -33,12 +35,12 @@ EOF
} }
init() { init() {
rm -rf temp/{xxx,yyy,z1,z2} rm -rf $PLUG_FIXTURES/{xxx,yyy,z1,z2}
make_dirs xxx/ xxx make_dirs xxx/ xxx
make_dirs xxx/after xxx make_dirs xxx/after xxx
mkdir -p temp/xxx/doc mkdir -p $PLUG_FIXTURES/xxx/doc
cat > temp/xxx/doc/xxx.txt << DOC cat > $PLUG_FIXTURES/xxx/doc/xxx.txt << DOC
hello *xxx* hello *xxx*
DOC DOC

View File

@@ -421,7 +421,7 @@ Execute (On-demand loading based on filetypes):
********************************************************************** **********************************************************************
Execute (Add unmanaged plugin): Execute (Add unmanaged plugin):
let fzf = fnamemodify(g:vader_file, ':h') . '/fzf' let fzf = expand('$PLUG_FIXTURES/fzf')
Log fzf Log fzf
call plug#begin() call plug#begin()
@@ -479,7 +479,7 @@ Execute (PlugStatus should point out that the plugin is missing):
Execute (Deploy unmanaged plugin): Execute (Deploy unmanaged plugin):
Assert !exists(':FZF'), ':FZF command should not exist' Assert !exists(':FZF'), ':FZF command should not exist'
call rename('fzf-staged', 'fzf') call rename(expand('$PLUG_FIXTURES/fzf-staged'), fzf)
Execute (PlugUpdate still should not care): Execute (PlugUpdate still should not care):
PlugUpdate PlugUpdate
@@ -517,12 +517,37 @@ Execute (Common parent):
********************************************************************** **********************************************************************
~ Frozen plugins ~ Frozen plugins
********************************************************************** **********************************************************************
- We've decided to install plugins that are frozen: see #113
Execute (Frozen plugin are not ~~installed nor~~ updated):
" Remove plugins
call plug#begin()
call plug#end()
PlugClean!
q
Execute (Frozen plugin are not installed nor updated): " vim-easy-align is not found, so it will be installed even though it's frozen
call plug#begin() call plug#begin()
Plug 'junegunn/vim-easy-align', { 'frozen': 1 } Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
call plug#end() call plug#end()
PlugInstall
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
q
" Remove plugins again
call plug#begin()
call plug#end()
PlugClean!
q
" PlugUpdate will do the same
call plug#begin()
Plug 'junegunn/vim-easy-align', { 'frozen': 1 }
call plug#end()
PlugInstall
AssertEqual 1, len(filter(getline(1, '$'), 'v:val =~ "vim-easy-align"'))
q
" Since vim-easy-align already exists, PlugInstall or PlugUpdate will skip it
redir => out redir => out
silent PlugInstall silent PlugInstall
redir END redir END
@@ -732,12 +757,12 @@ Execute (Using custom dir):
********************************************************************** **********************************************************************
Before (Clear global vars): Before (Clear global vars):
let g:xxx = [] let g:xxx = []
set rtp-=$PWD/temp/xxx/ set rtp-=$PLUG_FIXTURES/xxx/
set rtp-=$PWD/temp/xxx/after set rtp-=$PLUG_FIXTURES/xxx/after
Execute (Immediate loading): Execute (Immediate loading):
call plug#begin() call plug#begin()
Plug '$PWD/temp/xxx' Plug '$PLUG_FIXTURES/xxx'
call plug#end() call plug#end()
" FIXME: " FIXME:
@@ -751,7 +776,7 @@ Execute (Immediate loading):
Execute (Command-based on-demand loading): Execute (Command-based on-demand loading):
call plug#begin() call plug#begin()
Plug '$PWD/temp/xxx', { 'on': 'XXX' } Plug '$PLUG_FIXTURES/xxx', { 'on': 'XXX' }
call plug#end() call plug#end()
AssertEqual [], g:xxx AssertEqual [], g:xxx
@@ -764,7 +789,7 @@ Execute (Command-based on-demand loading):
Execute (Filetype-based on-demand loading): Execute (Filetype-based on-demand loading):
call plug#begin() call plug#begin()
Plug '$PWD/temp/xxx', { 'for': 'xxx' } Plug '$PLUG_FIXTURES/xxx', { 'for': 'xxx' }
call plug#end() call plug#end()
AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx AssertEqual ['xxx/ftdetect', 'xxx/after/ftdetect'], g:xxx
@@ -779,10 +804,10 @@ Before:
********************************************************************** **********************************************************************
Execute (plug#helptags): Execute (plug#helptags):
silent! call delete(expand('$PWD/temp/xxx/doc/tags')) silent! call delete(expand('$PLUG_FIXTURES/xxx/doc/tags'))
Assert !filereadable(expand('$PWD/temp/xxx/doc/tags')) Assert !filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
AssertEqual 1, plug#helptags() AssertEqual 1, plug#helptags()
Assert filereadable(expand('$PWD/temp/xxx/doc/tags')) Assert filereadable(expand('$PLUG_FIXTURES/xxx/doc/tags'))
********************************************************************** **********************************************************************
~ Manual loading ~ Manual loading
@@ -823,7 +848,7 @@ Execute (PlugStatus should not contain (not loaded)):
Execute (Load plugin from PlugStatus screen with L key in normal mode): Execute (Load plugin from PlugStatus screen with L key in normal mode):
call plug#begin() call plug#begin()
Plug '$PWD/temp/yyy', { 'on': [] } Plug '$PLUG_FIXTURES/yyy', { 'on': [] }
call plug#end() call plug#end()
PlugStatus PlugStatus
@@ -837,8 +862,8 @@ Execute (Load plugin from PlugStatus screen with L key in normal mode):
Execute (Load plugin from PlugStatus screen with L key in visual mode): Execute (Load plugin from PlugStatus screen with L key in visual mode):
call plug#begin() call plug#begin()
Plug '$PWD/temp/z1', { 'on': [] } Plug '$PLUG_FIXTURES/z1', { 'on': [] }
Plug '$PWD/temp/z2', { 'for': [] } Plug '$PLUG_FIXTURES/z2', { 'for': [] }
call plug#end() call plug#end()
PlugStatus PlugStatus
@@ -964,8 +989,8 @@ Execute (Plug directory with comma):
Execute (Strict load order): Execute (Strict load order):
let g:total_order = [] let g:total_order = []
call plug#begin() call plug#begin()
Plug '$PWD/temp/xxx' Plug '$PLUG_FIXTURES/xxx'
Plug '$PWD/temp/yyy', { 'for': ['xxx'] } Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
call plug#end() call plug#end()
call EnsureLoaded() call EnsureLoaded()
setf xxx setf xxx
@@ -977,8 +1002,8 @@ Execute (Strict load order):
let g:total_order = [] let g:total_order = []
call plug#begin() call plug#begin()
Plug '$PWD/temp/xxx', { 'for': ['xxx'] } Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
Plug '$PWD/temp/yyy' Plug '$PLUG_FIXTURES/yyy'
call plug#end() call plug#end()
call EnsureLoaded() call EnsureLoaded()
set rtp^=manually-prepended set rtp^=manually-prepended
@@ -994,8 +1019,8 @@ Execute (Strict load order):
let g:total_order = [] let g:total_order = []
call plug#begin() call plug#begin()
Plug '$PWD/temp/xxx', { 'for': ['xxx'] } Plug '$PLUG_FIXTURES/xxx', { 'for': ['xxx'] }
Plug '$PWD/temp/yyy', { 'for': ['xxx'] } Plug '$PLUG_FIXTURES/yyy', { 'for': ['xxx'] }
call plug#end() call plug#end()
call EnsureLoaded() call EnsureLoaded()
setf xxx setf xxx
@@ -1007,9 +1032,11 @@ Execute (Strict load order):
********************************************************************** **********************************************************************
Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home): Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home):
call plug#begin('$PWD/temp') call plug#begin('$PLUG_FIXTURES')
Plug '$PWD/temp/xxx' Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': [] }
Plug '$PWD/temp/yyy' Plug '$PLUG_FIXTURES/fzf'
Plug '$PLUG_FIXTURES/xxx'
Plug '$PLUG_FIXTURES/yyy'
call plug#end() call plug#end()
" Remove z1, z2 " Remove z1, z2
@@ -1022,6 +1049,24 @@ Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home
AssertExpect 'Already clean', 1 AssertExpect 'Already clean', 1
q q
**********************************************************************
Execute (#112 On-demand loading should not suppress messages from ftplugin):
call plug#begin('$PLUG_FIXTURES')
Plug '$PLUG_FIXTURES/ftplugin-msg', { 'for': 'c' }
call plug#end()
redir => out
tabnew a.c
redir END
Assert stridx(out, 'ftplugin') >= 0
* The same applies to plug#load())
redir => out
call plug#load('ftplugin-msg')
redir END
Assert stridx(out, 'ftplugin') >= 0
q
********************************************************************** **********************************************************************
Execute (PlugSnapshot): Execute (PlugSnapshot):
call plug#begin('$TMPDIR/plugged') call plug#begin('$TMPDIR/plugged')
@@ -1044,10 +1089,20 @@ Execute (PlugSnapshot):
AssertEqual 'snapshot.sh', fnamemodify(expand('%'), ':t') AssertEqual 'snapshot.sh', fnamemodify(expand('%'), ':t')
q q
**********************************************************************
Execute (#114 Should not contain empty path in &rtp):
call plug#begin('$TMPDIR/plugged')
call plug#end()
Log &rtp
Assert &rtp !~ ',,', 'Commas'
Assert &rtp !~ '^,', 'Comma prefix'
Assert &rtp !~ ',$', 'Comma suffix'
Execute (Cleanup): Execute (Cleanup):
silent! call system('rm -rf '.temp_plugged) silent! call system('rm -rf '.temp_plugged)
silent! call system('rm -rf '.temp_plugged) silent! call system('rm -rf '.temp_plugged)
silent! call rename('fzf', 'fzf-staged') silent! call rename(fzf, expand('$PLUG_FIXTURES/fzf-staged'))
silent! unlet g:plugs silent! unlet g:plugs
silent! unlet g:plug_home silent! unlet g:plug_home
silent! unlet g:plug_url_format silent! unlet g:plug_url_format