1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:20:06 +08:00

Improve plugin manager

This commit is contained in:
wsdjeg 2017-12-26 21:09:23 +08:00
parent 26234851e1
commit 271b35c8d0
3 changed files with 10 additions and 13 deletions

View File

@ -52,13 +52,13 @@ function! s:self.write(msg) abort
call writefile([a:msg], self.file, flags)
endfunction
function! s:self.warn(msg) abort
function! s:self.warn(msg, ...) abort
if self.level > 2
return
endif
let time = strftime('%H:%M:%S')
let log = '[ ' . self.name . ' ] [' . time . '] [ ' . s:levels[1] . ' ] ' . a:msg
if !self.silent && self.verbose >= 2
if (!self.silent && self.verbose >= 2) || get(a:000, 0, 0) == 1
echohl WarningMsg
echom log
echohl None

View File

@ -11,10 +11,9 @@ function! SpaceVim#logger#info(msg) abort
endfunction
function! SpaceVim#logger#warn(msg) abort
call s:LOGGER.warn(a:msg)
function! SpaceVim#logger#warn(msg, ...) abort
let issilent = get(a:000, 0, 1)
call s:LOGGER.warn(a:msg, issilent)
endfunction

View File

@ -120,19 +120,20 @@ function! SpaceVim#plugins#manager#install(...) abort
if !s:JOB.vim_job && !s:JOB.nvim_job
let &maxfuncdepth = 2000
endif
let s:plugins = a:0 == 0 ? sort(map(s:get_uninstalled_plugins(), 'v:val.name')) : sort(copy(a:1))
if empty(s:plugins)
call SpaceVim#logger#warn(' [ plug manager ] Wrong plugin name, or all of the plugins are already installed.')
let plugins = a:0 == 0 ? sort(map(s:get_uninstalled_plugins(), 'v:val.name')) : sort(copy(a:1))
if empty(plugins)
call SpaceVim#logger#warn(' [ plug manager ] All of the plugins are already installed.', 1)
return
endif
let status = s:new_window()
if status == 0
call SpaceVim#logger#warn(' [ plug manager ] plugin manager process is not finished.')
call SpaceVim#logger#warn(' [ plug manager ] plugin manager process is not finished.', 1)
return
elseif status == 1
" resume window
return
endif
let s:plugins = plugins
let s:pct = 0
let s:pct_done = 0
let s:total = len(s:plugins)
@ -232,7 +233,6 @@ endfunction
" here if a:data == 0, git pull succeed
function! s:on_pull_exit(id, data, event) abort
call SpaceVim#logger#info(string(a:data))
if a:id == -1
let id = s:jobpid
else
@ -292,7 +292,6 @@ endfunction
" @vimlint(EVL103, 1, a:event)
function! s:on_install_stdout(id, data, event) abort
call SpaceVim#logger#info(string(a:data))
if a:id == -1
let id = s:jobpid
else
@ -363,7 +362,6 @@ function! s:pull(repo) abort
let s:pct += 1
let s:ui_buf[a:repo.name] = s:pct
let argv = ['git', 'pull', '--progress']
call SpaceVim#logger#info('plugin manager cmd: ' . string(argv))
if s:JOB.vim_job || s:JOB.nvim_job
let jobid = s:JOB.start(argv,{
\ 'on_stderr' : function('s:on_install_stdout'),