Mercurial > dotfiles.old
diff vim/autoload/plug.vim @ 240:1d4692adfc1c
Upgrade vimplug
author | zegervdv <zegervdv@me.com> |
---|---|
date | Wed, 11 Feb 2015 17:46:22 +0100 |
parents | 6f3eb83613bf |
children | 0994a5f99432 |
line wrap: on
line diff
--- a/vim/autoload/plug.vim Wed Feb 11 17:44:46 2015 +0100 +++ b/vim/autoload/plug.vim Wed Feb 11 17:46:22 2015 +0100 @@ -73,6 +73,7 @@ let s:plug_buf = get(s:, 'plug_buf', -1) let s:mac_gui = has('gui_macvim') && has('gui_running') let s:is_win = has('win32') || has('win64') +let s:ruby = has('ruby') && has('patch-7.2.374') let s:nvim = has('nvim') && !s:is_win let s:me = resolve(expand('<sfile>:p')) let s:base_spec = { 'branch': 'master', 'frozen': 0 } @@ -234,6 +235,23 @@ return substitute(a:str, '[\/]\+$', '', '') endfunction +function! s:git_version_requirement(...) + let s:git_version = get(s:, 'git_version', + \ map(split(split(s:system('git --version'))[-1], '\.'), 'str2nr(v:val)')) + for idx in range(0, a:0 - 1) + let v = get(s:git_version, idx, 0) + if v < a:000[idx] | return 0 + elseif v > a:000[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + if s:is_win function! s:rtp(spec) return s:path(a:spec.dir . get(a:spec, 'rtp', '')) @@ -717,7 +735,7 @@ \ 'pull': a:pull, \ 'force': a:force, \ 'new': {}, - \ 'threads': (has('ruby') || s:nvim) ? min([len(todo), threads]) : 1, + \ 'threads': (s:ruby || s:nvim) ? min([len(todo), threads]) : 1, \ 'bar': '', \ 'fin': 0 \ } @@ -726,7 +744,7 @@ call append(0, ['', '']) normal! 2G - if has('ruby') && s:update.threads > 1 + if s:ruby && s:update.threads > 1 try let imd = &imd if s:mac_gui @@ -901,6 +919,8 @@ endfunction function! s:tick() + let pull = s:update.pull + let prog = s:progress_opt(s:nvim) while 1 " Without TCO, Vim stack is bound to explode if empty(s:update.todo) if empty(s:jobs) && !s:update.fin @@ -912,9 +932,7 @@ let name = keys(s:update.todo)[0] let spec = remove(s:update.todo, name) - let pull = s:update.pull let new = !isdirectory(spec.dir) - let prog = s:nvim ? '--progress' : '' call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') redraw @@ -1108,7 +1126,7 @@ end } if VIM::evaluate('s:mac_gui') == 1 - progress = iswin ? '' : '--progress' + progress = VIM::evaluate('s:progress_opt(1)') nthr.times do mtx.synchronize do threads << Thread.new { @@ -1312,7 +1330,7 @@ if v:shell_error throw get(s:lines(output), -1, v:shell_error) endif - elseif has('ruby') + elseif s:ruby call s:upgrade_using_ruby(new) else return s:err('curl executable or ruby support not found')