Merge pull request #47 from junegunn/fix-upgrade

Do not require reloading of .vimrc after PlugUpgrade
This commit is contained in:
Junegunn Choi 2014-08-05 19:09:17 +09:00
commit 3a2e406cd0
2 changed files with 30 additions and 20 deletions

View file

@ -61,14 +61,14 @@ Reload .vimrc and `:PlugInstall` to install plugins.
### Commands
| Command | Description |
| ----------------------------------- | ----------------------------------------------------------------------- |
| `PlugInstall [name ...] [#threads]` | Install plugins |
| `PlugUpdate [name ...] [#threads]` | Install or update plugins |
| `PlugClean[!]` | Remove unused directories (bang version will clean without prompt) |
| `PlugUpgrade` | Upgrade vim-plug itself. You may need to reload `.vimrc` after upgrade. |
| `PlugStatus` | Check the status of plugins |
| `PlugDiff` | See the updated changes from the previous PlugUpdate |
| Command | Description |
| ----------------------------------- | ------------------------------------------------------------------ |
| `PlugInstall [name ...] [#threads]` | Install plugins |
| `PlugUpdate [name ...] [#threads]` | Install or update plugins |
| `PlugClean[!]` | Remove unused directories (bang version will clean without prompt) |
| `PlugUpgrade` | Upgrade vim-plug itself |
| `PlugStatus` | Check the status of plugins |
| `PlugDiff` | See the updated changes from the previous PlugUpdate |
### `Plug` options

View file

@ -101,15 +101,18 @@ function! plug#begin(...)
" we want to keep track of the order plugins where registered.
let g:plugs_order = []
call s:define_commands()
return 1
endfunction
function! s:define_commands()
command! -nargs=+ -bar Plug call s:add(<args>)
command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install('<bang>' == '!', <f-args>)
command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update('<bang>' == '!', <f-args>)
command! -nargs=0 -bar -bang PlugClean call s:clean('<bang>' == '!')
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source '. s:me | call s:upgrade_specs() | endif
command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source '. s:me | endif
command! -nargs=0 -bar PlugStatus call s:status()
command! -nargs=0 -bar PlugDiff call s:diff()
return 1
endfunction
function! s:to_a(v)
@ -1003,16 +1006,13 @@ function! s:upgrade()
call system(printf(
\ 'curl -fLo %s %s && '.cp.' %s %s.old && '.mv.' %s %s',
\ new, s:plug_source, mee, mee, new, mee))
if v:shell_error == 0
unlet g:loaded_plug
echo 'Downloaded '. s:plug_source
return 1
else
if v:shell_error
return s:err('Error upgrading vim-plug')
endif
elseif has('ruby')
echo 'Downloading '. s:plug_source
ruby << EOF
try
ruby << EOF
require 'open-uri'
require 'fileutils'
me = VIM::evaluate('s:me')
@ -1024,12 +1024,16 @@ function! s:upgrade()
FileUtils.cp me, old
File.rename new, me
EOF
unlet g:loaded_plug
echo 'Downloaded '. s:plug_source
return 1
catch
return s:err('Error upgrading vim-plug')
endtry
else
return s:err('curl executable or ruby support not found')
endif
unlet g:loaded_plug
echo 'Downloaded '. s:plug_source
return 1
endfunction
function! s:upgrade_specs()
@ -1146,6 +1150,12 @@ endfunction
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
let s:last_rtp = s:esc(get(split(&rtp, ','), -1, ''))
if exists('g:plugs')
let g:plugs_order = get(g:, 'plugs_order', keys(g:plugs))
call s:upgrade_specs()
call s:define_commands()
endif
let &cpo = s:cpo_save
unlet s:cpo_save