branch: make it work with vim74

closes #1907
This commit is contained in:
Christian Brabandt 2019-04-25 14:43:56 +02:00
parent 9c1486522a
commit 6b213e1071
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -64,13 +64,17 @@ function! airline#async#vcs_untracked(config, file, vcs)
endif
endfunction
function! s:set_clean_variables(file, vcs)
let var=getbufvar(fnameescape(a:file), 'buffer_vcs_config', {})
let var[a:vcs].dirty=1
call setbufvar(fnameescape(a:file), 'buffer_vcs_config', var)
unlet! b:airline_head
endfunction
function! s:on_exit_clean(...) dict abort
let buf=self.buf
if !empty(buf)
let var=getbufvar(fnameescape(self.file), 'buffer_vcs_config', {})
let var[self.vcs].dirty=1
call setbufvar(fnameescape(self.file), 'buffer_vcs_config', var)
unlet! b:airline_head
call s:set_clean_variables(self.file, self.vcs)
endif
if has_key(get(s:clean_jobs, 'self.vcs', {}), self.file)
call remove(s:clean_jobs[self.vcs], self.file)
@ -255,32 +259,6 @@ elseif has("nvim")
let s:mq_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
function! airline#async#nvim_get_msgfmt_stat(cmd, file)
let config = {
\ 'buf': '',
@ -340,3 +318,37 @@ function! airline#async#nvim_vcs_untracked(cfg, file, vcs)
call airline#extensions#branch#update_untracked_config(a:file, a: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
endif
endfunction