1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-23 17:49:57 +08:00

Update manager

This commit is contained in:
wsdjeg 2017-04-04 23:01:41 +08:00
parent 66574c5226
commit feef100e21
4 changed files with 62 additions and 1 deletions

View File

@ -194,6 +194,9 @@ let g:spacevim_filemanager = 'vimfiler'
" Options are dein, neobundle, or vim-plug. " Options are dein, neobundle, or vim-plug.
let g:spacevim_plugin_manager = 'dein' let g:spacevim_plugin_manager = 'dein'
"" ""
" Set the max process of SpaceVim plugin manager
let g:spacevim_plugin_manager_max_processes = 8
""
" Enable/Disable checkinstall on SpaceVim startup. Default is 1. " Enable/Disable checkinstall on SpaceVim startup. Default is 1.
" > " >
" let g:spacevim_checkinstall = 1 " let g:spacevim_checkinstall = 1

View File

@ -1,5 +1,5 @@
function! SpaceVim#api#data#list#get() abort function! SpaceVim#api#job#get() abort
return map({'start' : '', return map({'start' : '',
\ 'stop' : '', \ 'stop' : '',
\ 'send' : '', \ 'send' : '',

View File

@ -8,6 +8,14 @@
" 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:LIST = SpaceVim#api#import('data#list')
" init values
let s:plugins = []
let s:pulling_repos = {}
" install plugin manager " install plugin manager
function! s:install_manager() abort function! s:install_manager() abort
" Fsep && Psep " Fsep && Psep
@ -92,3 +100,50 @@ function! s:need_cmd(cmd) abort
return 0 return 0
endif endif
endfunction endfunction
" @vimlint(EVL102, 1, l:i)
function! SpaceVim#plugins#manager#update() abort
let s:plugins = keys(dein#get())
for i in range(g:spacevim_plugin_manager_max_processes)
call s:pull(dein#get(s:LIST.shift(s:plugins)))
endfor
endfunction
" @vimlint(EVL102, 0, l:i)
" here if a:data == 0, git pull succeed
function! s:on_pull_exit(id, data, event) abort
"echom a:id . string(a:data) . string(a:event) . string(s:pulling_repos)
if a:data == 0
echom 'succeed to update ' . s:pulling_repos[a:id].name
else
echom 'failed to update ' . s:pulling_repos[a:id].name
endif
call s:msg_on_updated_done(s:pulling_repos[a:id].name)
call remove(s:pulling_repos, string(a:id))
if !empty(s:plugins)
call s:pull(dein#get(s:LIST.shift(s:plugins)))
endif
if empty(s:pulling_repos)
echom 'SpaceVim update done'
endif
endfunction
function! s:pull(repo) abort
let argv = ['git', '-C', a:repo.path, 'pull']
let jobid = s:JOB.start(argv,{
\ 'on_exit' : function('s:on_pull_exit')
\ })
if jobid != 0
let s:pulling_repos[jobid] = a:repo
call s:msg_on_start(a:repo.name)
endif
endfunction
function! s:msg_on_start(name) abort
" TODO update plugin manager ui
endfunction
function! s:msg_on_updated_done(name) abort
" TODO update plugin manager ui
endfunction

View File

@ -219,6 +219,9 @@ The default file manager of SpaceVim. Default is 'vimfiler'.
The default plugin manager of SpaceVim. Default is 'dein'. Options are dein, The default plugin manager of SpaceVim. Default is 'dein'. Options are dein,
neobundle, or vim-plug. neobundle, or vim-plug.
*g:spacevim_plugin_manager_max_processes*
Set the max process of SpaceVim plugin manager
*g:spacevim_checkinstall* *g:spacevim_checkinstall*
Enable/Disable checkinstall on SpaceVim startup. Default is 1. Enable/Disable checkinstall on SpaceVim startup. Default is 1.
> >