-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvimrc
298 lines (263 loc) · 8.29 KB
/
vimrc
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
148
149
150
151
152
153
154
155
156
157
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
" Skip initialization for vim-tiny or vim-small.
if !1 | finish | endif
" NeoBundle
if has('vim_starting')
set nocompatible " Be iMproved
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'windows' : 'tools\\update-dll-mingw',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'linux' : 'make',
\ 'unix' : 'gmake',
\ },
\ }
NeoBundle 'tpope/vim-abolish'
NeoBundle 'tpope/vim-eunuch'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-repeat'
NeoBundle 'tpope/vim-endwise'
NeoBundle 'tpope/vim-ragtag'
NeoBundle 'tpope/vim-git'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'scrooloose/nerdcommenter'
NeoBundle 'mileszs/ack.vim'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'jonathanfilip/vim-lucius'
NeoBundle 'gregsexton/Muon'
NeoBundle 'tmhedberg/matchit'
NeoBundle 'bling/vim-airline'
NeoBundle 'terryma/vim-multiple-cursors'
NeoBundle 'saltstack/salt-vim'
NeoBundle 'vim-scripts/taglist.vim'
NeoBundle 'vim-scripts/AnsiEsc.vim'
NeoBundle 'vim-scripts/LargeFile'
NeoBundle 'docker/docker' , {'rtp': 'contrib/syntax/vim/'}
NeoBundle 'jsx/jsx.vim'
" Lazy load shit because I don't always use them
NeoBundleLazy 'scrooloose/nerdtree'
NeoBundleLazy 'majutsushi/tagbar'
NeoBundleLazy 'vim-ruby/vim-ruby'
autocmd FileType ruby,rb,erb,ru NeoBundleSource vim-ruby
NeoBundleLazy 'scrooloose/syntastic'
autocmd FileType ruby,rb,erb,ru NeoBundleSource syntastic
NeoBundleLazy 'fatih/vim-go'
autocmd FileType go NeoBundleSource vim-go
NeoBundleLazy 'tfnico/vim-gradle'
autocmd FileType gradle NeoBundleSource vim-gradle
" NeoBundle 'myusuf3/numbers.vim' " unused because it is slow
call neobundle#end()
filetype plugin indent on
NeoBundleCheck
" Text Formatting
syntax on
set textwidth=110
let &wrapmargin= &textwidth
set formatoptions=croql
set hidden
set history=1000
set number
set hlsearch
set autoindent
set smartindent
set expandtab
set smarttab
set wildmenu
set wildmode=list:longest,full
set scrolloff=3
set title
set ts=2
set sw=2
set sts=2
set laststatus=2
set encoding=utf-8
set tags+=.tags
set ignorecase
set smartcase
set undofile
set backspace=indent,eol,start
set linespace=1
set incsearch
set shortmess=atI
set completeopt-=preview
" my fingers are slow. bind :W to :w & :Q to :q & :Wq to :wq & :Wa to :wa
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
cnoreabbrev <expr> Q ((getcmdtype() is# ':' && getcmdline() is# 'Q')?('q'):('Q'))
cnoreabbrev <expr> Wq ((getcmdtype() is# ':' && getcmdline() is# 'Wq')?('wq'):('Wq'))
cnoreabbrev <expr> Wa ((getcmdtype() is# ':' && getcmdline() is# 'Wa')?('wa'):('Wa'))
" vimproc > !
nnoremap ! :VimProcBang
" airline
let g:airline_powerline_fonts=1
" Ensure the temp dirs exist
call system("mkdir -p ~/.vim/tmp/swap")
call system("mkdir -p ~/.vim/tmp/backup")
call system("mkdir -p ~/.vim/tmp/undo")
" Change where we store swap/undo files
set dir=~/.vim/tmp/swap/
set backupdir=~/.vim/tmp/backup/
set undodir=~/.vim/tmp/undo/
" Mappings
let mapleader = ","
" Caleb's cool s and S mappings
nnoremap s i<CR><ESC>==
nnoremap S d$O<ESC>p==
" yank to and paste from clipboard
vnoremap <leader>yc "*y
nnoremap <leader>yv "*p
" Fucking Arrow Keys
nnoremap <Up> <ESC>
nnoremap <Down> <ESC>
nnoremap <Left> <ESC>
nnoremap <Right> <ESC>
inoremap <Up> <ESC>
inoremap <Down> <ESC>
inoremap <Left> <ESC>
inoremap <Right> <ESC>
" Ctrl-P
let g:ctrlp_map='<c-y>'
nnoremap <silent><C-t> :CtrlP pwd<CR>
nnoremap <silent><C-b> :CtrlPBuffer<CR>
nnoremap <silent><C-p> :CtrlPTag<CR>
let g:ctrlp_custom_ignore={
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(so|class)$',
\ }
let g:ctrlp_max_files=20000
let g:ctrlp_max_depth=20
if executable("pt")
let g:ctrlp_user_command = 'pt %s --ignore "*.class" -l --nocolor -g ""'
elseif executable("ag")
let g:ctrlp_user_command = 'ag %s --ignore "*.class" -l --nocolor -g ""'
endif
" NERDTree
let g:NERDTreeChDirMode=2
let g:NERDChristmasTree=1
nmap <leader>t :NeoBundleSource nerdtree<CR>:NERDTreeToggle<CR>
" Exit vim if NERDTree is the last window open
au bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Kill Bells
set vb t_vb=
if has("autocmd") && has("gui")
au GUIEnter * set t_vb=
endif
" Visual Options
set list
set listchars=tab:▸\ ,eol:¬
" ColorScheme
set t_Co=256
set background=dark
colorscheme muon
let g:airline_theme='raven'
" fix NonText and SpecialKey (equivalent to Comment)
hi NonText ctermfg=240 ctermbg=234 gui=None guifg=#585858 guibg=#1c1c1c
hi SpecialKey ctermfg=240 ctermbg=234 gui=None guifg=#585858 guibg=#1c1c1c
" fox sign column colors
let g:gitgutter_override_sign_column_highlight=0
hi SignColumn ctermbg=bg
hi GitGutterAdd ctermfg=086
hi GitGutterChange ctermfg=214
hi GitGutterDelete ctermfg=161
hi GitGutterChangeDelete ctermfg=166
" Show extra whitespace
hi ExtraWhitespace guibg=#CCCCCC
hi ExtraWhitespace ctermbg=161
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" A command to delete all trailing whitespace from a file.
command! DeleteTrailingWhitespace %s:\(\S*\)\s\+$:\1:
nnoremap <silent><F6> :DeleteTrailingWhitespace<CR>
" Reload files
nnoremap <silent><F5> :VimProcBang ~/bin/ctags -f .tags -R . &<CR><CR>:NERDTree<CR>:ClearAllCtrlPCaches<CR>:NERDTreeToggle<CR>
" ColorColumn
function! ToggleColorColumn()
if &colorcolumn == 0
" Draw the color column wherever wrapmargin is set
let &colorcolumn = &wrapmargin
else
let &colorcolumn = 0
endif
endfunction
command! ToggleColorColumn call ToggleColorColumn()
map <leader>c :ToggleColorColumn<CR>
call ToggleColorColumn()
" Fugitive
map <leader>gs :Gstatus<CR>
map <leader>gc :Gcommit<CR>
map <leader>gp :Git push<CR>
map <leader>gl :Git pull<CR>
map <leader>gd :Gdiff<CR>
map <leader>gb :Gblame<CR>
map <leader>ga :Git add .<CR>
nnoremap <leader>gD <c-w>h<c-w>c
" Git Gutter
map <leader>gg :GitGutterToggle<CR>
map <leader>gr :GitGutterToggle<CR>:GitGutterToggle<CR>
" Pt > Ag > Ack
if executable("pt")
let g:ackprg = 'pt --nogroup --nocolor --column'
elseif executable("ag")
let g:ackprg = 'ag --nogroup --nocolor --column'
endif
map <leader>aw yiw:Ack <c-r>0<CR>
map <leader>aa :Ack
map <leader>as :Ack -s
map <leader>af :AckFile
" eclim
au BufEnter *.java map <leader>tw :JavaSearch<CR>
au BufEnter *.scala map <leader>tw :ScalaSearch<CR>
au BufLeave *.java,*.scala map <leader>tw yiw:tag <c-r>0<CR>
let g:EclimJavaSearchSingleResult='edit'
let g:EclimScalaSearchSingleResult='edit'
let g:EclimCompletionMethod = 'omnifunc'
map <leader>er :ProjectDelete <c-r>=expand('%:p:h:t')<CR><CR>:ProjectImport .<CR>:ProjectOpen<CR>
vnoremap <leader>jg :JavaGetSet<CR>
map <leader>jc :JavaConstructor<CR>
map <leader>ji :JavaImport<CR>
map <leader>jo :JavaImportOrganize<CR>
" ctags
map <leader>tw yiw:tag <c-r>0<CR>
map <leader>ts :ts<CR>
map <leader>tn :tn<CR>
map <leader>tp :tp<CR>
map <leader>tf :tf<CR>
map <leader>tl :tl<CR>
map <leader>tt :pop<CR>
" Tagbar
nmap <leader>tb :NeoBundleSource tagbar<CR>:TagbarToggle<CR>
" Make
nnoremap <leader>mm :wa<CR>:make<CR>
nnoremap <leader>mc :wa<CR>:VimProcBang make clean<CR>
nnoremap <leader>mt :wa<CR>:VimProcBang make test<CR>
nnoremap <leader>mf :wa<CR>:VimProcBang make fmt<CR>
" Go specific settings
augroup golang
au!
au FileType go setlocal noexpandtab
augroup END
" Rake
nnoremap <leader>rt :wa<CR>:VimProcBang rake test SPEC_OPTS="--no-color"<CR>
nnoremap <leader>rf :wa<CR>:VimProcBang rspec --no-color <c-r>%<CR>
nnoremap <leader>rl :wa<CR>:VimProcBang rspec --no-color <c-r>%:<c-r>=line(".")<CR><CR>
" Exec
nnoremap <leader>ee ^y$:VimProcBang <c-r>0<CR>
" ruby-specific
" convert strings to symbols and visa-versa
nnoremap <leader>sw" :silent! normal ds"<ESC>i:<ESC>
nnoremap <leader>sw' :silent! normal ds'<ESC>i:<ESC>
nnoremap <leader>ss" :silent! normal ysiw"<ESC>:silent! normal hx<ESC>
nnoremap <leader>ss' :silent! normal ysiw'<ESC>:silent! normal hx<ESC>
" buffer management
nnoremap <leader>bd :bdelete<CR>
nnoremap <leader>bc :bdelete<CR>
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow