SignifyDiff: initial support for :SignifyDiff

Currently this only works for git and is not documented.
This commit is contained in:
Marco Hinz 2018-04-11 16:23:43 +02:00
parent e76d00ccc0
commit 46699b1df6
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F
2 changed files with 41 additions and 0 deletions

View File

@ -244,6 +244,33 @@ function! sy#repo#debug_detection()
endfor
endfunction
" Function: #diffmode {{{1
function! sy#repo#diffmode() abort
if !exists('b:sy')
echomsg 'signify: I cannot detect any changes!'
return
endif
let vcs = b:sy.updated_by
if !has_key(g:signify_vcs_cmds_diffmode, vcs)
echomsg 'SignifyDiff has no support for: '. vcs
echomsg 'Open an issue for it at: https://github.com/mhinz/vim-signify/issues'
return
endif
let cmd = s:expand_cmd_diffmode(vcs)
let ft = &filetype
tabedit %
diffthis
leftabove vnew
silent put =system(cmd)
silent 1delete
diffthis
set buftype=nofile bufhidden=wipe nomodified
let &filetype = ft
wincmd p
silent! %foldopen!
normal! ]czt
endfunction
" Function: s:initialize_job {{{1
function! s:initialize_job(vcs) abort
let vcs_cmd = s:expand_cmd(a:vcs)
@ -279,6 +306,15 @@ function! s:expand_cmd(vcs) abort
return cmd
endfunction
" Function: s:expand_cmd_diffmode {{{1
function! s:expand_cmd_diffmode(vcs) abort
let cmd = g:signify_vcs_cmds_diffmode[a:vcs]
let cmd = s:replace(cmd, '%f', s:get_vcs_path(a:vcs))
let cmd = s:replace(cmd, '%d', s:difftool)
let cmd = s:replace(cmd, '%n', s:devnull)
return cmd
endfunction
" Function: s:run {{{1
function! s:run(vcs)
let [cwd, chdir] = sy#util#chdir()
@ -436,5 +472,9 @@ else
let g:signify_vcs_cmds = s:vcs_cmds
endif
let g:signify_vcs_cmds_diffmode = {
\ 'git': 'git show HEAD:./%f',
\ }
let s:difftool = sy#util#escape(s:difftool)
let s:devnull = has('win32') || has ('win64') ? 'NUL' : '/dev/null'

View File

@ -66,6 +66,7 @@ augroup END
command! -nargs=0 -bar SignifyList call sy#debug#list_active_buffers()
command! -nargs=0 -bar SignifyDebug call sy#repo#debug_detection()
command! -nargs=0 -bar -bang SignifyFold call sy#fold#dispatch(<bang>1)
command! -nargs=0 -bar SignifyDiff call sy#repo#diffmode()
command! -nargs=0 -bar SignifyRefresh call sy#util#refresh_windows()
command! -nargs=0 -bar SignifyEnable call sy#enable()
command! -nargs=0 -bar SignifyDisable call sy#disable()