plug upgrade
This commit is contained in:
@@ -632,17 +632,39 @@ function! plug#(repo, ...)
|
||||
let g:plugs[name] = spec
|
||||
let s:loaded[name] = get(s:loaded, name, 0)
|
||||
catch
|
||||
return s:err(v:exception)
|
||||
return s:err(repo . ' ' . v:exception)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:parse_options(arg)
|
||||
let opts = copy(s:base_spec)
|
||||
let type = type(a:arg)
|
||||
let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)'
|
||||
if type == s:TYPE.string
|
||||
if empty(a:arg)
|
||||
throw printf(opt_errfmt, 'tag', 'string')
|
||||
endif
|
||||
let opts.tag = a:arg
|
||||
elseif type == s:TYPE.dict
|
||||
call extend(opts, a:arg)
|
||||
for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as']
|
||||
if has_key(opts, opt)
|
||||
\ && (type(opts[opt]) != s:TYPE.string || empty(opts[opt]))
|
||||
throw printf(opt_errfmt, opt, 'string')
|
||||
endif
|
||||
endfor
|
||||
for opt in ['on', 'for']
|
||||
if has_key(opts, opt)
|
||||
\ && type(opts[opt]) != s:TYPE.list
|
||||
\ && (type(opts[opt]) != s:TYPE.string || empty(opts[opt]))
|
||||
throw printf(opt_errfmt, opt, 'string or list')
|
||||
endif
|
||||
endfor
|
||||
if has_key(opts, 'do')
|
||||
\ && type(opts.do) != s:TYPE.funcref
|
||||
\ && (type(opts.do) != s:TYPE.string || empty(opts.do))
|
||||
throw printf(opt_errfmt, 'do', 'string or funcref')
|
||||
endif
|
||||
if has_key(opts, 'dir')
|
||||
let opts.dir = s:dirpath(s:plug_expand(opts.dir))
|
||||
endif
|
||||
@@ -2249,7 +2271,7 @@ endfunction
|
||||
|
||||
function! s:rm_rf(dir)
|
||||
if isdirectory(a:dir)
|
||||
call s:system(s:is_win
|
||||
return s:system(s:is_win
|
||||
\ ? 'rmdir /S /Q '.plug#shellescape(a:dir)
|
||||
\ : ['rm', '-rf', a:dir])
|
||||
endif
|
||||
@@ -2333,6 +2355,7 @@ endfunction
|
||||
function! s:delete(range, force)
|
||||
let [l1, l2] = a:range
|
||||
let force = a:force
|
||||
let err_count = 0
|
||||
while l1 <= l2
|
||||
let line = getline(l1)
|
||||
if line =~ '^- ' && isdirectory(line[2:])
|
||||
@@ -2341,11 +2364,22 @@ function! s:delete(range, force)
|
||||
let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1)
|
||||
let force = force || answer > 1
|
||||
if answer
|
||||
call s:rm_rf(line[2:])
|
||||
let err = s:rm_rf(line[2:])
|
||||
setlocal modifiable
|
||||
call setline(l1, '~'.line[1:])
|
||||
let s:clean_count += 1
|
||||
call setline(4, printf('Removed %d directories.', s:clean_count))
|
||||
if empty(err)
|
||||
call setline(l1, '~'.line[1:])
|
||||
let s:clean_count += 1
|
||||
else
|
||||
delete _
|
||||
call append(l1 - 1, s:format_message('x', line[1:], err))
|
||||
let l2 += len(s:lines(err))
|
||||
let err_count += 1
|
||||
endif
|
||||
let msg = printf('Removed %d directories.', s:clean_count)
|
||||
if err_count > 0
|
||||
let msg .= printf(' Failed to remove %d directories.', err_count)
|
||||
endif
|
||||
call setline(4, msg)
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user