From f011cb3577bd5baaeaef9fda55155817f7539ccd Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 8 Mar 2018 03:18:46 -0500 Subject: move diff-changes to its own repository --- .gitmodules | 3 ++ vim/pack/plugins/start/diff-changes | 1 + vim/plugin/diff.vim | 70 ------------------------------------- vimrc | 5 +++ 4 files changed, 9 insertions(+), 70 deletions(-) create mode 160000 vim/pack/plugins/start/diff-changes delete mode 100644 vim/plugin/diff.vim diff --git a/.gitmodules b/.gitmodules index 2b3c3de..9d20cdf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -97,3 +97,6 @@ [submodule "vim/pack/plugins/start/history-sync"] path = vim/pack/plugins/start/history-sync url = git://github.com/doy/vim-history-sync +[submodule "vim/pack/plugins/start/diff-changes"] + path = vim/pack/plugins/start/diff-changes + url = git://github.com/doy/vim-diff-changes diff --git a/vim/pack/plugins/start/diff-changes b/vim/pack/plugins/start/diff-changes new file mode 160000 index 0000000..5dfc65a --- /dev/null +++ b/vim/pack/plugins/start/diff-changes @@ -0,0 +1 @@ +Subproject commit 5dfc65aca270052443e871fc2a2506b86aba4990 diff --git a/vim/plugin/diff.vim b/vim/plugin/diff.vim deleted file mode 100644 index 7e72569..0000000 --- a/vim/plugin/diff.vim +++ /dev/null @@ -1,70 +0,0 @@ -let s:foldmethod = &foldmethod -let s:foldenable = &foldenable -let s:diffwindow = 0 - -function! s:diffstart(read_cmd) - if s:diffwindow != 0 - return - endif - let s:foldmethod = &foldmethod - let s:foldenable = &foldenable - let l:filetype = &filetype - vert new - let s:diffwindow = winnr() - set buftype=nofile - try - exe a:read_cmd - catch /.*/ - echohl ErrorMsg - echo v:exception - echohl NONE - call s:diffstop() - return - endtry - let &filetype = l:filetype - diffthis - wincmd p - diffthis -endfunction - -function! s:diffstop() - if s:diffwindow == 0 - return - endif - diffoff! - exe s:diffwindow . 'wincmd w' - bdelete - let &foldmethod = s:foldmethod - let &foldenable = s:foldenable - if &foldenable - if &foldmethod == 'marker' - normal! zv - else - normal! zE - end - endif - let s:diffwindow = 0 -endfunction - -function! s:vcs_orig(file) - " XXX: would be nice to use a:file rather than # here... - let l:dir = expand('#:p:h') - if filewritable(l:dir . '/.svn') == 2 - return system('svn cat ' . a:file) - elseif filewritable(l:dir . '/CVS') == 2 - return system("AFILE=" . a:file . "; MODFILE=`tempfile`; DIFF=`tempfile`; cp $AFILE $MODFILE && cvs diff -u $AFILE > $DIFF; patch -R $MODFILE $DIFF 2>&1 > /dev/null && cat $MODFILE; rm $MODFILE $DIFF") - elseif finddir('_darcs', l:dir . ';') =~# '_darcs' - return system('darcs show contents ' . a:file) - elseif finddir('.git', l:dir . ';') =~# '.git' - let l:prefix = system('git rev-parse --show-prefix') - let l:prefix = substitute(l:prefix, '\n', '', 'g') - let l:cmd = 'git show HEAD:'.l:prefix.a:file - return system(l:cmd) - else - throw 'No VCS directory found' - endif -endfunction - -nnoremap ds :call diffstart('read # normal! ggdd') -nnoremap dc :call diffstart('call append(0, split(s:vcs_orig(expand("#:.")), "\n", 1)) normal! Gdddd') -nnoremap de :call diffstop() diff --git a/vimrc b/vimrc index d15871c..3ca23f1 100644 --- a/vimrc +++ b/vimrc @@ -70,6 +70,11 @@ let g:ale_history_log_output = 0 " commentary {{{ map x :Commentary " }}} +" diff-changes {{{ +nnoremap ds :DiffAgainstFilesystem +nnoremap dc :DiffAgainstVCS +nnoremap de :DiffStop +" }}} " fzf {{{ let g:fzf_layout = { 'up': '~40%' } if &columns >= 160 -- cgit v1.2.3-54-g00ecf