Mercurial > dotfiles.old
comparison 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 |
comparison
equal
deleted
inserted
replaced
239:537e6cfb7e97 | 240:1d4692adfc1c |
---|---|
71 let s:plug_src = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | 71 let s:plug_src = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' |
72 let s:plug_tab = get(s:, 'plug_tab', -1) | 72 let s:plug_tab = get(s:, 'plug_tab', -1) |
73 let s:plug_buf = get(s:, 'plug_buf', -1) | 73 let s:plug_buf = get(s:, 'plug_buf', -1) |
74 let s:mac_gui = has('gui_macvim') && has('gui_running') | 74 let s:mac_gui = has('gui_macvim') && has('gui_running') |
75 let s:is_win = has('win32') || has('win64') | 75 let s:is_win = has('win32') || has('win64') |
76 let s:ruby = has('ruby') && has('patch-7.2.374') | |
76 let s:nvim = has('nvim') && !s:is_win | 77 let s:nvim = has('nvim') && !s:is_win |
77 let s:me = resolve(expand('<sfile>:p')) | 78 let s:me = resolve(expand('<sfile>:p')) |
78 let s:base_spec = { 'branch': 'master', 'frozen': 0 } | 79 let s:base_spec = { 'branch': 'master', 'frozen': 0 } |
79 let s:TYPE = { | 80 let s:TYPE = { |
80 \ 'string': type(''), | 81 \ 'string': type(''), |
230 endfor | 231 endfor |
231 endfunction | 232 endfunction |
232 | 233 |
233 function! s:trim(str) | 234 function! s:trim(str) |
234 return substitute(a:str, '[\/]\+$', '', '') | 235 return substitute(a:str, '[\/]\+$', '', '') |
236 endfunction | |
237 | |
238 function! s:git_version_requirement(...) | |
239 let s:git_version = get(s:, 'git_version', | |
240 \ map(split(split(s:system('git --version'))[-1], '\.'), 'str2nr(v:val)')) | |
241 for idx in range(0, a:0 - 1) | |
242 let v = get(s:git_version, idx, 0) | |
243 if v < a:000[idx] | return 0 | |
244 elseif v > a:000[idx] | return 1 | |
245 endif | |
246 endfor | |
247 return 1 | |
248 endfunction | |
249 | |
250 function! s:progress_opt(base) | |
251 return a:base && !s:is_win && | |
252 \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' | |
235 endfunction | 253 endfunction |
236 | 254 |
237 if s:is_win | 255 if s:is_win |
238 function! s:rtp(spec) | 256 function! s:rtp(spec) |
239 return s:path(a:spec.dir . get(a:spec, 'rtp', '')) | 257 return s:path(a:spec.dir . get(a:spec, 'rtp', '')) |
715 \ 'todo': copy(todo), | 733 \ 'todo': copy(todo), |
716 \ 'errors': [], | 734 \ 'errors': [], |
717 \ 'pull': a:pull, | 735 \ 'pull': a:pull, |
718 \ 'force': a:force, | 736 \ 'force': a:force, |
719 \ 'new': {}, | 737 \ 'new': {}, |
720 \ 'threads': (has('ruby') || s:nvim) ? min([len(todo), threads]) : 1, | 738 \ 'threads': (s:ruby || s:nvim) ? min([len(todo), threads]) : 1, |
721 \ 'bar': '', | 739 \ 'bar': '', |
722 \ 'fin': 0 | 740 \ 'fin': 0 |
723 \ } | 741 \ } |
724 | 742 |
725 call s:prepare() | 743 call s:prepare() |
726 call append(0, ['', '']) | 744 call append(0, ['', '']) |
727 normal! 2G | 745 normal! 2G |
728 | 746 |
729 if has('ruby') && s:update.threads > 1 | 747 if s:ruby && s:update.threads > 1 |
730 try | 748 try |
731 let imd = &imd | 749 let imd = &imd |
732 if s:mac_gui | 750 if s:mac_gui |
733 set noimd | 751 set noimd |
734 endif | 752 endif |
899 call s:bar() | 917 call s:bar() |
900 call s:tick() | 918 call s:tick() |
901 endfunction | 919 endfunction |
902 | 920 |
903 function! s:tick() | 921 function! s:tick() |
922 let pull = s:update.pull | |
923 let prog = s:progress_opt(s:nvim) | |
904 while 1 " Without TCO, Vim stack is bound to explode | 924 while 1 " Without TCO, Vim stack is bound to explode |
905 if empty(s:update.todo) | 925 if empty(s:update.todo) |
906 if empty(s:jobs) && !s:update.fin | 926 if empty(s:jobs) && !s:update.fin |
907 let s:update.fin = 1 | 927 let s:update.fin = 1 |
908 call s:update_finish() | 928 call s:update_finish() |
910 return | 930 return |
911 endif | 931 endif |
912 | 932 |
913 let name = keys(s:update.todo)[0] | 933 let name = keys(s:update.todo)[0] |
914 let spec = remove(s:update.todo, name) | 934 let spec = remove(s:update.todo, name) |
915 let pull = s:update.pull | |
916 let new = !isdirectory(spec.dir) | 935 let new = !isdirectory(spec.dir) |
917 let prog = s:nvim ? '--progress' : '' | |
918 | 936 |
919 call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') | 937 call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') |
920 redraw | 938 redraw |
921 | 939 |
922 if !new | 940 if !new |
1106 end | 1124 end |
1107 sleep 0.2 | 1125 sleep 0.2 |
1108 end | 1126 end |
1109 } if VIM::evaluate('s:mac_gui') == 1 | 1127 } if VIM::evaluate('s:mac_gui') == 1 |
1110 | 1128 |
1111 progress = iswin ? '' : '--progress' | 1129 progress = VIM::evaluate('s:progress_opt(1)') |
1112 nthr.times do | 1130 nthr.times do |
1113 mtx.synchronize do | 1131 mtx.synchronize do |
1114 threads << Thread.new { | 1132 threads << Thread.new { |
1115 while pair = take1.call | 1133 while pair = take1.call |
1116 name = pair.first | 1134 name = pair.first |
1310 if executable('curl') | 1328 if executable('curl') |
1311 let output = s:system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_src)) | 1329 let output = s:system(printf('curl -fLo %s %s', s:shellesc(new), s:plug_src)) |
1312 if v:shell_error | 1330 if v:shell_error |
1313 throw get(s:lines(output), -1, v:shell_error) | 1331 throw get(s:lines(output), -1, v:shell_error) |
1314 endif | 1332 endif |
1315 elseif has('ruby') | 1333 elseif s:ruby |
1316 call s:upgrade_using_ruby(new) | 1334 call s:upgrade_using_ruby(new) |
1317 else | 1335 else |
1318 return s:err('curl executable or ruby support not found') | 1336 return s:err('curl executable or ruby support not found') |
1319 endif | 1337 endif |
1320 catch | 1338 catch |