Spawn multiple threads unless g:plug_threads is set to 1
This commit is contained in:
parent
214b4fb6fa
commit
2cf0c4fda5
16
README.md
16
README.md
|
@ -73,16 +73,14 @@ installation.
|
||||||
|
|
||||||
A `Plugfile` should contain a set of `Plug` commands for the dependent plugins.
|
A `Plugfile` should contain a set of `Plug` commands for the dependent plugins.
|
||||||
|
|
||||||
I've created two dummy repositories with Plugfiles as an example to this scheme.
|
I've created three dummy repositories with Plugfiles as an example to this
|
||||||
|
scheme.
|
||||||
|
|
||||||
- [junegunn/dummy1](https://github.com/junegunn/dummy1)
|
- [junegunn/dummy1](https://github.com/junegunn/dummy1/blob/master/Plugfile)
|
||||||
- `Plug 'junegunn/vim-scroll-position'`
|
- Plugfile includes `Plug 'junegunn/dummy2'`
|
||||||
- `Plug 'junegunn/dummy2'`
|
- [junegunn/dummy2](https://github.com/junegunn/dummy2/blob/master/Plugfile)
|
||||||
- [junegunn/dummy2](https://github.com/junegunn/dummy2)
|
- Plugfile includes `Plug 'junegunn/dummy3'`
|
||||||
- `Plug 'junegunn/Zenburn'`
|
- [junegunn/dummy3](https://github.com/junegunn/dummy3/blob/master/Plugfile)
|
||||||
- `Plug 'junegunn/jellybeans.vim'`
|
|
||||||
- `Plug 'junegunn/dummy1'`
|
|
||||||
- (Circular dependencies are ignored)
|
|
||||||
|
|
||||||
If you put `Plug 'junegunn/dummy1'` in your configuration file, and run
|
If you put `Plug 'junegunn/dummy1'` in your configuration file, and run
|
||||||
`:PlugInstall`,
|
`:PlugInstall`,
|
||||||
|
|
20
plug.vim
20
plug.vim
|
@ -217,12 +217,7 @@ function! s:finish()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:update_impl(pull, args)
|
function! s:update_impl(pull, args)
|
||||||
if has('ruby') && get(g:, 'plug_parallel', 1)
|
let threads = len(a:args) > 0 ? a:args[0] : get(g:, 'plug_threads', 16)
|
||||||
let threads = min(
|
|
||||||
\ [len(g:plugs), len(a:args) > 0 ? a:args[0] : get(g:, 'plug_threads', 16)])
|
|
||||||
else
|
|
||||||
let threads = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
call s:prepare()
|
call s:prepare()
|
||||||
call append(0, a:pull ? 'Updating plugins' : 'Installing plugins')
|
call append(0, a:pull ? 'Updating plugins' : 'Installing plugins')
|
||||||
|
@ -230,7 +225,7 @@ function! s:update_impl(pull, args)
|
||||||
normal! 2G
|
normal! 2G
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
if threads > 1
|
if has('ruby') && threads > 1
|
||||||
call s:update_parallel(a:pull, threads)
|
call s:update_parallel(a:pull, threads)
|
||||||
else
|
else
|
||||||
call s:update_serial(a:pull)
|
call s:update_serial(a:pull)
|
||||||
|
@ -255,8 +250,9 @@ function! s:extend(names)
|
||||||
return filter(copy(g:plugs), '!has_key(prev, v:key)')
|
return filter(copy(g:plugs), '!has_key(prev, v:key)')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:update_progress(cnt, total)
|
function! s:update_progress(pull, cnt, total)
|
||||||
call setline(1, "Updating plugins (".a:cnt."/".a:total.")")
|
call setline(1, (a:pull ? 'Updating' : 'Installing').
|
||||||
|
\ " plugins (".a:cnt."/".a:total.")")
|
||||||
call s:progress_bar(2, a:cnt, a:total)
|
call s:progress_bar(2, a:cnt, a:total)
|
||||||
normal! 2G
|
normal! 2G
|
||||||
redraw
|
redraw
|
||||||
|
@ -300,13 +296,13 @@ function! s:update_serial(pull)
|
||||||
let result = '(x) ' . result
|
let result = '(x) ' . result
|
||||||
endif
|
endif
|
||||||
call append(3, '- ' . name . ': ' . result)
|
call append(3, '- ' . name . ': ' . result)
|
||||||
call s:update_progress(len(done), total)
|
call s:update_progress(a:pull, len(done), total)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
if !empty(s:extend(keys(todo)))
|
if !empty(s:extend(keys(todo)))
|
||||||
let todo = filter(copy(g:plugs), '!has_key(done, v:key)')
|
let todo = filter(copy(g:plugs), '!has_key(done, v:key)')
|
||||||
let total += len(todo)
|
let total += len(todo)
|
||||||
call s:update_progress(len(done), total)
|
call s:update_progress(a:pull, len(done), total)
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
|
@ -330,7 +326,7 @@ function! s:update_parallel(pull, threads)
|
||||||
take1 = proc { mtx.synchronize { all.shift } }
|
take1 = proc { mtx.synchronize { all.shift } }
|
||||||
logh = proc {
|
logh = proc {
|
||||||
cnt, tot = done.length, VIM::evaluate('len(g:plugs)')
|
cnt, tot = done.length, VIM::evaluate('len(g:plugs)')
|
||||||
$curbuf[1] = "Updating plugins (#{cnt}/#{tot})"
|
$curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})"
|
||||||
$curbuf[2] = '[' + ('=' * cnt).ljust(tot) + ']'
|
$curbuf[2] = '[' + ('=' * cnt).ljust(tot) + ']'
|
||||||
VIM::command('normal! 2G')
|
VIM::command('normal! 2G')
|
||||||
VIM::command('redraw')
|
VIM::command('redraw')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user