mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-23 20:45:31 -07:00
Merge pull request #47 from junegunn/fix-upgrade
Do not require reloading of .vimrc after PlugUpgrade
This commit is contained in:
commit
3a2e406cd0
@ -62,11 +62,11 @@ 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. |
|
||||
| `PlugUpgrade` | Upgrade vim-plug itself |
|
||||
| `PlugStatus` | Check the status of plugins |
|
||||
| `PlugDiff` | See the updated changes from the previous PlugUpdate |
|
||||
|
||||
|
32
plug.vim
32
plug.vim
@ -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,15 +1006,12 @@ 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
|
||||
try
|
||||
ruby << EOF
|
||||
require 'open-uri'
|
||||
require 'fileutils'
|
||||
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user