blob: c06c91f5c6c7dbd30c5572ce6beda2e7e5b17d74 (
plain) (
tree)
|
|
"
" 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 <http://www.sanctum.geek.nz/>
"
"
" 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 <SID>Status()
command! Scommit call <SID>Commit()
command! Sinfo call <SID>Info()
command! Supdate call <SID>Update()
command! -nargs=? -complete=file Sadd call <SID>Add(<f-args>)
command! -nargs=? -complete=file Sblame call <SID>Blame(<f-args>)
command! -nargs=? -complete=file Sdiff call <SID>Diff(<f-args>)
command! -nargs=? -complete=file Slog call <SID>Log(<f-args>)
|