diff --git a/autoload/airline/async.vim b/autoload/airline/async.vim index f52a4977..be82d6a8 100644 --- a/autoload/airline/async.vim +++ b/autoload/airline/async.vim @@ -85,9 +85,12 @@ function! airline#async#vcs_clean(cmd, file, vcs) if g:airline#init#vim_async " Vim 8 with async support noa call airline#async#vim_vcs_clean(a:cmd, a:file, a:vcs) - else - " nvim async or vim without job-feature + elseif has("nvim") + " nvim async noa call airline#async#nvim_vcs_clean(a:cmd, a:file, a:vcs) + else + " Vim pre 8 using system() + call airline#async#vim7_vcs_clean(a:cmd, a:file, a:vcs) endif endfunction @@ -282,6 +285,31 @@ elseif has("nvim") let s:po_jobs[a:file] = id endfunction + function! airline#async#nvim_vcs_clean(cmd, file, vcs) + let config = { + \ 'buf': '', + \ 'vcs': a:vcs, + \ 'file': a:file, + \ 'cwd': s:valid_dir(fnamemodify(a:file, ':p:h')), + \ 'on_stdout': function('s:nvim_output_handler'), + \ 'on_stderr': function('s:nvim_output_handler'), + \ 'on_exit': function('s:on_exit_clean')} + if g:airline#init#is_windows && &shell =~ 'cmd' + let cmd = a:cmd + else + let cmd = ['sh', '-c', a:cmd] + endif + + if !has_key(s:clean_jobs, a:vcs) + let s:clean_jobs[a:vcs] = {} + endif + if has_key(s:clean_jobs[a:vcs], a:file) + call remove(s:clean_jobs[a:vcs], a:file) + endif + let id = jobstart(cmd, config) + let s:clean_jobs[a:vcs][a:file] = id + endfunction + endif " Should work in either Vim pre 8 or Nvim @@ -319,36 +347,10 @@ function! airline#async#nvim_vcs_untracked(cfg, file, vcs) endif endfunction -function! airline#async#nvim_vcs_clean(cmd, file, vcs) - let config = { - \ 'buf': '', - \ 'vcs': a:vcs, - \ 'file': a:file, - \ 'cwd': s:valid_dir(fnamemodify(a:file, ':p:h'))} - if has("nvim") - call extenc(config, { - \ 'on_stdout': function('s:nvim_output_handler'), - \ 'on_stderr': function('s:nvim_output_handler'), - \ 'on_exit': function('s:on_exit_clean')}) - if g:airline#init#is_windows && &shell =~ 'cmd' - let cmd = a:cmd - else - let cmd = ['sh', '-c', a:cmd] - endif - - if !has_key(s:clean_jobs, a:vcs) - let s:clean_jobs[a:vcs] = {} - endif - if has_key(s:clean_jobs[a:vcs], a:file) - call remove(s:clean_jobs[a:vcs], a:file) - endif - let id = jobstart(cmd, config) - let s:clean_jobs[a:vcs][a:file] = id - else - " Vim pre 8 - let output=system(a:cmd) - if !empty(output) - call s:set_clean_variables(a:file, a:vcs) - endif +function! airline#async#vim7_vcs_clean(cmd, file, vcs) + " Vim pre 8, fallback using system() + let output=system(a:cmd) + if !empty(output) + call s:set_clean_variables(a:file, a:vcs) endif endfunction