aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vim/plugin/rspec.vim36
-rw-r--r--vimrc11
2 files changed, 47 insertions, 0 deletions
diff --git a/vim/plugin/rspec.vim b/vim/plugin/rspec.vim
new file mode 100644
index 0000000..d244476
--- /dev/null
+++ b/vim/plugin/rspec.vim
@@ -0,0 +1,36 @@
+fun! GetRubyBin()
+ for [key, val] in items(g:ruby_bin_list)
+ if match(expand("%:p"), key) == 0
+ return val
+ endif
+ endfor
+ return "ruby"
+endfun
+
+fun! GetSpecBin()
+ for [key, val] in items(g:spec_bin_list)
+ if match(expand("%:p"), key) == 0
+ return val
+ endif
+ endfor
+ return "spec"
+endfun
+
+fun! GetLibDirs()
+ let l:lib_dirs = []
+ for [key, val] in items(g:lib_dirs_list)
+ if match(expand("%:p"), key) == 0
+ call extend(l:lib_dirs, val)
+ endif
+ endfor
+ return "-I\"".join(l:lib_dirs, "\" -I\"")."\""
+endfun
+
+fun! RunSpec()
+ let l:current_file = expand("%:p")
+ let l:ruby_bin = GetRubyBin()
+ let l:spec_bin = GetSpecBin()
+ let l:lib_dirs = GetLibDirs()
+ let l:cmd = l:ruby_bin." ".l:lib_dirs." ".l:spec_bin." ".l:current_file
+ exec "!".l:cmd
+endfun
diff --git a/vimrc b/vimrc
index d68dddf..95f7760 100644
--- a/vimrc
+++ b/vimrc
@@ -75,6 +75,9 @@ endif
" bindings
"
+noremap <C-x> :source ~/.vimrc<Enter>
+noremap <C-a> :call RunSpec()<Enter>
+
" NERDTree
noremap <C-e> :NERDTreeToggle<Enter>
let NERDTreeMapActivateNode='<Space>'
@@ -92,3 +95,11 @@ set hlsearch
"
helptags $HOME/.vim/doc " load all plugin docs
+
+"
+" local additions
+"
+
+if filereadable($HOME."/.vimrc-local")
+ source ~/.vimrc-local
+endif