" ============================================================================ " File: gundo.vim " Description: vim global plugin to visualize your undo tree " 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 and histwin.vim. " " ============================================================================ "{{{ Init "if exists('loaded_gundo') || &cp "finish "endif "let loaded_gundo = 1 if !exists('g:gundo_width') let g:gundo_width = 45 endif "}}} "{{{ Movement Mappings function! s:GundoMove(direction) let start_line = getline('.') " If we're in between two nodes we move by one to get back on track. if stridx(start_line, '[') == -1 let distance = 1 else let distance = 2 endif let target_n = line('.') + (distance * a:direction) " Bound the movement to the graph. if target_n <= 4 call cursor(5, 0) else call cursor(target_n, 0) endif let line = getline('.') " Move to the node, whether it's an @ or an o let idx1 = stridx(line, '@') let idx2 = stridx(line, 'o') if idx1 != -1 call cursor(0, idx1 + 1) else call cursor(0, idx2 + 1) endif let target_line = matchstr(getline("."), '\v\[[0-9]+\]') let target_num = matchstr(target_line, '\v[0-9]+') call s:GundoRenderPreview(target_num) endfunction "}}} "{{{ Buffer/Window Management function! s:GundoResizeBuffers(backto) " This sucks and doesn't work. TODO: Fix it. exe bufwinnr(bufnr('__Gundo__')) . "wincmd w" exe "vertical resize " . g:gundo_width exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w" exe "resize " . 15 exe a:backto . "wincmd w" endfunction function! s:GundoOpenBuffer() let existing_gundo_buffer = bufnr("__Gundo__") if existing_gundo_buffer == -1 exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w" exe "new __Gundo__" call s:GundoResizeBuffers(winnr()) nnoremap