motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit 4c7e649efba289df0e7e8bb9abfa37f95b28f8ed (tree)
parent 618d884562f2b99fa62e3fb90e3531bf17396efa
Author: Tim Pope <code@tpope.net>
Date:   Fri, 19 Apr 2013 15:53:02 -0400

Encapsulate restore options for diff

This should make it easier to experiment with solutions for issues such
as #257.

Diffstat:
Mplugin/fugitive.vim | 33+++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim @@ -1373,17 +1373,22 @@ function! s:diff_window_count() return c endfunction +function! s:diff_restore() + let restore = 'setlocal nodiff noscrollbind' + \ . ' scrollopt=' . &l:scrollopt + \ . (&l:wrap ? ' wrap' : ' nowrap') + \ . ' foldmethod=' . &l:foldmethod + \ . ' foldcolumn=' . &l:foldcolumn + \ . ' foldlevel=' . &l:foldlevel + if has('cursorbind') + let restore .= (&l:cursorbind ? ' ' : ' no') . 'cursorbind' + endif + return restore +endfunction + function! s:diffthis() if !&diff - let w:fugitive_diff_restore = 'setlocal nodiff noscrollbind' - let w:fugitive_diff_restore .= ' scrollopt=' . &l:scrollopt - let w:fugitive_diff_restore .= &l:wrap ? ' wrap' : ' nowrap' - let w:fugitive_diff_restore .= ' foldmethod=' . &l:foldmethod - let w:fugitive_diff_restore .= ' foldcolumn=' . &l:foldcolumn - let w:fugitive_diff_restore .= ' foldlevel=' . &l:foldlevel - if has('cursorbind') - let w:fugitive_diff_restore .= (&l:cursorbind ? ' ' : ' no') . 'cursorbind' - endif + let w:fugitive_diff_restore = s:diff_restore() diffthis endif endfunction @@ -1434,16 +1439,16 @@ endfunction call s:add_methods('buffer',['compare_age']) function! s:Diff(bang,...) - let split = a:bang ? 'split' : 'vsplit' + let vert = a:bang ? '' : 'vertical ' if exists(':DiffGitCached') return 'DiffGitCached' elseif (!a:0 || a:1 == ':') && s:buffer().commit() =~# '^[0-1]\=$' && s:repo().git_chomp_in_tree('ls-files', '--unmerged', '--', s:buffer().path()) !=# '' let nr = bufnr('') - execute 'leftabove '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`' + execute 'leftabove '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`' execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>' call s:diffthis() wincmd p - execute 'rightbelow '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`' + execute 'rightbelow '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`' execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>' call s:diffthis() wincmd p @@ -1476,9 +1481,9 @@ function! s:Diff(bang,...) let spec = s:repo().translate(file) let commit = matchstr(spec,'\C[^:/]//\zs\x\+') if s:buffer().compare_age(commit) < 0 - execute 'rightbelow '.split.' '.s:fnameescape(spec) + execute 'rightbelow '.vert.'split '.s:fnameescape(spec) else - execute 'leftabove '.split.' '.s:fnameescape(spec) + execute 'leftabove '.vert.'split '.s:fnameescape(spec) endif call s:diffthis() wincmd p