Make Vim + system() work
This commit is contained in:
parent
a67b613acf
commit
0df130ac6e
@ -8,13 +8,6 @@ let g:sy_cache = {}
|
|||||||
|
|
||||||
let s:has_doau_modeline = v:version > 703 || v:version == 703 && has('patch442')
|
let s:has_doau_modeline = v:version > 703 || v:version == 703 && has('patch442')
|
||||||
|
|
||||||
" Function: #verbose {{{1
|
|
||||||
function! sy#verbose(msg) abort
|
|
||||||
if &verbose
|
|
||||||
echomsg printf('[sy] %s', a:msg)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: #start {{{1
|
" Function: #start {{{1
|
||||||
function! sy#start() abort
|
function! sy#start() abort
|
||||||
if g:signify_locked
|
if g:signify_locked
|
||||||
@ -72,7 +65,7 @@ function! sy#start() abort
|
|||||||
call sy#repo#detect(0)
|
call sy#repo#detect(0)
|
||||||
else
|
else
|
||||||
call sy#verbose('Updating signs.')
|
call sy#verbose('Updating signs.')
|
||||||
call sy#repo#get_diff_{b:sy.type}(0)
|
call sy#repo#get_diff_start(b:sy.type, 0)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -156,6 +149,13 @@ function! sy#buffer_is_active()
|
|||||||
return exists('b:sy') && b:sy.active
|
return exists('b:sy') && b:sy.active
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: #verbose {{{1
|
||||||
|
function! sy#verbose(msg) abort
|
||||||
|
if &verbose
|
||||||
|
echomsg printf('[sy] %s', a:msg)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Function: s:skip {{{1
|
" Function: s:skip {{{1
|
||||||
function! s:skip(path)
|
function! s:skip(path)
|
||||||
if &diff || !filereadable(a:path)
|
if &diff || !filereadable(a:path)
|
||||||
|
@ -16,15 +16,8 @@ function! sy#repo#detect(do_register) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
for type in vcs_list
|
for type in vcs_list
|
||||||
call sy#repo#get_diff_{type}(a:do_register)
|
call sy#repo#get_diff_start(type, a:do_register)
|
||||||
endfor
|
endfor
|
||||||
" let [istype, diff] = sy#repo#get_diff_{type}()
|
|
||||||
" if istype
|
|
||||||
" return [diff, type]
|
|
||||||
" endif
|
|
||||||
" endfor
|
|
||||||
|
|
||||||
" return ['', 'unknown']
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:callback_stdout_nvim {{{1
|
" Function: s:callback_stdout_nvim {{{1
|
||||||
@ -40,36 +33,52 @@ endfunction
|
|||||||
|
|
||||||
" Function: s:callback_exit {{{1
|
" Function: s:callback_exit {{{1
|
||||||
function! s:callback_exit(_job_id, exitcode, _event) dict abort
|
function! s:callback_exit(_job_id, exitcode, _event) dict abort
|
||||||
call sy#verbose('Running callback_exit(). Exit code: '. a:exitcode)
|
call sy#verbose('Running callback_exit().')
|
||||||
let [found_diff, diff] = a:exitcode ? [0, ''] : [1, join(self.stdoutbuf, "\n")]
|
call s:get_diff_end(a:exitcode, join(self.stdoutbuf, "\n"), self.do_register)
|
||||||
if found_diff
|
endfunction
|
||||||
|
|
||||||
|
" Function: sy#get_diff_start {{{1
|
||||||
|
function! sy#repo#get_diff_start(vcs, do_register) abort
|
||||||
|
if has('nvim')
|
||||||
|
let id = get(b:, 'job_id_'. a:vcs)
|
||||||
|
if id
|
||||||
|
silent! call jobstop(id)
|
||||||
|
endif
|
||||||
|
let cmd = s:expand_cmd(g:signify_vcs_cmds[a:vcs], b:sy_info.file)
|
||||||
|
let cmd = (has('win32') && &shell =~ 'cmd') ? cmd : ['sh', '-c', cmd]
|
||||||
|
execute b:sy_info.chdir fnameescape(b:sy_info.dir)
|
||||||
|
try
|
||||||
|
let s:job_id_git = jobstart(cmd, {
|
||||||
|
\ 'stdoutbuf': [],
|
||||||
|
\ 'do_register': a:do_register,
|
||||||
|
\ 'on_stdout': function('s:callback_stdout_nvim'),
|
||||||
|
\ 'on_exit': function('s:callback_exit'),
|
||||||
|
\ })
|
||||||
|
finally
|
||||||
|
execute b:sy_info.chdir b:sy_info.cwd
|
||||||
|
endtry
|
||||||
|
else
|
||||||
|
let diff = s:run(g:signify_vcs_cmds[a:vcs], b:sy_info.path)
|
||||||
|
call s:get_diff_end(v:shell_error, diff, a:do_register)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Function: s:get_diff_end {{{1
|
||||||
|
function! s:get_diff_end(exitcode, diff, do_register) abort
|
||||||
|
if !a:exitcode
|
||||||
let b:sy.type = 'git'
|
let b:sy.type = 'git'
|
||||||
endif
|
endif
|
||||||
if !self.do_register
|
if !a:do_register
|
||||||
let b:sy.id_top = g:id_top
|
let b:sy.id_top = g:id_top
|
||||||
endif
|
endif
|
||||||
call sy#set_signs(diff, self.do_register)
|
call sy#set_signs(a:diff, a:do_register)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: #get_diff_git {{{1
|
" Function: #get_diff_git {{{1
|
||||||
function! sy#repo#get_diff_git(do_register) abort
|
function! sy#repo#get_diff_git(exitcode, diff, do_register) abort
|
||||||
call sy#verbose('Running get_diff_git().')
|
call sy#verbose('Running get_diff_git().')
|
||||||
let cmd = s:expand_cmd(g:signify_vcs_cmds.git, b:sy_info.file)
|
let [found_diff, diff] = a:exitcode ? [0, ''] : [1, join(self.stdoutbuf, "\n")]
|
||||||
let cmd = (has('win32') && &shell =~ 'cmd') ? cmd : ['sh', '-c', cmd]
|
call s:get_diff_end(found_diff, diff, self.do_register)
|
||||||
if exists('s:job_id_git')
|
|
||||||
silent! call jobstop(s:job_id_git)
|
|
||||||
endif
|
|
||||||
execute b:sy_info.chdir fnameescape(b:sy_info.dir)
|
|
||||||
try
|
|
||||||
let s:job_id_git = jobstart(cmd, {
|
|
||||||
\ 'stdoutbuf': [],
|
|
||||||
\ 'do_register': a:do_register,
|
|
||||||
\ 'on_stdout': function('s:callback_stdout_nvim'),
|
|
||||||
\ 'on_exit': function('s:callback_exit'),
|
|
||||||
\ })
|
|
||||||
finally
|
|
||||||
execute b:sy_info.chdir b:sy_info.cwd
|
|
||||||
endtry
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: #get_diff_hg {{{1
|
" Function: #get_diff_hg {{{1
|
||||||
|
Loading…
Reference in New Issue
Block a user