From fc4de8bfaa5dde3308e125a73a6f9674f0cc30e7 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Sat, 9 Oct 2010 11:09:26 -0400 Subject: [PATCH] Restructure everything and add fold markers before I go insane. --- plugin/gundo.vim | 317 +++++++++++++++++++++++++++++++---------------- 1 file changed, 209 insertions(+), 108 deletions(-) diff --git a/plugin/gundo.vim b/plugin/gundo.vim index 710015c..5d67695 100644 --- a/plugin/gundo.vim +++ b/plugin/gundo.vim @@ -4,11 +4,12 @@ " Maintainer: Steve Losh " License: GPLv2+ -- look it up. " Notes: Much of this code was thiefed from Mercurial, and the rest was -" heavily inspired by scratch.vim. +" heavily inspired by scratch.vim and histwin.vim. " " ============================================================================ -" -" + + +"{{{ Init "if exists('loaded_gundo') || &cp "finish "endif @@ -18,7 +19,9 @@ if !exists('g:gundo_width') let g:gundo_width = 45 endif +"}}} +"{{{ Movement Mappings function! s:GundoMoveUp() call cursor(line('.') - 2, 0) @@ -30,6 +33,8 @@ function! s:GundoMoveUp() else call cursor(0, idx2 + 1) endif + + call s:GundoRenderPreview() endfunction function! s:GundoMoveDown() @@ -43,6 +48,18 @@ function! s:GundoMoveDown() else call cursor(0, idx2 + 1) endif + + call s:GundoRenderPreview() +endfunction +"}}} + +"{{{ Buffer/Window Management +function! s:GundoResizeBuffers(backto) + exe bufwinnr(bufwinnr('__Gundo__')) . "wincmd w" + exe "vertical resize " . g:gundo_width + exe bufwinnr(bufwinnr('__Gundo_Preview__')) . "wincmd w" + exe "vertical resize " . 40 + exe a:backto . "wincmd w" endfunction function! s:GundoOpenBuffer() @@ -51,7 +68,7 @@ function! s:GundoOpenBuffer() if existing_gundo_buffer == -1 exe "vnew __Gundo__" wincmd H - exe "vertical resize " . g:gundo_width + call s:GundoResizeBuffers(winnr()) nnoremap