1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 23:49:19 +08:00

Merge pull request #441 from SpaceVim/plugin_ui

Fix resume windows
This commit is contained in:
Wang Shidong 2017-04-15 23:03:11 +08:00 committed by GitHub
commit bf9be875f7

View File

@ -116,12 +116,13 @@ endfunction
" @vimlint(EVL102, 1, l:i) " @vimlint(EVL102, 1, l:i)
function! SpaceVim#plugins#manager#install(...) abort function! SpaceVim#plugins#manager#install(...) abort
let s:plugins = a:0 == 0 ? sort(map(s:get_uninstalled_plugins(), 'v:val.name')) : sort(copy(a:1)) let s:plugins = a:0 == 0 ? sort(map(s:get_uninstalled_plugins(), 'v:val.name')) : sort(copy(a:1))
if s:new_window() == 0 let status = s:new_window()
if status == 0
echohl WarningMsg echohl WarningMsg
echom '[SpaceVim] [plugin manager] plugin manager process is not finished.' echom '[SpaceVim] [plugin manager] plugin manager process is not finished.'
echohl None echohl None
return return
elseif s:new_window() == 1 elseif status == 1
" resume window " resume window
return return
elseif empty(s:plugins) elseif empty(s:plugins)
@ -131,8 +132,9 @@ function! SpaceVim#plugins#manager#install(...) abort
return return
endif endif
let s:pct = 0 let s:pct = 0
let s:pct_done = 0
let s:total = len(s:plugins) let s:total = len(s:plugins)
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installing plugins (' . s:pct . '/' . s:total . ')') call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installing plugins (' . s:pct_done . '/' . s:total . ')')
if has('nvim') if has('nvim')
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())
call s:set_buf_line(s:plugin_manager_buffer, 3, '') call s:set_buf_line(s:plugin_manager_buffer, 3, '')
@ -157,21 +159,23 @@ endfunction
" @vimlint(EVL102, 1, l:i) " @vimlint(EVL102, 1, l:i)
function! SpaceVim#plugins#manager#update(...) abort function! SpaceVim#plugins#manager#update(...) abort
if s:new_window() == 0 let status = s:new_window()
if status == 0
echohl WarningMsg echohl WarningMsg
echom '[SpaceVim] [plugin manager] plugin updating is not finished.' echom '[SpaceVim] [plugin manager] plugin updating is not finished.'
echohl None echohl None
return return
elseif s:new_window() == 1 elseif status == 1
return return
endif endif
let s:pct = 0 let s:pct = 0
let s:pct_done = 0
let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1)) let s:plugins = a:0 == 0 ? sort(keys(dein#get())) : sort(copy(a:1))
if a:0 == 0 if a:0 == 0
call add(s:plugins, 'SpaceVim') call add(s:plugins, 'SpaceVim')
endif endif
let s:total = len(s:plugins) let s:total = len(s:plugins)
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updating plugins (' . s:pct . '/' . s:total . ')') call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updating plugins (' . s:pct_done . '/' . s:total . ')')
if has('nvim') if has('nvim')
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())
call s:set_buf_line(s:plugin_manager_buffer, 3, '') call s:set_buf_line(s:plugin_manager_buffer, 3, '')
@ -218,8 +222,13 @@ function! s:on_pull_exit(id, data, event) abort
else else
call s:msg_on_updated_failed(s:pulling_repos[a:id].name) call s:msg_on_updated_failed(s:pulling_repos[a:id].name)
endif endif
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updating plugins (' . s:pct . '/' . s:total . ')') if get(s:pulling_repos[a:id], 'build', '') !=# ''
call s:set_buf_line(s:plugin_manager_buffer, 2, s:status_bar()) call s:build(s:pulling_repos[a:id])
else
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, 2, s:status_bar())
endif
call remove(s:pulling_repos, string(a:id)) call remove(s:pulling_repos, string(a:id))
if !empty(s:plugins) if !empty(s:plugins)
let name = s:LIST.shift(s:plugins) let name = s:LIST.shift(s:plugins)
@ -233,7 +242,7 @@ function! s:on_pull_exit(id, data, event) abort
endif endif
call s:pull(repo) call s:pull(repo)
endif endif
if empty(s:pulling_repos) if empty(s:pulling_repos) && empty(s:building_repos)
" TODO add elapsed time info. " TODO add elapsed time info.
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updated. Elapsed time: ' call s:set_buf_line(s:plugin_manager_buffer, 1, 'Updated. Elapsed time: '
\ . split(reltimestr(reltime(s:start_time)))[0] . ' sec.') \ . split(reltimestr(reltime(s:start_time)))[0] . ' sec.')
@ -258,7 +267,6 @@ endfunction
function! s:lock_revision(repo) abort function! s:lock_revision(repo) abort
let cmd = ['git', '-C', a:repo.path, 'checkout', a:repo.rev] let cmd = ['git', '-C', a:repo.path, 'checkout', a:repo.rev]
let g:wsd = cmd
call s:VIM_CO.system(cmd) call s:VIM_CO.system(cmd)
endfunction endfunction
@ -268,6 +276,10 @@ function! s:on_build_exit(id, data, event) abort
else else
call s:msg_on_build_failed(s:building_repos[a:id].name) call s:msg_on_build_failed(s:building_repos[a:id].name)
endif endif
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, 2, s:status_bar())
call remove(s:building_repos, string(a:id))
if empty(s:pulling_repos) && empty(s:building_repos) if empty(s:pulling_repos) && empty(s:building_repos)
" TODO add elapsed time info. " TODO add elapsed time info.
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installed. Elapsed time: ' call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installed. Elapsed time: '
@ -286,13 +298,15 @@ function! s:on_install_exit(id, data, event) abort
else else
call s:msg_on_install_failed(s:pulling_repos[a:id].name) call s:msg_on_install_failed(s:pulling_repos[a:id].name)
endif endif
call s:set_buf_line(s:plugin_manager_buffer, 1, 'Installing plugins (' . s:pct . '/' . s:total . ')')
call s:set_buf_line(s:plugin_manager_buffer, 2, s:status_bar())
if get(s:pulling_repos[a:id], 'rev', '') !=# '' if get(s:pulling_repos[a:id], 'rev', '') !=# ''
call s:lock_revision(s:pulling_repos[a:id]) call s:lock_revision(s:pulling_repos[a:id])
endif endif
if get(s:pulling_repos[a:id], 'build', '') !=# '' if get(s:pulling_repos[a:id], 'build', '') !=# ''
call s:build(s:pulling_repos[a:id]) call s:build(s:pulling_repos[a:id])
else
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, 2, s:status_bar())
endif endif
call remove(s:pulling_repos, string(a:id)) call remove(s:pulling_repos, string(a:id))
if !empty(s:plugins) if !empty(s:plugins)
@ -351,7 +365,7 @@ endfunction
function! s:msg_on_build_start(name) abort function! s:msg_on_build_start(name) abort
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3,
\ '- ' . a:name . ': Building ') \ '* ' . a:name . ': Building ')
endfunction endfunction
function! s:get_build_argv(build) abort function! s:get_build_argv(build) abort
@ -389,12 +403,12 @@ endfunction
" - foo.vim: Updating failed. " - foo.vim: Updating failed.
function! s:msg_on_updated_failed(name) abort function! s:msg_on_updated_failed(name) abort
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, '- ' . a:name . ': Updating failed.') call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, 'x ' . a:name . ': Updating failed.')
endfunction endfunction
function! s:msg_on_install_process(name, status) abort function! s:msg_on_install_process(name, status) abort
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3,
\ '- ' . a:name . ': Installing ' . a:status) \ '* ' . a:name . ': Installing ' . a:status)
endfunction endfunction
" - foo.vim: Updating done. " - foo.vim: Updating done.
@ -404,7 +418,7 @@ endfunction
" - foo.vim: Updating failed. " - foo.vim: Updating failed.
function! s:msg_on_install_failed(name) abort function! s:msg_on_install_failed(name) abort
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, '- ' . a:name . ': Installing failed.') call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, 'x ' . a:name . ': Installing failed.')
endfunction endfunction
" - foo.vim: Updating done. " - foo.vim: Updating done.
@ -414,7 +428,7 @@ endfunction
" - foo.vim: Updating failed. " - foo.vim: Updating failed.
function! s:msg_on_build_failed(name) abort function! s:msg_on_build_failed(name) abort
call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, '- ' . a:name . ': Building failed.') call s:set_buf_line(s:plugin_manager_buffer, s:ui_buf[a:name] + 3, 'x ' . a:name . ': Building failed.')
endfunction endfunction
function! s:new_window() abort function! s:new_window() abort