From b32169ff30eb7375453ab35eb23a14dc4e7ddd6a Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 13 Oct 2016 13:17:17 +0900 Subject: [PATCH 1/7] Use job_start on vim Close #498 Close #534 --- .travis.yml | 1 + plug.vim | 122 ++++++++++++++++++++++++++++++++++-------------- test/test.vader | 10 +++- 3 files changed, 97 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index c60eef6..15277c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ matrix: - env: ENV=ruby20 rvm: 2.0.0 - env: ENV=neovim + - env: ENV=vim8 install: | git config --global user.email "you@example.com" git config --global user.name "Your Name" diff --git a/plug.vim b/plug.vim index 2c38a68..0d00f45 100644 --- a/plug.vim +++ b/plug.vim @@ -98,6 +98,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:nvim = has('nvim') && exists('*jobwait') && !s:is_win +let s:vim8 = has('patch-8.0.0001') && exists('*job_start') let s:me = resolve(expand(':p')) let s:base_spec = { 'branch': 'master', 'frozen': 0 } let s:TYPE = { @@ -948,8 +949,9 @@ function! s:update_impl(pull, force, args) abort call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') endif - let python = (has('python') || has('python3')) && !s:nvim - let ruby = has('ruby') && !s:nvim && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && s:check_ruby() + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && s:check_ruby() let s:update = { \ 'start': reltime(), @@ -959,7 +961,7 @@ function! s:update_impl(pull, force, args) abort \ 'pull': a:pull, \ 'force': a:force, \ 'new': {}, - \ 'threads': (python || ruby || s:nvim) ? min([len(todo), threads]) : 1, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, \ 'bar': '', \ 'fin': 0 \ } @@ -973,7 +975,7 @@ function! s:update_impl(pull, force, args) abort \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' " Python version requirement (>= 2.7) - if python && !has('python3') && !ruby && !s:nvim && s:update.threads > 1 + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 redir => pyv silent python import platform; print platform.python_version() redir END @@ -1014,7 +1016,7 @@ function! s:update_impl(pull, force, args) abort endtry else call s:update_vim() - while s:nvim && has('vim_starting') + while use_job && has('vim_starting') sleep 100m if s:update.fin break @@ -1091,12 +1093,16 @@ function! s:update_finish() endfunction function! s:job_abort() - if !s:nvim || !exists('s:jobs') + if (!s:nvim && !s:vim8) || !exists('s:jobs') return endif for [name, j] in items(s:jobs) - silent! call jobstop(j.jobid) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif if j.new call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir)) endif @@ -1104,56 +1110,104 @@ function! s:job_abort() let s:jobs = {} endfunction +function! s:job_out_cb(self, ch, data) abort + let self = a:self + let complete = empty(a:data[-1]) + let lines = map(filter(a:data, 'v:val =~ "[^\r\n]"'), 'split(v:val, "[\r\n]")[-1]') + call extend(self.lines, lines) + let self.result = join(self.lines, "\n") + if !complete + call remove(self.lines, -1) + endif + " To reduce the number of buffer updates + let self.tick = get(self, 'tick', -1) + 1 + if self.tick % len(s:jobs) == 0 + call s:log(self.new ? '+' : '*', self.name, self.result) + endif +endfunction + +function! s:job_exit_cb(self, ch, data) abort + let self = a:self + call s:reap(self.name) + call s:tick() +endfunction + +function! s:find_job(ch) + for j in keys(s:jobs) + if s:jobs[j].jobid == a:ch + return s:jobs[j] + endif + endfor + return {} +endfunction + +function! s:vim8_out_cb(ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + let self = s:find_job(a:ch) + if !empty(self) + call s:job_out_cb(self, a:ch, a:data) + endif +endfunction + +function! s:vim8_exit_cb(ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + let self = s:find_job(a:ch) + if !empty(self) + call s:job_exit_cb(self, a:ch, a:data) + endif +endfunction + " When a:event == 'stdout', data = list of strings " When a:event == 'exit', data = returncode -function! s:job_handler(job_id, data, event) abort +function! s:nvim_job_handler(job_id, data, event) abort if !s:plug_window_exists() " plug window closed return s:job_abort() endif if a:event == 'stdout' - let complete = empty(a:data[-1]) - let lines = map(filter(a:data, 'v:val =~ "[^\r\n]"'), 'split(v:val, "[\r\n]")[-1]') - call extend(self.lines, lines) - let self.result = join(self.lines, "\n") - if !complete - call remove(self.lines, -1) - endif - " To reduce the number of buffer updates - let self.tick = get(self, 'tick', -1) + 1 - if self.tick % len(s:jobs) == 0 - call s:log(self.new ? '+' : '*', self.name, self.result) - endif + call s:job_out_cb(self, a:job_id, a:data) elseif a:event == 'exit' - let self.running = 0 - if a:data != 0 - let self.error = 1 - endif - call s:reap(self.name) - call s:tick() + call s:job_exit_cb(self, a:job_id, a:data) endif endfunction function! s:spawn(name, cmd, opts) let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [], 'result': '', - \ 'new': get(a:opts, 'new', 0), - \ 'on_stdout': function('s:job_handler'), - \ 'on_exit' : function('s:job_handler'), - \ } + \ 'new': get(a:opts, 'new', 0) } let s:jobs[a:name] = job + let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], + \ has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) if s:nvim - let argv = [ 'sh', '-c', - \ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) ] + call extend(job, { + \ 'on_stdout': function('s:nvim_job_handler'), + \ 'on_exit': function('s:nvim_job_handler'), + \ }) let jid = jobstart(argv, job) if jid > 0 let job.jobid = jid else let job.running = 0 let job.error = 1 - let job.result = jid < 0 ? 'sh is not executable' : + let job.result = jid < 0 ? argv[0].' is not executable' : \ 'Invalid arguments (or job table is full)' endif + elseif s:vim8 + let jid = job_start(argv, { + \ 'out_cb': function('s:vim8_out_cb'), + \ 'exit_cb': function('s:vim8_exit_cb') + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.result = 'Failed to start job' + endif else let params = has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd] let job.result = call('s:system', params) @@ -1220,7 +1274,7 @@ endfunction function! s:tick() let pull = s:update.pull - let prog = s:progress_opt(s:nvim) + let prog = s:progress_opt(s:nvim || s:vim8) while 1 " Without TCO, Vim stack is bound to explode if empty(s:update.todo) if empty(s:jobs) && !s:update.fin diff --git a/test/test.vader b/test/test.vader index 85f94f8..eaa444c 100644 --- a/test/test.vader +++ b/test/test.vader @@ -14,9 +14,15 @@ Execute (Initialize test environment): " Temporarily patch plug.vim call system('cp "$PLUG_SRC" "$PLUG_TMP"') - call writefile(extend(readfile($PLUG_TMP), + let patch = \ ['function! ResetPlug()', 'let s:loaded = {}', 'endfunction', - \ 'function! CompareURI(a, b)', 'return s:compare_git_uri(a:a, a:b)', 'endfunction']), $PLUG_TMP) + \ 'function! CompareURI(a, b)', 'return s:compare_git_uri(a:a, a:b)', 'endfunction'] + + if $ENV != 'vim8' + call add(patch, 'let s:vim8 = 0') + endif + + call writefile(extend(readfile($PLUG_TMP), patch), $PLUG_TMP) set t_Co=256 colo default From 759103d074cb7bfd8a42d43e847805a313179c25 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 17 Oct 2016 17:51:42 +0900 Subject: [PATCH 2/7] Refactor job callbacks with partial --- plug.vim | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/plug.vim b/plug.vim index 0d00f45..e8eb0c7 100644 --- a/plug.vim +++ b/plug.vim @@ -1110,7 +1110,7 @@ function! s:job_abort() let s:jobs = {} endfunction -function! s:job_out_cb(self, ch, data) abort +function! s:job_out_cb(self, data) abort let self = a:self let complete = empty(a:data[-1]) let lines = map(filter(a:data, 'v:val =~ "[^\r\n]"'), 'split(v:val, "[\r\n]")[-1]') @@ -1126,39 +1126,17 @@ function! s:job_out_cb(self, ch, data) abort endif endfunction -function! s:job_exit_cb(self, ch, data) abort +function! s:job_exit_cb(self, data) abort let self = a:self call s:reap(self.name) call s:tick() endfunction -function! s:find_job(ch) - for j in keys(s:jobs) - if s:jobs[j].jobid == a:ch - return s:jobs[j] - endif - endfor - return {} -endfunction - -function! s:vim8_out_cb(ch, data) +function! s:vim8_cb(fn, job, ch, data) if !s:plug_window_exists() " plug window closed return s:job_abort() endif - let self = s:find_job(a:ch) - if !empty(self) - call s:job_out_cb(self, a:ch, a:data) - endif -endfunction - -function! s:vim8_exit_cb(ch, data) - if !s:plug_window_exists() " plug window closed - return s:job_abort() - endif - let self = s:find_job(a:ch) - if !empty(self) - call s:job_exit_cb(self, a:ch, a:data) - endif + call call(a:fn, [a:job, split(a:data, '[\r\n]', 1)]) endfunction " When a:event == 'stdout', data = list of strings @@ -1169,9 +1147,9 @@ function! s:nvim_job_handler(job_id, data, event) abort endif if a:event == 'stdout' - call s:job_out_cb(self, a:job_id, a:data) + call s:job_out_cb(self, a:data) elseif a:event == 'exit' - call s:job_exit_cb(self, a:job_id, a:data) + call s:job_exit_cb(self, a:data) endif endfunction @@ -1198,8 +1176,8 @@ function! s:spawn(name, cmd, opts) endif elseif s:vim8 let jid = job_start(argv, { - \ 'out_cb': function('s:vim8_out_cb'), - \ 'exit_cb': function('s:vim8_exit_cb') + \ 'callback': function('s:vim8_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:vim8_cb', ['s:job_exit_cb', job]) \}) if job_status(jid) == 'run' let job.jobid = jid From 6bff19c2a935af0f472ce8d33f7a2f7eed6fa2e1 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 17 Oct 2016 17:52:13 +0900 Subject: [PATCH 3/7] Set out_mode to raw for progress report --- plug.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index e8eb0c7..f5ab1bf 100644 --- a/plug.vim +++ b/plug.vim @@ -1177,7 +1177,8 @@ function! s:spawn(name, cmd, opts) elseif s:vim8 let jid = job_start(argv, { \ 'callback': function('s:vim8_cb', ['s:job_out_cb', job]), - \ 'exit_cb': function('s:vim8_cb', ['s:job_exit_cb', job]) + \ 'exit_cb': function('s:vim8_cb', ['s:job_exit_cb', job]), + \ 'out_mode': 'raw' \}) if job_status(jid) == 'run' let job.jobid = jid From b94607b172334ef61b89c4c6cd64dea00da17c26 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 17 Oct 2016 18:00:20 +0900 Subject: [PATCH 4/7] Update README: +job --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46f843d..33e5710 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A minimalist Vim plugin manager. - Easier to setup: Single file. No boilerplate code required. - Easier to use: Concise, intuitive syntax - [Super-fast][40/4] parallel installation/update - (with any of `+python`, `+python3`, `+ruby`, or [Neovim][nv]) + (with any of `+job`, `+python`, `+python3`, `+ruby`, or [Neovim][nv]) - Creates shallow clones to minimize disk space usage and download time - On-demand loading for [faster startup time][startup-time] - Can review and rollback updates From d1022e948e19b0cb8f4db7ae48b736044074225f Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 18 Oct 2016 00:31:36 +0900 Subject: [PATCH 5/7] Address out-of-order invocation of out_cb and exit_cb --- plug.vim | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/plug.vim b/plug.vim index f5ab1bf..c250296 100644 --- a/plug.vim +++ b/plug.vim @@ -1121,36 +1121,28 @@ function! s:job_out_cb(self, data) abort endif " To reduce the number of buffer updates let self.tick = get(self, 'tick', -1) + 1 - if self.tick % len(s:jobs) == 0 - call s:log(self.new ? '+' : '*', self.name, self.result) + if !self.running || self.tick % len(s:jobs) == 0 + let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-') + call s:log(bullet, self.name, self.result) endif endfunction function! s:job_exit_cb(self, data) abort - let self = a:self - call s:reap(self.name) + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) call s:tick() endfunction -function! s:vim8_cb(fn, job, ch, data) +function! s:job_cb(fn, job, ch, data) if !s:plug_window_exists() " plug window closed return s:job_abort() endif - call call(a:fn, [a:job, split(a:data, '[\r\n]', 1)]) + call call(a:fn, [a:job, a:data]) endfunction -" When a:event == 'stdout', data = list of strings -" When a:event == 'exit', data = returncode -function! s:nvim_job_handler(job_id, data, event) abort - if !s:plug_window_exists() " plug window closed - return s:job_abort() - endif - - if a:event == 'stdout' - call s:job_out_cb(self, a:data) - elseif a:event == 'exit' - call s:job_exit_cb(self, a:data) - endif +function! s:nvim_cb(job_id, data, event) abort + call s:job_cb(a:event == 'stdout' ? 's:job_out_cb' : 's:job_exit_cb', self, 0, a:data) endfunction function! s:spawn(name, cmd, opts) @@ -1162,8 +1154,8 @@ function! s:spawn(name, cmd, opts) if s:nvim call extend(job, { - \ 'on_stdout': function('s:nvim_job_handler'), - \ 'on_exit': function('s:nvim_job_handler'), + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), \ }) let jid = jobstart(argv, job) if jid > 0 @@ -1176,8 +1168,8 @@ function! s:spawn(name, cmd, opts) endif elseif s:vim8 let jid = job_start(argv, { - \ 'callback': function('s:vim8_cb', ['s:job_out_cb', job]), - \ 'exit_cb': function('s:vim8_cb', ['s:job_exit_cb', job]), + \ 'out_cb': { c, d -> s:job_cb('s:job_out_cb', job, c, split(d, '[\r\n]', 1)) }, + \ 'exit_cb': { c, d -> s:job_cb('s:job_exit_cb', job, c, d) }, \ 'out_mode': 'raw' \}) if job_status(jid) == 'run' From 1bbb7a55e349f8634078b20aa1875fe5f52ea56e Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 18 Oct 2016 00:32:27 +0900 Subject: [PATCH 6/7] Update Vim 8 requirement https://github.com/junegunn/vim-plug/issues/498#issuecomment-254239466 --- plug.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index c250296..351874b 100644 --- a/plug.vim +++ b/plug.vim @@ -98,7 +98,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:nvim = has('nvim') && exists('*jobwait') && !s:is_win -let s:vim8 = has('patch-8.0.0001') && exists('*job_start') +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') let s:me = resolve(expand(':p')) let s:base_spec = { 'branch': 'master', 'frozen': 0 } let s:TYPE = { From 6287ba88d5e411db2a104a96efc2dde6928ae2a6 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 18 Oct 2016 13:14:43 +0900 Subject: [PATCH 7/7] Fix installer output - Same output format across different installers - Avoid unnecessary construction of result string - Fix multi-line error logging when exit_cb is called before out_cb --- plug.vim | 74 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/plug.vim b/plug.vim index 351874b..c4c92e8 100644 --- a/plug.vim +++ b/plug.vim @@ -1037,7 +1037,7 @@ function! s:update_finish() if s:switch_in() call append(3, '- Updating ...') | 4 for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) - let pos = s:logpos(name) + let [pos, _] = s:logpos(name) if !pos continue endif @@ -1110,20 +1110,28 @@ function! s:job_abort() let s:jobs = {} endfunction +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction + function! s:job_out_cb(self, data) abort let self = a:self - let complete = empty(a:data[-1]) - let lines = map(filter(a:data, 'v:val =~ "[^\r\n]"'), 'split(v:val, "[\r\n]")[-1]') + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') call extend(self.lines, lines) - let self.result = join(self.lines, "\n") - if !complete - call remove(self.lines, -1) - endif " To reduce the number of buffer updates let self.tick = get(self, 'tick', -1) + 1 if !self.running || self.tick % len(s:jobs) == 0 let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-') - call s:log(bullet, self.name, self.result) + let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) + call s:log(bullet, self.name, result) endif endfunction @@ -1142,11 +1150,13 @@ function! s:job_cb(fn, job, ch, data) endfunction function! s:nvim_cb(job_id, data, event) abort - call s:job_cb(a:event == 'stdout' ? 's:job_out_cb' : 's:job_exit_cb', self, 0, a:data) + return a:event == 'stdout' ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) endfunction function! s:spawn(name, cmd, opts) - let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [], 'result': '', + let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], \ 'new': get(a:opts, 'new', 0) } let s:jobs[a:name] = job let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], @@ -1163,13 +1173,13 @@ function! s:spawn(name, cmd, opts) else let job.running = 0 let job.error = 1 - let job.result = jid < 0 ? argv[0].' is not executable' : - \ 'Invalid arguments (or job table is full)' + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] endif elseif s:vim8 let jid = job_start(argv, { - \ 'out_cb': { c, d -> s:job_cb('s:job_out_cb', job, c, split(d, '[\r\n]', 1)) }, - \ 'exit_cb': { c, d -> s:job_cb('s:job_exit_cb', job, c, d) }, + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), \ 'out_mode': 'raw' \}) if job_status(jid) == 'run' @@ -1177,11 +1187,11 @@ function! s:spawn(name, cmd, opts) else let job.running = 0 let job.error = 1 - let job.result = 'Failed to start job' + let job.lines = ['Failed to start job'] endif else let params = has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd] - let job.result = call('s:system', params) + let job.lines = s:lines(call('s:system', params)) let job.error = v:shell_error != 0 let job.running = 0 endif @@ -1196,7 +1206,9 @@ function! s:reap(name) endif let s:update.bar .= job.error ? 'x' : '=' - call s:log(job.error ? 'x' : '-', a:name, empty(job.result) ? 'OK' : job.result) + let bullet = job.error ? 'x' : '-' + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + call s:log(bullet, a:name, empty(result) ? 'OK' : result) call s:bar() call remove(s:jobs, a:name) @@ -1215,23 +1227,31 @@ endfunction function! s:logpos(name) for i in range(4, line('$')) if getline(i) =~# '^[-+x*] '.a:name.':' - return i + for j in range(i + 1, line('$')) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] endif endfor + return [0, 0] endfunction function! s:log(bullet, name, lines) if s:switch_in() - let pos = s:logpos(a:name) - if pos > 0 - silent execute pos 'd _' - if pos > winheight('.') - let pos = 4 + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 endif else - let pos = 4 + let b = 4 endif - call append(pos - 1, s:format_message(a:bullet, a:name, a:lines)) + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) call s:switch_out() endif endfunction @@ -1270,10 +1290,10 @@ while 1 " Without TCO, Vim stack is bound to explode let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir }) else - let s:jobs[name] = { 'running': 0, 'result': 'Already installed', 'error': 0 } + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } endif else - let s:jobs[name] = { 'running': 0, 'result': error, 'error': 1 } + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } endif else call s:spawn(name,