Created
March 17, 2010 23:48
-
-
Save samg/335875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
set scrolloff=2 | |
set nowrap | |
set wildmenu | |
set iskeyword+=?,! | |
set backspace=2 | |
set background=dark | |
filetype plugin indent on | |
syntax on | |
set ruler | |
set incsearch | |
set ignorecase | |
set et | |
set sw=2 | |
set smarttab | |
set number | |
noremap Y y$ | |
set list | |
set lcs=tab:>> "show tabs | |
set lcs+=trail:. "show trailing spaces | |
set pastetoggle=<F11> | |
noremap Q @q | |
function! BDD(args) | |
if bufname("%") =~ "test.rb" | |
call RunTest(a:args) | |
elseif bufname("%") =~ ".scala" | |
call RunSBTTest() | |
elseif bufname("%") =~ ".feature" | |
call RunCucumber() | |
elseif bufname("%") =~ "spec.rb" | |
call RunSpec(a:args) | |
else | |
echo "don't know how to BDD this file" | |
end | |
endfunction | |
function! RunTest(args) | |
let cursor = matchstr(a:args, '\d\+') | |
if cursor | |
while !exists("cmd") && cursor != 1 | |
if match(getline(cursor), 'def test') >= 0 | |
let cmd = ":! ruby % -vv -n ". matchstr(getline(cursor), "test_[a-zA-Z_]*") | |
else | |
let cursor -= 1 | |
end | |
endwhile | |
end | |
if !exists("cmd") | |
let cmd = ":! ruby % -vv" | |
end | |
execute cmd | |
endfunction | |
function! RunSpec(args) | |
if exists("b:rails_root") && filereadable(b:rails_root . "/script/spec") | |
let spec = b:rails_root . "/script/spec" | |
else | |
let spec = "spec" | |
end | |
let cmd = ":! " . spec . " % -cfn " . a:args | |
execute cmd | |
endfunction | |
function! RunCucumber() | |
if exists("b:rails_root") && filereadable(b:rails_root . "/script/spec") | |
let cuke = b:rails_root . "/script/cucumber" | |
else | |
let cuke = "cucumber" | |
end | |
let cmd = ":! " . cuke . " --format=pretty %" | |
execute cmd | |
endfunction | |
function! RunSBTTest() | |
execute ":! java -jar ~/sbt-launcher-0.5.5.jar test" | |
endfunction | |
map !s :call BDD("-l " . <C-r>=line('.')<CR>) | |
map !S :call BDD("") | |
map ;j :JSLintLight<CR> | |
map ;J :JSLintClear<CR> | |
map !b :%s/\s\+$//g<CR> | |
map !f :FufFile**/<CR> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment