mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 18:47:29 -07:00
PlugUpgrade using git
This commit is contained in:
parent
650927980d
commit
27354c826e
55
plug.vim
55
plug.vim
@ -67,7 +67,7 @@ let g:loaded_plug = 1
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
let s:plug_src = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
let s:plug_src = 'https://github.com/junegunn/vim-plug.git'
|
||||||
let s:plug_tab = get(s:, 'plug_tab', -1)
|
let s:plug_tab = get(s:, 'plug_tab', -1)
|
||||||
let s:plug_buf = get(s:, 'plug_buf', -1)
|
let s:plug_buf = get(s:, 'plug_buf', -1)
|
||||||
let s:mac_gui = has('gui_macvim') && has('gui_running')
|
let s:mac_gui = has('gui_macvim') && has('gui_running')
|
||||||
@ -1668,6 +1668,12 @@ function! s:git_valid(spec, check_branch)
|
|||||||
return [ret, msg]
|
return [ret, msg]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:rm_rf(dir)
|
||||||
|
if isdirectory(a:dir)
|
||||||
|
call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:clean(force)
|
function! s:clean(force)
|
||||||
call s:prepare()
|
call s:prepare()
|
||||||
call append(0, 'Searching for unused plugins in '.g:plug_home)
|
call append(0, 'Searching for unused plugins in '.g:plug_home)
|
||||||
@ -1716,9 +1722,7 @@ function! s:clean(force)
|
|||||||
call inputrestore()
|
call inputrestore()
|
||||||
if yes
|
if yes
|
||||||
for dir in todo
|
for dir in todo
|
||||||
if isdirectory(dir)
|
call s:rm_rf(dir)
|
||||||
call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(dir))
|
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
call append(line('$'), 'Removed.')
|
call append(line('$'), 'Removed.')
|
||||||
else
|
else
|
||||||
@ -1729,29 +1733,19 @@ function! s:clean(force)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:upgrade()
|
function! s:upgrade()
|
||||||
let new = s:me . '.new'
|
echo 'Downloading the latest version of vim-plug'
|
||||||
echo 'Downloading '. s:plug_src
|
|
||||||
redraw
|
redraw
|
||||||
|
let tmp = tempname()
|
||||||
|
let new = tmp . '/plug.vim'
|
||||||
|
|
||||||
try
|
try
|
||||||
if executable('curl')
|
let out = s:system(printf('git clone --depth 1 %s %s', s:plug_src, tmp))
|
||||||
let output = s:system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_src))
|
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
throw get(s:lines(output), -1, v:shell_error)
|
return s:err('Error upgrading vim-plug: '. out)
|
||||||
endif
|
endif
|
||||||
elseif has('ruby')
|
|
||||||
call s:upgrade_using_ruby(new)
|
|
||||||
elseif has('python')
|
|
||||||
call s:upgrade_using_python(new)
|
|
||||||
else
|
|
||||||
return s:err('Missing: curl executable, ruby support or python support')
|
|
||||||
endif
|
|
||||||
catch
|
|
||||||
return s:err('Error upgrading vim-plug: '. v:exception)
|
|
||||||
endtry
|
|
||||||
|
|
||||||
if readfile(s:me) ==# readfile(new)
|
if readfile(s:me) ==# readfile(new)
|
||||||
echo 'vim-plug is already up-to-date'
|
echo 'vim-plug is already up-to-date'
|
||||||
silent! call delete(new)
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
call rename(s:me, s:me . '.old')
|
call rename(s:me, s:me . '.old')
|
||||||
@ -1760,24 +1754,9 @@ function! s:upgrade()
|
|||||||
echo 'vim-plug has been upgraded'
|
echo 'vim-plug has been upgraded'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfunction
|
finally
|
||||||
|
silent! call s:rm_rf(tmp)
|
||||||
function! s:upgrade_using_ruby(new)
|
endtry
|
||||||
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_using_python(new)
|
|
||||||
python << EOF
|
|
||||||
import urllib
|
|
||||||
import vim
|
|
||||||
psrc, dest = vim.eval('s:plug_src'), vim.eval('a:new')
|
|
||||||
urllib.urlretrieve(psrc, dest)
|
|
||||||
EOF
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:upgrade_specs()
|
function! s:upgrade_specs()
|
||||||
|
Loading…
Reference in New Issue
Block a user