mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 18:47:29 -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
16
README.md
16
README.md
@ -61,14 +61,14 @@ Reload .vimrc and `:PlugInstall` to install plugins.
|
|||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| ----------------------------------- | ----------------------------------------------------------------------- |
|
| ----------------------------------- | ------------------------------------------------------------------ |
|
||||||
| `PlugInstall [name ...] [#threads]` | Install plugins |
|
| `PlugInstall [name ...] [#threads]` | Install plugins |
|
||||||
| `PlugUpdate [name ...] [#threads]` | Install or update plugins |
|
| `PlugUpdate [name ...] [#threads]` | Install or update plugins |
|
||||||
| `PlugClean[!]` | Remove unused directories (bang version will clean without prompt) |
|
| `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 |
|
| `PlugStatus` | Check the status of plugins |
|
||||||
| `PlugDiff` | See the updated changes from the previous PlugUpdate |
|
| `PlugDiff` | See the updated changes from the previous PlugUpdate |
|
||||||
|
|
||||||
### `Plug` options
|
### `Plug` options
|
||||||
|
|
||||||
|
34
plug.vim
34
plug.vim
@ -101,15 +101,18 @@ function! plug#begin(...)
|
|||||||
" we want to keep track of the order plugins where registered.
|
" we want to keep track of the order plugins where registered.
|
||||||
let g:plugs_order = []
|
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 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 PlugInstall call s:install('<bang>' == '!', <f-args>)
|
||||||
command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update('<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 -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 PlugStatus call s:status()
|
||||||
command! -nargs=0 -bar PlugDiff call s:diff()
|
command! -nargs=0 -bar PlugDiff call s:diff()
|
||||||
|
|
||||||
return 1
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:to_a(v)
|
function! s:to_a(v)
|
||||||
@ -1003,16 +1006,13 @@ function! s:upgrade()
|
|||||||
call system(printf(
|
call system(printf(
|
||||||
\ 'curl -fLo %s %s && '.cp.' %s %s.old && '.mv.' %s %s',
|
\ 'curl -fLo %s %s && '.cp.' %s %s.old && '.mv.' %s %s',
|
||||||
\ new, s:plug_source, mee, mee, new, mee))
|
\ new, s:plug_source, mee, mee, new, mee))
|
||||||
if v:shell_error == 0
|
if v:shell_error
|
||||||
unlet g:loaded_plug
|
|
||||||
echo 'Downloaded '. s:plug_source
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return s:err('Error upgrading vim-plug')
|
return s:err('Error upgrading vim-plug')
|
||||||
endif
|
endif
|
||||||
elseif has('ruby')
|
elseif has('ruby')
|
||||||
echo 'Downloading '. s:plug_source
|
echo 'Downloading '. s:plug_source
|
||||||
ruby << EOF
|
try
|
||||||
|
ruby << EOF
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
me = VIM::evaluate('s:me')
|
me = VIM::evaluate('s:me')
|
||||||
@ -1024,12 +1024,16 @@ function! s:upgrade()
|
|||||||
FileUtils.cp me, old
|
FileUtils.cp me, old
|
||||||
File.rename new, me
|
File.rename new, me
|
||||||
EOF
|
EOF
|
||||||
unlet g:loaded_plug
|
catch
|
||||||
echo 'Downloaded '. s:plug_source
|
return s:err('Error upgrading vim-plug')
|
||||||
return 1
|
endtry
|
||||||
else
|
else
|
||||||
return s:err('curl executable or ruby support not found')
|
return s:err('curl executable or ruby support not found')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
unlet g:loaded_plug
|
||||||
|
echo 'Downloaded '. s:plug_source
|
||||||
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:upgrade_specs()
|
function! s:upgrade_specs()
|
||||||
@ -1146,6 +1150,12 @@ endfunction
|
|||||||
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
|
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
|
||||||
let s:last_rtp = s:esc(get(split(&rtp, ','), -1, ''))
|
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
|
let &cpo = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user