.vimrc 7.11 KB
Newer Older
1
set nocompatible
Ariejan de Vroom's avatar
Ariejan de Vroom committed
2 3
filetype off

4 5 6
" Execute commands with Bash, always.
set shell=/bin/bash

Ariejan de Vroom's avatar
Ariejan de Vroom committed
7 8
" Load Vundle, store bundles in ~/.vundle.local
set rtp+=~/.vim/bundle/vundle/
9
call vundle#begin('~/.vundle.local')
Ariejan de Vroom's avatar
Ariejan de Vroom committed
10 11

" Let vundle manage vundle
12
Plugin 'gmarik/Vundle.vim'
Ariejan de Vroom's avatar
Ariejan de Vroom committed
13

14 15 16
" CtrlP
Plugin 'kien/ctrlp.vim'

Ariejan de Vroom's avatar
Ariejan de Vroom committed
17
" Bling
18
Plugin 'bling/vim-airline'
19
Plugin 'vim-airline/vim-airline-themes'
20

Ariejan de Vroom's avatar
Ariejan de Vroom committed
21
" Useful helpers
22 23 24 25
Plugin 'tomtom/tcomment_vim'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-surround'
Plugin 'align'
Ariejan de Vroom's avatar
Ariejan de Vroom committed
26
Plugin 'tpope/vim-sleuth'
27
Plugin 'godlygeek/tabular'
Ariejan de Vroom's avatar
Ariejan de Vroom committed
28 29

" Git / Fugitive
30 31 32
Plugin 'tpope/vim-fugitive'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
33

Ariejan de Vroom's avatar
Ariejan de Vroom committed
34
" Markdown
35
Plugin 'tpope/vim-markdown'
Ariejan de Vroom's avatar
Ariejan de Vroom committed
36

37
" TMux
38
Plugin 'christoomey/vim-tmux-navigator'
39

Ariejan de Vroom's avatar
Ariejan de Vroom committed
40
" Golang
41
Plugin 'fatih/vim-go'
Ariejan de Vroom's avatar
Ariejan de Vroom committed
42

Ariejan de Vroom's avatar
Ariejan de Vroom committed
43 44
" Ruby etc.
Plugin 'vim-ruby/vim-ruby'
45
Plugin 'tpope/vim-cucumber'
Ariejan de Vroom's avatar
Ariejan de Vroom committed
46 47

" Pretty colours
48
Plugin 'dracula/vim'
Ariejan de Vroom's avatar
Ariejan de Vroom committed
49
Plugin 'morhetz/gruvbox'
50

Ariejan de Vroom's avatar
Ariejan de Vroom committed
51 52 53
" Elixir
Plugin 'elixir-lang/vim-elixir'

Ariejan de Vroom's avatar
Ariejan de Vroom committed
54 55 56
" Elm
Plugin 'lambdatoast/elm.vim'

Ariejan de Vroom's avatar
Ariejan de Vroom committed
57 58 59
" Syntastic
Plugin 'vim-syntastic/syntastic'
Plugin 'gcorne/vim-sass-lint'
60

Ariejan de Vroom's avatar
Ariejan de Vroom committed
61
" Done, finish up Vundle
62
call vundle#end()
63 64

let g:ruby_path = system('echo $HOME/.rbenv/shims')
Ariejan de Vroom's avatar
Ariejan de Vroom committed
65 66
filetype plugin indent on

67 68 69
" Map leader key
let mapleader=","

Ariejan de Vroom's avatar
Ariejan de Vroom committed
70
" To enable vim-airline directly
Ariejan de Vroom's avatar
Ariejan de Vroom committed
71
set laststatus=2
72 73 74 75 76

" Always work with utf-8
set encoding=utf-8

" Highlight the cursor line
77
set cursorline
78
" set cursorcolumn
79 80 81 82 83 84 85

" Automatically update changes on getting focus
set autoread

" Keep a longer history
set history=100

Ariejan de Vroom's avatar
Ariejan de Vroom committed
86 87 88 89
" Realtime git update
let g:gitgutter_realtime = 1
let g:gitgutter_eager = 1

90 91 92
" Make file/command completion useful
set wildmenu
set wildmode=list:longest
Ariejan de Vroom's avatar
Ariejan de Vroom committed
93
set wildignore+=tmp,.bundle,.sass-cache,.git,.svn,.hg
94

95 96
set lazyredraw  

Ariejan de Vroom's avatar
Ariejan de Vroom committed
97 98 99
" Disable audible bell
set visualbell

100 101 102
" Syntax highlighting
syntax on
set showmatch "matchin braces
Ariejan de Vroom's avatar
Ariejan de Vroom committed
103

104
" colorscheme 
Ariejan de Vroom's avatar
Ariejan de Vroom committed
105 106
let g:gruvbox_italic=1
colorscheme gruvbox
107 108 109

" Replace Ruby 1.8 Hash syntax with 1.9 Hash syntax_
nmap <leader>rh :%s/\v:(\w+) \=\>/\1:/g<cr>_ 
110

Ariejan de Vroom's avatar
Ariejan de Vroom committed
111
" Font see dotfiles/data
Ariejan de Vroom's avatar
Ariejan de Vroom committed
112
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h12
Ariejan de Vroom's avatar
Ariejan de Vroom committed
113

114 115 116 117 118 119 120 121 122 123 124
" Intuitive backspace
set bs=indent,eol,start

" Line wrapping
set nowrap
set linebreak

" Make sure we use editor lines, not real lines when navigating
nnoremap j gj
nnoremap k gk

125 126 127 128 129 130
" Rspec mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>

131 132 133 134
" Some other settings
set hidden
set modelines=0

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
" Status line
set showcmd
set ruler
set number

" Scrollbars
set sidescrolloff=2
set numberwidth=4

" Maintain more context around the cursor
set scrolloff=3

" Don't keep backups
set nobackup
set nowritebackup
set noswapfile

" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
157
nnoremap <leader><space> :noh<CR>
158

159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
" Set terminal title
set title

" Indenting
set softtabstop=4
set tabstop=4
set shiftwidth=4
set expandtab
set ai " Automatically set the indent of a new line
set si " Smart indent

" Remove trailing whitespace from code files on save
function! StripTrailingWhitespace()
  " store current cursor location
  silent exe "normal ma<CR>"
  " store the current search value
  let saved_search = @/

  " delete the whitespace (e means don't warn if pattern not found)
  %s/\s\+$//e

  " restore old cursor location
  silent exe "normal `a<CR>"
  " restore the search value
  let @/ = saved_search
endfunction

" Set open new windows below/to the right
set sb
set spr
Ariejan de Vroom's avatar
Ariejan de Vroom committed
189

Ariejan de Vroom's avatar
Ariejan de Vroom committed
190
" Highlight anything in column > 80
191 192
" highlight OverLength ctermbg=red ctermfg=white guibg=#592929
" match OverLength /\%81v.\+/
Ariejan de Vroom's avatar
Ariejan de Vroom committed
193 194

" Remap Esc to ii
195
" imap ii <Esc>
Ariejan de Vroom's avatar
Ariejan de Vroom committed
196 197

" Airline
198
let g:airline_powerline_fonts=1
Ariejan de Vroom's avatar
Ariejan de Vroom committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218

" Easy pasting, ripped from tpope/vim-unimpaired
function! s:setup_paste() abort
  let s:paste = &paste
  let s:mouse = &mouse
  set paste
  set mouse=
endfunction

nnoremap <silent> <Plug>unimpairedPaste :call <SID>setup_paste()<CR>

nnoremap <silent> yp  :call <SID>setup_paste()<CR>a
nnoremap <silent> yP  :call <SID>setup_paste()<CR>i
nnoremap <silent> yo  :call <SID>setup_paste()<CR>o
nnoremap <silent> yO  :call <SID>setup_paste()<CR>O
nnoremap <silent> yA  :call <SID>setup_paste()<CR>A
nnoremap <silent> yI  :call <SID>setup_paste()<CR>I
nnoremap <silent> ygi :call <SID>setup_paste()<CR>gi
nnoremap <silent> ygI :call <SID>setup_paste()<CR>gI

219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
" Autocommands
if has('autocmd')
    augroup autocommandbots
        autocmd!
        " Remove trailing whitespace from various files
        autocmd BufWritePre,FileWritePre *.html,*.rb,*.php,*.xml,*.erb call StripTrailingWhitespace()

        " Use 2 spaces for tabs in ruby and associated langs
        autocmd Filetype coffee,ruby,yaml,rake,rb,ru,javascript setlocal ts=2 sw=2 expandtab
        autocmd BufNewFile,BufRead {*.rake,Podfile,Gemfile,Guardfile,Capfile,Rakefile,Thorfile,config.ru} set ft=ruby
        autocmd BufNewFile,BufRead Gemfile.lock set ft=yaml
        autocmd BufNewFile,BufRead *.json set ft=javascript
        autocmd BufNewFile,BufRead *.prawn set ft=ruby
        autocmd BufNewFile,BufRead *.go set ft=go

        " Enable Less syntax
        autocmd BufRead,BufNewFile *.less set filetype=less

        " Enable SCSS syntax
        autocmd BufRead,BufNewFile *.scss set filetype=scss

        " Enable soft-wrapping for text files
        autocmd FileType text,markdown,html,xhtml,eruby setlocal wrap linebreak nolist

        " Auto-resise windows when resizing
        autocmd VimResized * wincmd =

        " Folding on indent for HAML and coffee-script files
        autocmd BufNewFile,BufReadPost *.{coffee,haml} setl foldmethod=indent nofoldenable

        " Unimpaired paste
        autocmd InsertLeave *
            \ if exists('s:paste') |
            \   let &paste = s:paste |
            \   let &mouse = s:mouse |
            \   unlet s:paste |
            \   unlet s:mouse |
            \ endif
    augroup END
endif

260 261

" Mark the 79-character limit
Ariejan de Vroom's avatar
Ariejan de Vroom committed
262 263
" let &colorcolumn=join(range(80,999),",")
" highlight ColorColumn ctermbg=235 guibg=#2c2d27
264

265 266
" Configure vim-go
let g:go_fmt_command = "goimports"
267

268
" Configure gist
269 270 271 272
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:gist_post_private = 1
let g:gist_open_browser_after_post = 1
273

Ariejan de Vroom's avatar
Ariejan de Vroom committed
274 275 276 277 278 279 280 281 282 283 284 285 286 287
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

" Lint SCSS/SASS
let g:syntastic_sass_checkers=["sasslint"]
let g:syntastic_scss_checkers=["sasslint"]

288 289 290
" Explore
map <leader>f :Explore<cr>
let g:netrw_liststyle=3
291 292 293

" Set short timeout, helps with vim-airline switching from INSERT mode
set ttimeoutlen=10
294 295 296 297 298 299 300 301 302 303 304 305 306 307

" Tabular alignment
inoremap <silent> <Bar>   <Bar><Esc>:call <SID>align()<CR>a

function! s:align()
  let p = '^\s*|\s.*\s|\s*$'
  if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
    let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
    let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
    Tabularize/|/l1
    normal! 0
    call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
  endif
endfunction
308 309 310

" Clipboard 
set clipboard=unnamed