1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 00:50:05 +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) call writefile([a:msg], self.file, flags)
endfunction endfunction
function! s:self.warn(msg) abort function! s:self.warn(msg, ...) abort
if self.level > 2 if self.level > 2
return return
endif endif
let time = strftime('%H:%M:%S') let time = strftime('%H:%M:%S')
let log = '[ ' . self.name . ' ] [' . time . '] [ ' . s:levels[1] . ' ] ' . a:msg 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 echohl WarningMsg
echom log echom log
echohl None echohl None

View File

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

View File

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