Add PlugStatus command

This commit is contained in:
Junegunn Choi 2013-09-23 17:33:36 +09:00
parent f785a017b0
commit e117c264d2
2 changed files with 39 additions and 8 deletions

View file

@ -52,12 +52,13 @@ plugins with `plug#begin(path)` call.
### Commands
| Command | Description |
| ---------------------- | ------------------------- |
| PlugInstall [#threads] | Install plugins |
| PlugUpdate [#threads] | Install or update plugins |
| PlugClean | Remove unused directories |
| PlugUpgrade | Upgrade vim-plug itself |
| Command | Description |
| ---------------------- | --------------------------- |
| PlugInstall [#threads] | Install plugins |
| PlugUpdate [#threads] | Install or update plugins |
| PlugClean | Remove unused directories |
| PlugUpgrade | Upgrade vim-plug itself |
| PlugStatus | Check the status of plugins |
(Default number of threads = `g:plug_threads` or 16)

View file

@ -79,6 +79,7 @@ function! plug#begin(...)
command! -nargs=* PlugUpdate call s:update(<f-args>)
command! -nargs=0 -bang PlugClean call s:clean('<bang>' == '!')
command! -nargs=0 PlugUpgrade if s:upgrade() | execute "source ". s:me | endif
command! -nargs=0 PlugStatus call s:status()
endfunction
function! plug#end()
@ -246,7 +247,7 @@ function! s:update_serial(pull)
\ spec.branch, spec.branch)) : 'Already installed'
let error = a:pull ? v:shell_error != 0 : 0
else
let result = "PlugClean required. Invalid remote repository."
let result = "PlugClean required. Invalid remote."
let error = 1
endif
else
@ -313,7 +314,7 @@ function! s:update_parallel(pull, threads)
[true, skip]
end
else
[false, "PlugClean required. Invalid remote repository."]
[false, "PlugClean required. Invalid remote."]
end
else
FileUtils.mkdir_p(base)
@ -437,3 +438,32 @@ function! s:upgrade()
endif
endfunction
function! s:status()
call s:prepare()
call append(0, 'Checking plugins')
let errs = 0
for [name, spec] in items(g:plugs)
let err = 'OK'
if isdirectory(spec.dir)
execute 'cd '.spec.dir
if s:git_valid(spec, 0)
let branch = s:system('git rev-parse --abbrev-ref HEAD')
if spec.branch != branch
let err = '(x) Invalid branch: '.branch.'. Try PlugUpdate.'
endif
else
let err = '(x) Invalid remote. Try PlugClean.'
endif
cd -
else
let err = '(x) Not found. Try PlugInstall.'
endif
let errs += err != 'OK'
call append(2, printf('- %s: %s', name, err))
call cursor(3, 1)
redraw
endfor
call setline(1, 'Finished. '.errs.' error(s).')
endfunction