-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdot_vimrc
514 lines (437 loc) · 17.6 KB
/
dot_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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
"
" Jesse Nelson <[email protected]>
" joe miller <[email protected]>
"-------------------------------------------------------------------------------
"
"
set nocompatible " be iMproved
set t_Co=256
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
"set clipboard=unnamed " enable clipboard sharing with mac or x11
if has('nvim')
runtime! plugin/python_setup.vim
endif
set ts=4
set sw=4
set expandtab
autocmd FileType go set tabstop=2|set shiftwidth=2|set noexpandtab
autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab
autocmd FileType yaml set tabstop=2|set shiftwidth=2|set expandtab
autocmd FileType coffee set tabstop=2|set shiftwidth=2|set expandtab
set ttyfast " Send more characters for redraws
set mouse=a " enable mouse
set ttymouse=xterm2 " xterm2 to make split resizing with the mouse work. doesn't work with 'xterm' *shrug*. http://superuser.com/questions/549930/cant-resize-vim-splits-inside-tmux
" buffer pos memory
"set viminfo='10,\"100,:20,%,n~/.viminfo
nnoremap <silent> + :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> - :exe "resize " . (winheight(0) * 2/3)<CR>
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" Scripts and Bundles " {{{
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/Vundle.vim'
" My Bundles here:
Plugin 'Chiel92/vim-autoformat'
" Plugin 'tpope/vim-fugitive'
Plugin 'oplatek/Conque-Shell'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'jiangmiao/auto-pairs'
Plugin 'airblade/vim-gitgutter'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 't9md/vim-chef'
Plugin 'rodjek/vim-puppet'
Plugin 'JSON.vim'
Plugin 'nsf/gocode', {'rtp': 'vim/'}
Plugin 'fatih/vim-go'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'majutsushi/tagbar'
Plugin 'craigemery/vim-autotag'
"Plugin 'benekastah/neomake'
Plugin 'scrooloose/syntastic'
Plugin 'vim-scripts/vim-json-bundle'
Plugin 'tpope/vim-repeat'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'smerrill/vcl-vim-plugin'
Plugin 'Valloric/YouCompleteMe' " cd ~/.vim/bundle/YouCompleteMe ; ./install.py --clang-completer --gocode-completer
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'Matt-Deacalion/vim-systemd-syntax'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'kchmck/vim-coffee-script'
Plugin 'digitaltoad/vim-pug' " pug, formerly Jade markup lang
Plugin 'tpope/vim-commentary'
Plugin 'nazo/pt.vim'
Plugin 'vim-ruby/vim-ruby'
Plugin 'ConradIrwin/vim-bracketed-paste'
Plugin 'tpope/vim-surround'
Plugin 'dgryski/vim-godef'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
Plugin 'flazz/vim-colorschemes'
Plugin 'godlygeek/tabular'
Plugin 'gabrielelana/vim-markdown'
Plugin 'mkitt/tabline.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'jez/vim-github-hub'
Plugin 'wakatime/vim-wakatime'
Plugin 'junegunn/vim-emoji'
Plugin 'rakr/vim-one' " another clone of atom's One theme
Plugin 'liuchengxu/space-vim-dark'
Plugin 'tpope/vim-endwise'
"Plugin 'xolox/vim-session'
"Plugin 'xolox/vim-misc'
Plugin 'sjl/vitality.vim' " nice tweaks for making iterm2 + vim + tmux play together, including cursor shape toggling
Plugin 'b4b4r07/vim-hcl'
Plugin 'fatih/vim-hclfmt' " install hclfmt: go get github.com/fatih/hclfmt
Plugin 'mhinz/vim-startify'
Plugin 'markcornick/vim-bats'
call vundle#end() " required
let g:Powerline_symbols = 'unicode'
filetype plugin indent on " required!
" Common typos fixed.
ab teh the
ab fro for
ab nad and
ab adn and
ab recipie recipe
ab tempalte template
ab seperate separate
ab srting string
ab balacner balancer
" relative line numbers are so awesome for someone not good with markers like me
"set relativenumber
" lines of visible b4 scroll
set scrolloff=6
hi clear
" configure statusline (currently using vim-airline)
set laststatus=2
"let g:airline_theme="bubblegum" " https://github.com/vim-airline/vim-airline/wiki/Screenshots
let g:airline_theme="one" " rakr/vim-one
let g:airline_powerline_fonts = 1 " hot fonts! https://github.com/powerline/fonts
let g:airline_detect_spell=0 " disable the pointless SPELL> marker in the statusline
let g:airline#extensions#syntastic#enabled=1
let g:airline#extensions#default#section_truncate_width = {
\ 'b': 110,
\ 'x': 100,
\ 'y': 110,
\ 'z': 50,
\ 'warning': 90,
\ 'error': 90,
\ }
" configure greppers/searchers
if executable('pt')
set grepprg=pt
endif
" Don't use Ex mode, use Q for formatting
map Q gq
"highlight clear SignColumn
filetype plugin indent on
syntax on
"set cursorline " show highlight on line with active cursor
let mapleader = "\<Space>"
set nobackup "no backup files
set nowritebackup "only in case you don't want a backup file while editing
set noswapfile "no swap files
set number "enable line number
filetype plugin on
highlight Pmenu ctermbg=238 gui=bold
au FileType go map <leader>r :!go run %<CR>
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" If you prefer the Omni-Completion tip window to close when a selection is
" " made, these lines close it on movement in insert mode or when leaving
" " insert mode
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
autocmd StdinReadPre * let s:std_in=1
nmap <C-m> :TagbarToggle<CR>
"faith-go
let g:go_auto_type_info = 1
let g:go_fmt_command = "goimports"
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_bin_path = expand("~/go/bin")
"Run commands, such as go run with <leader>r for the current file or go build and go test for the current package with <leader>b and <leader>t. Display a beautiful annotated source code to see which functions are covered with <leader>c.
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <Leader>s <Plug>(go-implements)
"By default the mapping gd is enabled which opens the target identifier in current buffer. You can also open the definition/declaration in a new vertical, horizontal or tab for the word under your cursor:
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
"Open the relevant Godoc for the word under the cursor with <leader>gd or open it vertically with <leader>gv
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
"Or open the Godoc in browser
au FileType go nmap <Leader>gb <Plug>(go-doc-browser)
"Show a list of interfaces which is implemented by the type under your cursor with <leader>s
au FileType go nmap <Leader>s <Plug>(go-implements)
"Show type info for the word under your cursor with <leader>i (useful if you have disabled auto showing type info via g:go_auto_type_info)
au FileType go nmap <Leader>i <Plug>(go-info)
"Rename the identifier under the cursor to a new name
au FileType go nmap <Leader>e <Plug>(go-rename)
"More <Plug> mappings can be seen with :he go-mappings. Also these are just recommendations, you are free to create more advanced mappings or functions based on :he go-commands.
" Make gf work on Chef include_recipe lines
" Add all cookbooks/*/recipe dirs to Vim's path variable
autocmd BufRead,BufNewFile */cookbooks/*/recipes/*.rb setlocal path+=recipes;/cookbooks/**1
" colorscheme config
syntax enable
set background=dark
"let g:solarized_termcolors=16
"let g:solarized_visibility = "low"
"let g:solarized_visibility = "high"
"let g:solarized_contrast = "high"
"colorscheme solarized
"colorscheme bubblegum
colorscheme one " rakr/vim-one
"colorscheme space-vim-dark
nmap <silent> <F2> <Plug>DashSearch
nmap <silent> <F3> <Plug>DashSearch
" golint https://github.com/golang/lint
set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
" AutoFormat on write
noremap <F3> :Autoformat<CR><CR>
setlocal spell spelllang=en_us
set nospell " disable spelling in general, enable only for specific file types because it gets really annoying in source code
autocmd FileType markdown set spell
autocmd FileType text set spell
highlight ExtraWhitespace ctermbg=red guibg=red
" ---------------- begin list toggle code ----------------------
" http://vim.wikia.com/wiki/Toggle_to_open_or_close_the_quickfix_window
" function to provide toggling of the location-list (Syntastic) and quickfix
" windows
function! GetBufferList()
redir =>buflist
silent! ls!
redir END
return buflist
endfunction
function! ToggleList(bufname, pfx)
let buflist = GetBufferList()
for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))')
if bufwinnr(bufnum) != -1
exec(a:pfx.'close')
return
endif
endfor
if a:pfx == 'l' && len(getloclist(0)) == 0
echohl ErrorMsg
echo "Location List is Empty."
return
endif
let winnr = winnr()
exec(a:pfx.'open')
if winnr() != winnr
wincmd p
endif
endfunction
nmap <silent> <leader>l :call ToggleList("Location List", 'l')<CR>
nmap <silent> <leader>q :call ToggleList("Quickfix List", 'c')<CR>
" ---------------- end list toggle code ----------------------
" set a vertical marker at the 80th and 120th columns on text files
fun! EnableColorColumn()
if exists('b:ShowColorColumn')
let &colorcolumn="80,".join(range(120,999),",")
else
let &colorcolumn=''
endif
endfun
autocmd FileType markdown,text let b:ShowColorColumn = 1
autocmd FileType * call EnableColorColumn()
" disable auto-pairs plugin for [] on markdown, it drives me crazy with the auto-spacing
"au Filetype markdown let b:AutoPairs = {'(':')', '{':'}',"'":"'",'"':'"', '`':'`'}
let g:AutoPairsMapSpace=0
" map tab to scroll thru splits
nnoremap <Tab> <c-w>w
" SPC SPC - visual mode
nmap <Leader><Leader> V
" SPC [1-9] - switch to tab 1 through 9
noremap <silent> <leader>1 1gt
noremap <silent> <leader>2 2gt
noremap <silent> <leader>3 3gt
noremap <silent> <leader>4 4gt
noremap <silent> <leader>5 5gt
noremap <silent> <leader>6 6gt
noremap <silent> <leader>7 7gt
noremap <silent> <leader>8 8gt
noremap <silent> <leader>9 9gt
" SPC w - fast save
nnoremap <Leader>w :w<CR>
" SPC q a - quit-all
nnoremap <Leader>qa :qa<CR>
" SPC q - quit
nnoremap <Leader>q :q<CR>
" SPC f r - Reload .vimrc (from space-vim: https://github.com/liuchengxu/space-vim/blob/master/layers/%2Bvim/better-defaults/README.md#others
nnoremap <Leader>fR :source $MYVIMRC<CR>
" jump loclist SPC n, SPC p
map <Leader>n :lnext<CR>
map <Leader>p :lprev<CR>
" ALT tab - switch tabs
map <M-Tab> :tabprev<CR>
imap <M-Tab> <C-O>:tabprev<CR>
" linters to install:
" - shellcheck (brew install shellcheck)
" - go-metalinter (go get -u github.com/alecthomas/gometalinter ; gometalinter --install --update)
" - yamllint (pip install yamllint)
" - jsonlint (brew install jsonlint)
" syntastic (uncomment Plugin to enable)
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 2
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_ruby_checkers = ['mri', 'rubocop', 'rubylint']
let g:syntastic_python_checkers = ['python', 'pylint']
autocmd BufRead,BufNewFile */titan/* let g:syntastic_python_checkers=['python'] " disable pylint when working in the titan project
" NOTE: gometalinter is too slow to run all the linters on most projects. disabled for now.
"let g:syntastic_go_checkers = ['gometalinter']
let g:syntastic_go_checkers = ['go', 'golint', 'govet', 'errcheck', 'deadcode']
"let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck', 'deadcode']
"let g:syntastic_go_checkers = ['go', 'govet']
let g:syntastic_yaml_checkers = ['yamllint']
let g:syntastic_yaml_yamllint_args = '-c ' . shellescape($HOME . '/.yamllint')
let g:syntastic_json_checkers = ['jsonlint']
" NOTE: there are issues with multi-byte emojis in at least Neovim currently (9/2016): https://github.com/neovim/neovim/issues/5149
if emoji#available()
let g:syntastic_error_symbol = emoji#for('x')
let g:syntastic_warning_symbol = emoji#for('warning')
let g:syntastic_style_error_symbol = emoji#for('interrobang')
let g:syntastic_style_warning_symbol = emoji#for('poop')
elseif has('multi_byte') && &encoding ==# 'utf-8'
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
let g:syntastic_style_error_symbol = '»»'
let g:syntastic_style_warning_symbol = '»'
else
let g:syntastic_error_symbol = 'E'
let g:syntastic_warning_symbol = 'W'
let g:syntastic_style_error_symbol = 'S'
let g:syntastic_style_warning_symbol = 's'
endif
highlight link SyntasticErrorSign SignColumn
highlight link SyntasticWarningSign SignColumn
highlight link SyntasticStyleErrorSign SignColumn
highlight link SyntasticStyleWarningSign SignColumn
let g:syntastic_stl_format = "[%E{❌ %fe #%e}%B{|}%W{⚠️ %fw #%w}]"
" neomake settings
"let g:neomake_open_list=1
"autocmd! BufWritePost * Neomake
" gist config
let g:gist_post_private = 1 " private gists by default
let g:gist_show_privates = 1 " show private gists with :Gist -l
" ctrlp config
let g:ctrlp_dont_split = 'nerdtree|NERD' " don't open files in the nerdtree pane. this can be a regex
" open files from ctrlp in a new tab by default (https://github.com/kien/ctrlp.vim/issues/160)
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<c-t>'],
\ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'],
\ }
" fast opening cltrp with SPC-o
nnoremap <Leader>o :CtrlP<CR>
" tabline config
"hi TabLineSel ctermfg=236 ctermbg=150 cterm=NONE " roughly matches the bubblegum dark theme
hi TabLine ctermfg=Black ctermbg=Green cterm=NONE
hi TabLineFill ctermfg=Black ctermbg=Green cterm=NONE
hi TabLineSel ctermfg=White ctermbg=DarkBlue cterm=NONE
" gitgutter config
if emoji#available()
let g:gitgutter_sign_added = emoji#for('small_blue_diamond')
let g:gitgutter_sign_modified = emoji#for('small_orange_diamond')
let g:gitgutter_sign_removed = emoji#for('small_red_triangle')
let g:gitgutter_sign_modified_removed = emoji#for('collision')
endif
" autoreload files that are changed externally whenever a tab/buffer regains focus.
" This is particularly useful with the `make readme-toc` command which updates
" the TOC in a readme: https://github.com/pantheon-systems/markdown-toc-docker#makefile-usage
" From the 'alternative section' of this answer: http://vim.wikia.com/wiki/Have_Vim_check_automatically_if_the_file_has_changed_externally
set autoread
au FocusGained,BufEnter * :silent! !
" NERDTree settings
"nmap <C-n> :NERDTreeToggle<CR>
nmap <C-n> :NERDTreeTabsToggle<CR>
let g:NERDTreeShowHidden=1
let g:NERDTreeWinSize= 22 " smaller than default 31
" vim-nerdtree-tabs configuration - https://github.com/jistr/vim-nerdtree-tabs#configuration
let g:nerdtree_tabs_open_on_console_startup = 2
let g:nerdtree_tabs_focus_on_files = 1
let g:nerdtree_tabs_focus_on_files = 1
" crazy shit needed for 24-bit truecolor mode inside tmux 2.3+
" https://github.com/lifepillar/vim-solarized8/issues/1#issuecomment-226959344
set t_8f=[38;2;%lu;%lu;%lum " Needed in tmux
set t_8b=[48;2;%lu;%lu;%lum " Ditto
" lower timeouts for moving between modes
set timeoutlen=1000 ttimeoutlen=0
" gabrielelana/vim-markdown settings
" - leader + t will toggle a checkbox on a list item, see: https://github.com/gabrielelana/vim-markdown#default-mappings-normal-and-visual-mode
let g:markdown_mapping_switch_status = '<Leader>t'
" YouCompleteMe (ycm) configuration
" - Use relative path to python bin so that virtualenv python will be found and autocompletion for libs in the virtualenv will work - https://github.com/Valloric/YouCompleteMe#python-semantic-completion
let g:ycm_python_binary_path = 'python'
" Startify configuration
let g:startify_session_dir = '~/.vim/sessions'
let g:startify_bookmarks = [ '~/.dotfiles', '~/.vimrc', '~/.zshrc' ]
let g:startify_session_before_save = [ 'echo "Cleaning up before saving.."', 'silent! NERDTreeTabsClose', ]
let g:startify_session_persistence = 1
let g:startify_session_autoload = 1
let g:startify_files_number = 6
" make startify + nerdtree start together when vim is started with no args
autocmd VimEnter *
\ if !argc()
\ | Startify
\ | NERDTree
\ | wincmd w
\ | endif