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

Fix install process

This commit is contained in:
wsdjeg 2017-04-22 16:08:07 +08:00
parent 83882ba74f
commit f063f66bb6

View File

@ -6,9 +6,6 @@
" License: MIT license " License: MIT license
"============================================================================= "=============================================================================
" TODO add airline support for plugin manager
" TODO add install function for plugin manager
" Load SpaceVim api " Load SpaceVim api
let s:VIM_CO = SpaceVim#api#import('vim#compatible') let s:VIM_CO = SpaceVim#api#import('vim#compatible')
let s:JOB = SpaceVim#api#import('job') let s:JOB = SpaceVim#api#import('job')
@ -277,10 +274,15 @@ 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
if a:id == -1
let id = s:jobpid
else
let id = a:id
endif
for str in a:data for str in a:data
let status = matchstr(str,'\d\+%\s(\d\+/\d\+)') let status = matchstr(str,'\d\+%\s(\d\+/\d\+)')
if !empty(status) if !empty(status)
call s:msg_on_install_process(s:pulling_repos[a:id].name, status) call s:msg_on_install_process(s:pulling_repos[id].name, status)
endif endif
endfor endfor
endfunction endfunction
@ -311,34 +313,31 @@ endfunction
" here if a:data == 0, git pull succeed " here if a:data == 0, git pull succeed
function! s:on_install_exit(id, data, event) abort function! s:on_install_exit(id, data, event) abort
if a:data == 0 && a:event ==# 'exit' if a:id == -1
call s:msg_on_install_done(s:pulling_repos[a:id].name) let id = s:jobpid
else else
call s:msg_on_install_failed(s:pulling_repos[a:id].name) let id = a:id
endif endif
if get(s:pulling_repos[a:id], 'rev', '') !=# '' if a:data == 0 && a:event ==# 'exit'
call s:lock_revision(s:pulling_repos[a:id]) call s:msg_on_install_done(s:pulling_repos[id].name)
else
call s:msg_on_install_failed(s:pulling_repos[id].name)
endif endif
if get(s:pulling_repos[a:id], 'build', '') !=# '' if get(s:pulling_repos[id], 'rev', '') !=# ''
call s:build(s:pulling_repos[a:id]) call s:lock_revision(s:pulling_repos[id])
endif
if get(s:pulling_repos[id], 'build', '') !=# ''
call s:build(s:pulling_repos[id])
else else
let s:pct_done += 1 let s:pct_done += 1
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updating plugins (' . s:pct_done . '/' . s:total . ')') call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updating plugins (' . s:pct_done . '/' . s:total . ')')
call s:set_buf_line(s:plugin_manager_buffer, 2, s:status_bar()) call s:set_buf_line(s:plugin_manager_buffer, 2, s:status_bar())
endif endif
call remove(s:pulling_repos, string(a:id)) call remove(s:pulling_repos, string(id))
if !empty(s:plugins) if !empty(s:plugins)
call s:install(dein#get(s:LIST.shift(s:plugins))) call s:install(dein#get(s:LIST.shift(s:plugins)))
endif endif
if empty(s:pulling_repos) && empty(s:building_repos) call s:recache_rtp(a:id)
" TODO add elapsed time info.
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installed. Elapsed time: '
\ . split(reltimestr(reltime(s:start_time)))[0] . ' sec.')
let s:plugin_manager_buffer = 0
if g:spacevim_plugin_manager ==# 'dein'
call dein#recache_runtimepath()
endif
endif
endfunction endfunction
function! s:pull(repo) abort function! s:pull(repo) abort
@ -370,13 +369,25 @@ function! s:install(repo) abort
let s:ui_buf[a:repo.name] = s:pct let s:ui_buf[a:repo.name] = s:pct
let url = 'https://github.com/' . a:repo.repo let url = 'https://github.com/' . a:repo.repo
let argv = ['git', 'clone', '--progress', url, a:repo.path] let argv = ['git', 'clone', '--progress', url, a:repo.path]
let jobid = s:JOB.start(argv,{ if s:JOB.vim_job || s:JOB.nvim_job
\ 'on_stderr' : function('s:on_install_stdout'), let jobid = s:JOB.start(argv,{
\ 'on_exit' : function('s:on_install_exit') \ 'on_stderr' : function('s:on_install_stdout'),
\ }) \ 'on_exit' : function('s:on_install_exit')
if jobid != 0 \ })
let s:pulling_repos[jobid] = a:repo if jobid != 0
call s:msg_on_install_start(a:repo.name) let s:pulling_repos[jobid] = a:repo
call s:msg_on_install_start(a:repo.name)
endif
else
let s:jobpid += 1
let s:pulling_repos[s:jobpid] = a:repo
call s:msg_on_start(a:repo.name)
redraw!
call s:JOB.start(argv,{
\ 'on_stderr' : function('s:on_install_stdout'),
\ 'on_exit' : function('s:on_install_exit')
\ })
endif endif
endfunction endfunction