Created
February 24, 2013 06:29
-
-
Save thecarlhall/5022877 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 " be iMproved | |
" this little dance it to get a 0 exit code for git commit | |
filetype plugin indent on | |
filetype plugin indent off | |
filetype off " required! | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
filetype plugin indent on " required! | |
set backupdir=~/.vim/backup | |
set directory=~/.vim/swap | |
set nowrap " wrap long lines | |
set autoindent " indent at the same level of the previous line | |
set shiftwidth=2 " use indents of 4 spaces | |
set expandtab " tabs are spaces, not tabs | |
set tabstop=2 " an indentation every four columns | |
set softtabstop=2 " let backspace delete indent | |
set nu " Line numbers on | |
set ignorecase " case insensitive search | |
set smartcase " case insensitive search | |
set scrolljump=5 " lines to scroll when cursor leaves screen | |
set scrolloff=3 " minimum lines to keep above and below cursor | |
set list | |
set listchars=tab:,.,trail:.,extends:#,nbsp:. " Highlight problematic whitespace | |
set tm=90 | |
set cursorline " highlight current line | |
" let Vundle manage Vundle | |
" required! | |
Bundle 'gmarik/vundle' | |
"" original repos on github | |
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'} | |
Bundle 'tpope/vim-rails.git' | |
Bundle 'ctrlp.vim' | |
Bundle 'rails.vim' | |
Bundle 'surround.vim' | |
Bundle 'wombat256.vim' | |
"" vim-scripts repos | |
"Bundle 'FuzzyFinder' | |
"Bundle 'L9' " required by FuzzyFinder | |
Bundle 'puppetlabs/puppet-syntax-vim' | |
Bundle 'The-NERD-tree' | |
Bundle 'Lokaltog/vim-powerline' | |
" non github repos | |
"Bundle 'git://git.wincent.com/command-t.git' | |
" | |
" Brief help | |
" :BundleList - list configured bundles | |
" :BundleInstall(!) - install(update) bundles | |
" :BundleSearch(!) foo - search(or refresh cache first) for foo | |
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles | |
" | |
" see :h vundle for more details or wiki for FAQ | |
" NOTE: comments after Bundle command are not allowed.. | |
autocmd BufWritePre *.c,*.cpp,*.java,*.rb,*.php,*.html,*.erb,*.css,*.scss,*.sass,*.js,*.coffee,*.yml,*.sh,*.rake,*.feature,*.json,*.md,*.mdown,*.ru,*.sql,*.txt,*.xml,*.svg :%s/\s\+$//e | |
autocmd BufEnter *.c,*.cpp,*.java,*.php,*.rb,*.html,*.erb,*.css,*.scss,*.sass,*.js,*.coffee,*.yml,*.sh,*.rake,*.feature,*.json,*.md,*.mdown,*.ru,*.sql,*.txt,*.xml,*.svg set expandtab tabstop=2 shiftwidt# | |
syntax enable | |
set background=dark | |
colorscheme wombat256mod | |
" Setup git stuff { | |
set laststatus=2 | |
" set statusline=%F\ %{GitBranch()} | |
" set statusline=%F\ %{prompt_func()} | |
" } | |
" powerline { | |
" let g:Powerline_symbols = 'fancy' | |
" } | |
" NerdTree { | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " close vim when only NERDTree is left | |
autocmd VimEnter * NERDTree " open NERDTree on vim start | |
autocmd VimEnter * wincmd l " put the cursor in the editor on vim start | |
let g:NERDTreeWinPos="left" " attempt to keep on the left | |
map <C-e> :NERDTreeToggle<CR>:NERDTreeMirror<CR> " toggle NERDTree using ctrl+e | |
let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr'] | |
" } | |
" ctags { | |
map !c :!ctags -R . | |
" } | |
" Functions for running tests { | |
function! BDD(args) | |
if bufname("%") =~ "test_.*.rb-n " | |
call RunTest(a:args) | |
elseif bufname("%") =~ ".scala" | |
call RunSBTTest() | |
elseif bufname("%") =~ ".feature" | |
call RunCucumber(a:args) | |
elseif bufname("%") =~ "spec.rb" | |
call RunSpec(a:args) | |
elseif bufname("%") =~ "spec.js" | |
call RunJavascriptSpec(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! RunJavascriptSpec(args) | |
execute ":!rake jasmine:ci" | |
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 = "bin/rspec" | |
end | |
let cmd = ":! " . spec . " % -cfn " . a:args | |
execute cmd | |
endfunction | |
function! RunCucumber(args) | |
if exists("b:rails_root") && filereadable(b:rails_root . "/script/spec") | |
let cuke = b:rails_root . "/script/cucumber" | |
else | |
let cuke = "bundle exec cucumber " | |
end | |
let cmd = ":! " . cuke . " " . bufname("%") . " " . a:args | |
execute cmd | |
endfunction | |
function! RunSBTTest() | |
execute ":! java -jar ~/sbt-launcher-0.5.5.jar test" | |
endfunction | |
nmap !s :call BDD("-l " . <C-r>=line('.')<CR>) | |
nmap !S :call BDD("") | |
" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment