-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvimrc
More file actions
466 lines (372 loc) · 14.4 KB
/
Copy pathvimrc
File metadata and controls
466 lines (372 loc) · 14.4 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
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer: "
" Mike Arpaia "
" mike@arpaia.co "
" http://arpaia.co "
" "
" To use: "
" - Copy this file to ~/.vimrc "
" - Open vim "
" "
" Keep in mind: "
" - If you have a ~/.vim directory, it might be a good idea to delete it "
" before you use this vimrc as this vimrc will automatically create the "
" appropriate directory structure that it needs "
" - This vimrc uses vundle to install plugins from github (via git) so it "
" should go without saying that you'll need git installed on your host "
" in order for this to work "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Initial setup "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let createVimDir=1
let vim_dir=expand('~/.vim')
if !isdirectory(vim_dir)
echo "Creating ~/.vim/"
echo ""
silent !mkdir -p ~/.vim
let createVimDir=0
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Setting up Vundle - the vim plugin bundler
let installVundle=0
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Sit tight! I'm going to install Vundle and a few plugins for you!"
echo ""
echo ""
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
echo "Installing plugins.."
echo ""
silent !vim +BundleInstall +qall
let installVundle=1
else
let installVundle=1
endif
if installVundle
" Required settings for Vundle
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
" Plugins
Bundle 'tpope/vim-fugitive'
Bundle 'kien/ctrlp.vim'
Bundle 'mileszs/ack.vim'
Bundle 'Lokaltog/vim-powerline'
Bundle 'scrooloose/nerdtree'
Bundle 'mattn/webapi-vim'
Bundle 'mattn/gist-vim'
Bundle 'marpaia/go.vim'
Bundle 'scrooloose/syntastic'
Bundle 'Townk/vim-autoclose'
Bundle 'tpope/vim-eunuch'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-rvm'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-surround'
Bundle 'ervandew/supertab'
Bundle 'Blackrush/vim-gocode'
Bundle 'tomtom/tlib_vim'
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'garbas/vim-snipmate'
Bundle 'honza/vim-snippets'
Bundle 'sontek/minibufexpl.vim'
Bundle 'kien/rainbow_parentheses.vim'
Bundle 'xolox/vim-misc'
" Bundle 'derekwyatt/vim-scala'
" Bundle 'vim-scripts/easytags.vim'
Bundle 'flazz/vim-colorschemes'
Bundle 'rdolgushin/play.vim'
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General viewing "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" fix backspace
set backspace=start,eol,indent
" make it prettier
set background=dark
" makes sure the status line displays automatically
set laststatus=2
" turn on syntax highlighting
syntax on
" set terminal title to file name
set title
" Set to auto read when a file is changed from the outside
set autoread
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Ignore case when searching
set ignorecase
" Highlight search results
set hlsearch
" Automatically display line number
set number
" Read man pages in vim
runtime ftplugin/man.vim
" Show and clear all extraneous whitespace automatically
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
autocmd BufWritePre * :%s/\s\+$//e
" set the filetype for Smarty files
au BufRead,BufNewFile *.tpl set filetype=smarty
" set filetype for go files
au BufRead,BufNewFile *.go set filetype=go
" set the filetype for markdown files
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.mkd set filetype=markdown
au BufRead,BufNewFile *.markdown set filetype=markdown
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General code writing "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" fold based on indent
set foldmethod=indent
" deepest fold is 10 levels
set foldnestmax=10
" dont fold by default
set nofoldenable
" set the foldlevel
" set foldlevel=1
" set commentary comment types
autocmd FileType python set commentstring=#\ %s
autocmd FileType ruby set commentstring=#\ %s
" turn on gocode completion
filetype plugin indent on
" automatically format go files on save
au FileType go au BufWritePre <buffer> Fmt
" auto close the omnicomplete window
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Key maps "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set the leader to the , key
let mapleader = ","
" map ; to be the same thing as : in normal mode
nnoremap ; :
" toggle spell checking
map <leader>s <nop>
map <leader>s :set spell!<CR>
" map ,d to buffer close
map <leader>d :bd<CR>
" Remap VIM 0 to first non-blank character
map 0 ^
" Turning off the <F1> help
nmap <F1> <nop>
" tab left
map <F3> gT
" tab right
map <F4> gt
" toggle line numbers
map <F5> :set number!<CR> :set foldcolumn=0<CR>
" word wrap
map <F6> gwap
" turn on spell checking
map <F7> :set paste!<CR>
" run the file
au BufEnter,BufNew *.php map <F8> :w<CR>:!clear && php %<CR>
au BufEnter,BufNew *.py map <F8> :w<CR>:!clear && python %<CR>
au BufEnter,BufNew *.rb map <F8> :w<CR>:!clear && ruby %<CR>
au BufEnter,BufNew *.io map <F8> :w<CR>:!clear && io %<CR>
au BufEnter,BufNew *.sh map <F8> :w<CR>:!clear && bash %<CR>
au BufEnter,BufNew *.zsh map <F8> :w<CR>:!clear && zsh %<CR>
au BufEnter,BufNew *.go map <F8> :w<CR>:!clear && go run %<CR>
au BufEnter,BufNew *_test.go map <F8> :w<CR>:!clear && go test -v<CR>
" jump back one word
map <F9> b
" jump forward one wordd
map <F10> w
" jump to the beginning of the line
map <F11> 0
" jump to the end of the line
map <F12> $
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" shortcut for completion
:inoremap <nop>
:inoremap
:inoremap <nop>
:inoremap
" Relative number toggling
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
nnoremap <C-n> :call NumberToggle()<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indentation and spacing "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" smartindent inserts one extra level of indentation when appropriate
set smartindent
" autoindent copies the indentation from the previous line,
set autoindent
" tabstop changes the width of the tab character
set tabstop=4
au BufEnter,BufNew *.rb set tabstop=2
au BufEnter,BufNew *.scala set tabstop=2
au BufEnter,BufNew *.html set tabstop=2
" expandtab inserts spaces whenever the tab key is pressed
set expandtab
autocmd FileType go set noexpandtab
" shiftwidth changes the number of space characters inserted for indentation
set shiftwidth=4
au BufEnter,BufNew *.rb set shiftwidth=2
au BufEnter,BufNew *.scala set shiftwidth=2
au BufEnter,BufNew *.html set shiftwidth=2
" softtabstop makes the backspace key treat the four spaces like a tab
set softtabstop=4
au BufEnter,BufNew *.rb set softtabstop=2
au BufEnter,BufNew *.html set softtabstop=2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim artifact files "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set permanent undo files
set undofile
" maximum number of changes that can be undone
set undolevels=1000
" maximum number lines to save for undo on a buffer reload
set undoreload=10000
let createVimTmp=0
let vim_tmp=expand('~/.vim/tmp')
if !isdirectory(vim_tmp)
echo "Creating ~/.vim/tmp"
echo ""
silent !mkdir -p ~/.vim/tmp
let createVimTmp=1
else
let createVimTmp=1
endif
" Don't drop swap and undo files all over the place
if createVimTmp
set directory=~/.vim/tmp
set undodir=~/.vim/tmp
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ctags "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let createVimTags=0
let vim_tags=expand('~/.vim/tags')
if !isdirectory(vim_tags)
echo "Creating ~/.vim/tags"
echo ""
silent !mkdir -p ~/.vim/tags
let createVimTags=1
else
let createVimTags=1
endif
"if isdirectory('~/.vim/bundle/easytags.vim')
" Set the tags file
" let g:easytags_file = '~/.vim/tags/tags'
" generate tags on file saves
" let g:easytags_events = ['BufWritePost']
" recurse directories
" let g:easytags_autorecurse = 1
" turn off the updatetime_warning
" let g:easytags_updatetime_warn = 0
"end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Gist "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/gist-vim')
" GitHub enterprise swag
let g:github_api_url = 'https://github.etsycorp.com/api/v3'
" Allow private gists to show in gist list
let g:gist_show_privates = 1
" Post a private gist
map gpp :Gist -p<CR>
" Post whole file to gist
map gp :Gist<CR>
" List gists
map gl :Gist -l<CR>
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Powerline "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/vim-powerline')
" setup powerline symbols
if expand($SHELL) =~ "bash$"
if expand($HOSTNAME) =~ "etsy.com"
let g:Powerline_symbols = 'compatible'
else
let g:Powerline_symbols = 'unicode'
endif
elseif expand($SHELL) =~ "zsh$"
if expand($HOST) =~ "etsy.com"
let g:Powerline_symbols = 'compatible'
else
let g:Powerline_symbols = 'unicode'
endif
endif
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ctrl-p "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/ctrlp.vim')
" faster find for ctrl-p
let g:ctrlp_user_command = 'find %s -type f'
" set ignore directories for ctl-p
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/.git/*,*/.hg/*,*/.svn/*
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Supertab "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/supertab')
" set context for supertab
let g:SuperTabDefaultCompletionType = "context"
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntastic "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/syntastic')
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_check_on_open=1
let g:syntastic_auto_loc_list=1
let g:syntastic_loc_list_height=5
let g:syntastic_error_symbol='E'
let g:syntastic_warning_symbol='W'
" set the checkers
let g:syntastic_python_checkers=['pylint']
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Rainbow parentheses "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/rainbow_parentheses.vim')
" rainbow parentheses always on
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTree "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/nerdtree')
" toggle NERDTree
nmap <F1> :NERDTreeToggle<CR>
end
" switch between NERDTree and the open file
map <F2> <C-w><C-w>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colorschemes "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory('~/.vim/bundle/vim-colorschemes')
colorscheme enzyme
end