Mercurial > dotfiles.old
comparison vim/autoload/plug.vim @ 213:4e723feac624
Update vimplug
author | zegervdv <zegervdv@me.com> |
---|---|
date | Tue, 02 Dec 2014 18:06:52 +0100 |
parents | e519bf689316 |
children | d216f4d5508e |
comparison
equal
deleted
inserted
replaced
212:aba6fdee2489 | 213:4e723feac624 |
---|---|
750 silent! call jobstop(j.jobid) | 750 silent! call jobstop(j.jobid) |
751 if j.new | 751 if j.new |
752 call system('rm -rf ' . s:shellesc(g:plugs[name].dir)) | 752 call system('rm -rf ' . s:shellesc(g:plugs[name].dir)) |
753 endif | 753 endif |
754 endfor | 754 endfor |
755 let s:jobs = {} | 755 let s:jobs = {} |
756 let s:jobs_idx = {} | 756 endfunction |
757 endfunction | 757 |
758 | 758 function! s:job_handler(name) abort |
759 function! s:job_handler() abort | |
760 if !s:plug_window_exists() " plug window closed | 759 if !s:plug_window_exists() " plug window closed |
761 return s:job_abort() | 760 return s:job_abort() |
762 endif | 761 endif |
763 | 762 |
764 let name = get(s:jobs_idx, v:job_data[0], '') | 763 if !has_key(s:jobs, a:name) |
765 if empty(name) " stale task | |
766 return | 764 return |
767 endif | 765 endif |
768 let job = s:jobs[name] | 766 let job = s:jobs[a:name] |
769 | 767 |
770 if v:job_data[1] == 'exit' | 768 if v:job_data[1] == 'exit' |
771 let job.running = 0 | 769 let job.running = 0 |
772 if s:lastline(job.result) ==# 'Error' | 770 if s:lastline(job.result) ==# 'Error' |
773 let job.error = 1 | 771 let job.error = 1 |
774 let job.result = substitute(job.result, "Error[\r\n]$", '', '') | 772 let job.result = substitute(job.result, "Error[\r\n]$", '', '') |
775 endif | 773 endif |
776 call s:reap(name) | 774 call s:reap(a:name) |
777 call s:tick() | 775 call s:tick() |
778 else | 776 else |
779 let job.result .= s:to_s(v:job_data[2]) | 777 let job.result .= s:to_s(v:job_data[2]) |
780 " To reduce the number of buffer updates | 778 " To reduce the number of buffer updates |
781 let job.tick = get(job, 'tick', -1) + 1 | 779 let job.tick = get(job, 'tick', -1) + 1 |
782 if job.tick % len(s:jobs) == 0 | 780 if job.tick % len(s:jobs) == 0 |
783 call s:log(job.new ? '+' : '*', name, job.result) | 781 call s:log(job.new ? '+' : '*', a:name, job.result) |
784 endif | 782 endif |
785 endif | 783 endif |
786 endfunction | 784 endfunction |
787 | 785 |
788 function! s:spawn(name, cmd, opts) | 786 function! s:spawn(name, cmd, opts) |
793 if s:nvim | 791 if s:nvim |
794 let x = jobstart(a:name, 'sh', ['-c', | 792 let x = jobstart(a:name, 'sh', ['-c', |
795 \ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) | 793 \ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) |
796 \ . ' || echo Error']) | 794 \ . ' || echo Error']) |
797 if x > 0 | 795 if x > 0 |
798 let s:jobs_idx[x] = a:name | |
799 let job.jobid = x | 796 let job.jobid = x |
800 augroup PlugJobControl | 797 augroup PlugJobControl |
801 execute 'autocmd JobActivity' a:name 'call s:job_handler()' | 798 execute 'autocmd JobActivity' a:name printf('call s:job_handler(%s)', string(a:name)) |
802 augroup END | 799 augroup END |
803 else | 800 else |
804 let job.running = 0 | 801 let job.running = 0 |
805 let job.error = 1 | 802 let job.error = 1 |
806 let job.result = x < 0 ? 'sh is not executable' : | 803 let job.result = x < 0 ? 'sh is not executable' : |
867 call s:switch_out() | 864 call s:switch_out() |
868 endif | 865 endif |
869 endfunction | 866 endfunction |
870 | 867 |
871 function! s:update_vim() | 868 function! s:update_vim() |
872 let s:jobs = {} | 869 let s:jobs = {} |
873 let s:jobs_idx = {} | |
874 | 870 |
875 call s:bar() | 871 call s:bar() |
876 call s:tick() | 872 call s:tick() |
877 endfunction | 873 endfunction |
878 | 874 |