Created
December 2, 2012 13:28
-
-
Save tcrayford/4188666 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
filetype off | |
silent! call pathogen#runtime_append_all_bundles() | |
silent! call pathogen#helptags() | |
filetype plugin indent on | |
runtime macros/matchit.vim | |
set hidden | |
set autoread | |
set nobackup | |
set noswapfile | |
set nowritebackup | |
set number | |
set ignorecase | |
set smartcase | |
set cmdheight=2 | |
set t_Co=256 | |
let mapleader = " " | |
map <leader>r :r <C-R>=expand("%:h")<cr>/ | |
map <leader>e :e <C-R>=expand("%:h")<cr>/ | |
" Go to previous file | |
nnoremap <leader><leader> <c-^> | |
nmap <silent> <leader>v :tabe $MYVIMRC<CR> | |
" Copy current visual selection to osx clipboard | |
map <silent> <leader>y :<C-u>silent '<,'>w !pbcopy<CR> | |
map <leader>n :cn <CR> | |
map <leader>p :cp <CR> | |
" Seriously, who ever actually uses ' | |
nnoremap ' ` | |
nnoremap ` ' | |
nnoremap j gj | |
nnoremap k gk | |
"Seriously, guys. It's not like :W is bound to anything anyway. | |
command! W :w | |
command! Q :q | |
command! Wall :wall | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
set history=1000 " keep 1000 lines of command line history | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
" Make tab completion for files/buffers act like bash | |
set wildmenu | |
set completeopt=longest,menu | |
" Softtabs, 2 spaces | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
set softtabstop=2 | |
set smarttab | |
set hlsearch | |
set cursorline | |
set numberwidth=5 | |
syntax enable | |
colorscheme grb256 | |
set background=dark | |
if has("autocmd") | |
augroup vimrcEx | |
au! | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
augroup END | |
else | |
set autoindent " always set autoindenting on | |
endif | |
" Remap the tab key to do autocompletion or indentation depending on the | |
" context (from http://www.vim.org/tips/tip.php?tip_id=102) | |
function! InsertTabWrapper() | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
else | |
return "\<c-p>" | |
endif | |
endfunction | |
inoremap <tab> <c-r>=InsertTabWrapper()<cr> | |
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%) | |
set laststatus=2 | |
" Map keys to go to specific files | |
function! ShowRoutes() | |
" Requires 'scratch' plugin | |
:topleft 100 :split __Routes__ | |
" Make sure Vim doesn't write __Routes__ as a file | |
:set buftype=nofile | |
" Delete everything | |
:normal 1GdG | |
" Put routes output in buffer | |
:0r! rake -s routes | |
" Size window to number of lines (1 plus rake output length) | |
:exec ":normal " . line("$") . _ " | |
" Move cursor to bottom | |
:normal 1GG | |
" Delete empty trailing line | |
:normal dd | |
endfunction | |
map <leader>dd :topleft 100 :split spec/todo_spec.rb<cr> | |
" Leave the return key alone when in command line windows, since it's used | |
" to run commands there. | |
autocmd! CmdwinEnter * :unmap <cr> | |
autocmd! CmdwinLeave * :call MapCR() | |
autocmd BufWinEnter quickfix :unmap <cr> | |
autocmd BufWinLeave quickfix :call MapCR() | |
function! MapCR() | |
nnoremap <cr> :nohlsearch<cr> | |
endfunction | |
call MapCR() | |
" Ensure vim always runs from a shell, rvm needs this. | |
set shell=/bin/sh | |
" In these functions, we don't use the count argument, but the map referencing | |
" v:count seems to make it work. I don't know why. | |
" You can't see it on github, but there are raw character codes below | |
function! ScrollOtherWindowDown(count) | |
normal! | |
normal! | |
normal! | |
endfunction | |
function! ScrollOtherWindowUp(count) | |
normal! | |
normal! | |
normal! | |
endfunction | |
nnoremap g<c-y> :call ScrollOtherWindowUp(v:count)<cr> | |
nnoremap g<c-e> :call ScrollOtherWindowDown(v:count)<cr> | |
:inoremap <c-c> | |
set winwidth=84 | |
set scrolloff=2 | |
set shiftround | |
function! RunTests(filename) | |
" Write the file and run tests for the given filename | |
:w | |
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo | |
if match(a:filename, '\.feature$') != -1 | |
exec ":!bundle exec cucumber " . a:filename | |
elseif match(a:filename, '\.coffee$') != -1 | |
exec "!jasmine-headless-webkit " . a.filename | |
else | |
if filereadable("script/test") | |
exec ":!script/test " . a:filename | |
else | |
exec ":!bundle exec rspec " . a:filename | |
end | |
end | |
endfunction | |
function! SetTestFile() | |
" Set the spec file that tests will be run for. | |
let t:grb_test_file=@% | |
endfunction | |
function! RunTestFile(...) | |
let in_clojure_file = match(expand("%"), '\(.clj\)$') != -1 | |
if a:0 | |
let command_suffix = a:1 | |
else | |
let command_suffix = "" | |
endif | |
" Run the tests for the previously-marked file. | |
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|.*test.*.clj\|Spec.js\|.*Spec.*.hs\|.*Test.*hs\)$') != -1 | |
if in_test_file | |
call SetTestFile() | |
elseif !exists("t:grb_test_file") | |
return | |
end | |
call RunTests(t:grb_test_file . command_suffix) | |
endfunction | |
function! RunNearestTest() | |
let spec_line_number = line('.') | |
call RunTestFile(":" . spec_line_number) | |
endfunction | |
" Test running on leader | |
map <leader>t :call RunTestFile()<cr> | |
map <leader>T :call RunNearestTest()<cr> | |
map <leader>a :call RunTests('')<cr> | |
map <leader>c :w\|:!script/features<cr> | |
map <leader>C :w\|:!script/features --profile wip<cr> | |
map <leader>R :w\|:!ruby %<cr> | |
map <leader>l :w\|:!script/lint %<cr> | |
map <leader>L :w\|:!script/lint<cr> | |
"jumping to files on leader | |
map <leader>gr :topleft :split config/routes.rb<cr> | |
map <leader>gR :call ShowRoutes()<cr> | |
map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr> | |
map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr> | |
map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr> | |
map <leader>ge :CommandTFlush<cr>\|:CommandT app/mailers<cr> | |
map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr> | |
map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr> | |
map <leader>go :CommandTFlush<cr>\|:CommandT app/observers<cr> | |
map <leader>gj :CommandTFlush<cr>\|:CommandT public/javascripts<cr> | |
map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr> | |
map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets/sass<cr> | |
map <leader>gf :CommandTFlush<cr>\|:CommandT features<cr> | |
map <leader>q :CommandTFlush<cr>\|:CommandT app/estately<cr> | |
map <leader>gg :topleft 100 :split Gemfile<cr> | |
map <leader>ga :CommandTFlush<cr>\|:CommandT app/assets<cr> | |
map <leader>f :CommandTFlush<cr>\|:CommandT<cr> | |
map <leader>F :CommandTFlush<cr>\|:CommandT %%<cr> | |
imap <c-l> <space>=><space> | |
imap <c-k> <%<space><space>%><esc>F<space>i | |
function! WritingText() | |
:set spell | |
:map <leader>a :normal gqap<cr> | |
:map <leader>j :call FormatJava()<cr> | |
:set tabstop=4 | |
:set shiftwidth=4 | |
:set softtabstop=4 | |
:map <leader>s :w\|!texcount *.tex *.latex<cr> | |
endfunction | |
function! BuildSurvey() | |
:w | |
:!sh script/build | |
:!open report.pdf | |
endfunction | |
let Tlist_Use_Right_Window = 1 | |
set wildignore+=*.o,*.obj,.git,*.pyc,*.log,*.rbc,*.hi,vendor/*,kafka/* | |
autocmd! BufReadPost *.latex :call WritingText() | |
autocmd! BufReadPost *.tex :call WritingText() | |
autocmd! BufReadPost *.md :call WritingText() | |
autocmd! BufReadPost *.markdown :call WritingText() | |
autocmd! BufReadPost *.latex :map <leader>t :call BuildSurvey()<cr> | |
autocmd! BufReadPost *.md :map <buffer><leader>t :w\|!open "%"<cr> | |
autocmd! bufwritepost .vimrc source ~/.vimrc | |
" ignore latex files | |
set wildignore+=*.bbl,*-blx.bib,*.aux,*.log,*.pdf,*.pdf,*.blg,*.out,*.xml,*.toc | |
let g:Tex_DefaultTargetFormat = 'pdf' | |
let g:Tex_ViewRule_pdf = 'Preview' | |
let Tex_FoldedSections="" | |
let Tex_FoldedEnvironments="" | |
let Tex_FoldedMisc="" | |
" stop jumping around by char | |
map <Left> :echo "no!"<cr> | |
map <Right> :echo "no!"<cr> | |
map <Up> :echo "no!"<cr> | |
map <Down> :echo "no!"<cr> | |
"indentation inside html tags | |
autocmd TabEnter,WinEnter,BufWinEnter *.html,*.erb let g:html_indent_tags = g:html_indent_tags.'\|p' | |
autocmd! InsertLeave,CursorMoved *.sass,*.erb,*.coffee,*.js,*.css :w | |
set showtabline=2 | |
set autoread | |
set t_ti= t_te= | |
" No delay before hitting O straight after | |
set noesckeys | |
let vimclojure#WantNailgun = 1 | |
let vimclojure#NailgunClient = "ng" | |
let vimclojure#SplitSize = 8 | |
let vimclojure#UseErrorBuffer = 0 | |
let vimclojure#FuzzyIndent=1 | |
let g:vimclojure#ParenRainbow=1 | |
let vimclojure#HighlightBuiltins=1 | |
let vimclojure#ParenRainbowColors = { | |
\ '0': 'ctermfg=237', | |
\ '1': 'ctermfg=237', | |
\ '2': 'ctermfg=237', | |
\ '3': 'ctermfg=237', | |
\ '4': 'ctermfg=237', | |
\ '5': 'ctermfg=237', | |
\ '6': 'ctermfg=237', | |
\ '7': 'ctermfg=237', | |
\ '8': 'ctermfg=237', | |
\ '9': 'ctermfg=237', | |
\ } | |
" use ghc functionality for haskell files | |
au Bufenter *.hs compiler ghc | |
" Configure browser for haskell_doc.vim | |
let g:haddock_browser = "open" | |
let g:haddock_browser_callformat = "%s %s" | |
:call arpeggio#load() | |
:source ~/.myarpeggio.vim | |
autocmd! bufwritepost .myarpeggio.vim source ~/.myarpeggio.vim | |
let g:arpeggio_timeoutlen=30 | |
function! ShowSlowSpecs() | |
" Requires 'scratch' plugin | |
:topleft 100 :split __SlowSpecs__ | |
" Don't write an file | |
:set buftype=nofile | |
" Delete everything | |
:normal 1GdG | |
" Put pasted slow specs in buffer | |
normal "+p | |
endfunction | |
"ghc-mod | |
"let &l:statusline = '%{empty(getqflist()) ? "" : "[Errors Found]"}' . (empty(&l:statusline) ? &statusline : &l:statusline) | |
"autocmd BufWritePost *.hs GhcModCheckAndLintAsync | |
inoremap <C-f> <c-r>=InsertTabWrapper()<cr> | |
let g:syntastic_enable_highlighting=1 | |
highlight ExtraWhitespace ctermbg=red guibg=red | |
au ColorScheme * highlight ExtraWhitespace guibg=red | |
au BufEnter * match ExtraWhitespace /\s\+$/ | |
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/ | |
au InsertLeave * match ExtraWhiteSpace /\s\+$/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment