" " kimble.vim - Some commands to make the lives of those compelled to use " Subversion just a bit less painful. Inspired by fugitive.vim, but not nearly " as comprehensive in scope. " " Maintainer: Tom Ryder " " " Wrapper to prevent overloading and signal our presence, and check we're not " in compatible mode or running a version of Vim that's too old. " if exists('g:loaded_kimble') || &compatible || v:version < 700 finish endif let g:loaded_kimble = 1 " " Convenience function for running a command and opening its output in a new " scratch buffer on a specified side of the screen. " function! s:Open(commandline, side) let expanded_commandline = a:commandline for part in split(a:commandline, ' ') if part[0] =~ '\v[%#<]' let expanded_part = fnameescape(expand(part)) let expanded_commandline = substitute(expanded_commandline, part, expanded_part, '') endif endfor if (a:side == 'left') vertical topleft 32 new elseif (a:side == 'right') vertical belowright 32 new elseif (a:side == 'top') topleft 12 new elseif (a:side == 'bottom') botright 12 new endif silent! execute '0 read !'. expanded_commandline normal gg setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap nomodifiable endfunction " " Define function wrappers for svn binary calls, with appropriate sides for " loading output. " function! s:Commit() call s:Open('svn commit', 'bottom') endfunction function! s:Info() call s:Open('svn info', 'bottom') endfunction function! s:Status() call s:Open('svn status', 'bottom') endfunction function! s:Update() call s:Open('svn update', 'bottom') endfunction function! s:Add(...) let l:filename = a:0 ? a:1 : expand("%") call s:Open('svn add ' . fnameescape(l:filename), 'bottom') endfunction function! s:Blame(...) let l:filename = a:0 ? a:1 : expand("%") call s:Open('svn blame ' . fnameescape(l:filename), 'left') endfunction function! s:Diff(...) let l:filename = a:0 ? a:1 : expand("%") call s:Open('svn diff ' . fnameescape(l:filename), 'bottom') endfunction function! s:Log(...) let l:filename = a:0 ? a:1 : expand("%") call s:Open('svn log ' . fnameescape(l:filename), 'bottom') endfunction " " Define commands. " command! Sstatus call Status() command! Scommit call Commit() command! Sinfo call Info() command! Supdate call Update() command! -nargs=? -complete=file Sadd call Add() command! -nargs=? -complete=file Sblame call Blame() command! -nargs=? -complete=file Sdiff call Diff() command! -nargs=? -complete=file Slog call Log()