aboutsummaryrefslogtreecommitdiff
path: root/plugin/kimble.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2012-02-13 17:04:40 +1300
committerTom Ryder <tom@sanctum.geek.nz>2012-02-13 17:04:40 +1300
commitd397fb145a08ebd20ef4966f51206183a189d9dc (patch)
treedcc6a97036d9d068be2952b4f6458e93ddf3a758 /plugin/kimble.vim
downloadvim-kimble-d397fb145a08ebd20ef4966f51206183a189d9dc.tar.gz
vim-kimble-d397fb145a08ebd20ef4966f51206183a189d9dc.zip
First commit.
Diffstat (limited to 'plugin/kimble.vim')
-rw-r--r--plugin/kimble.vim88
1 files changed, 88 insertions, 0 deletions
diff --git a/plugin/kimble.vim b/plugin/kimble.vim
new file mode 100644
index 0000000..c06c91f
--- /dev/null
+++ b/plugin/kimble.vim
@@ -0,0 +1,88 @@
+"
+" 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>)
+