Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 148 lines (120 sloc) 4.476 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
" load pathogen bundles
silent! call pathogen#runtime_append_all_bundles()

" filetype detection with indenting
filetype plugin indent on

syntax enable
colorscheme Tomorrow-Night

set encoding=utf-8 " Use UTF-8 everywhere

set nocompatible " vim not vi by default
set backspace=indent,eol,start " better backspacing
set directory=~/.vim/tmp/ " damn .swp files
set nobackup " don't keep backup file
set writebackup " but do write one while writing the new file
set history=100 " keep 100 lines of command line history
set ruler " show the cursor position in status bar
set showcmd " show commands as they are typed
set number " show line numbers
set showmatch " show matching () {} etc
set noerrorbells " turn off error bells
set visualbell " turn off auditory bell
set autoread " refresh file if changed outside of vim
set autowrite " auto-save current buffer when switching
set hidden " don't unload abandoned bufferes
set wildmode=list:longest " list completions, complete longest common
set wildmenu " better command completion
set scrolloff=5 " keep 5 lines of context around cursor
set textwidth=78 " column width for auto-formatting
set linebreak " if wrapping, do it at whitespace
set foldmethod=marker " syntax folding IS SO SLOW
set foldminlines=2 " don't fold a single line
set nofoldenable
set splitright " split to the right, not left
set splitbelow " split to the bottom, not top
set list " show invisibles as per below
set listchars=eol,tab:› ,nbsp:•
set modelines=2 " search top/bottom 2 lines for modelines

set incsearch " do incremental searching
set ignorecase " ignore case in patterns
set smartcase " ...unless there is a capital letter
set hlsearch " highlight search results

set smartindent " try to be smart about indentation
set autoindent " ditto
set smarttab " smarter tabbing

set grepprg=git\ grep\ -n\ $*

set winwidth=84
set winheight=5
set winminheight=5
set winheight=999

autocmd BufWritePre * :%s/\s\+$//e " Auto-strip trailing whitespace on write

cnoremap %% <C-R>=expand('%:h').'/'<cr>

let g:ctrlp_custom_ignore = '\v[\/](\.git|\.hg|\.svn|node_modules|\.bundle)$'

" Nearest Test Runner {{{

function! RunTests(filename)
" Write the file and run tests for the given filename
    :wa
    :silent !clear
    exec ":!chruby 1.9.3 && test-runner " . a:filename
endfunction

function! SetTestFile()
" Set the spec file that tests will be run for.
    let t:grb_test_file=@%
endfunction

function! RunTestFile(...)
    if a:0
        let command_suffix = a:1
    else
        let command_suffix = ""
    endif

" Run the tests for the previously-marked file.
    let in_spec_file = match(expand("%"), '_spec.rb$') != -1
    if in_spec_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

" }}}

" Key Remaps {{{

nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk

nnoremap <Down> <Nop>
nnoremap <Up> <Nop>
vnoremap <Down> <Nop>
vnoremap <Up> <Nop>
inoremap <Down> <Nop>
inoremap <Up> <Nop>
nmap Q <Nop>
nmap K <Nop>

imap <C-l> <Space>=><Space>
imap <C-c> <Esc>

nnoremap <CR> :nohlsearch<CR>

nnoremap ]<Space> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap [<Space> :set paste<CR>m`O<Esc>``:set nopaste<CR>
nnoremap [q :cp<CR>
nnoremap ]q :cn<CR>

nmap >> a<C-t><Esc>
nmap << a<C-d><Esc>

let mapleader = ","
nmap <Leader>> :Tab /=><CR>
nmap <Leader>= :Tab /=<CR>
xmap <Leader>\ <Plug>Commentary
nmap <Leader>\ <Plug>Commentary
nmap <Leader>\\ <Plug>CommentaryLine
nmap <silent><Leader>A :grep <cword><CR>:botright copen<CR>
nmap <Leader>ct <Esc>:!ctags -R .<CR>
nmap <leader>e :edit %%
nmap <Leader>pm :!markdown % \|bcat<CR><CR>
nmap <Leader>rs :exe "!rspec %:" . line(".")<CR>
nmap <Leader>t :wa \| :call RunTestFile()<CR>
nmap <Leader>T :wa \| :call RunNearestTest()<CR>
nmap <Leader><Space> :CtrlP<CR>
nnoremap <Leader><Leader> <C-^>
nnoremap <Leader>v V`]

" }}}
Something went wrong with that request. Please try again.