This repository has been archived by the owner on Sep 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
.vimrc
573 lines (539 loc) · 15.4 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
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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
" Sources {{{
" vi-improved.org/vimrc.php
" github.com/carlhuda/janus
" github.com/gmarik/vimfiles/blob/master/vimrc
" github.com/durdn/cfg/blob/master/.vimrc
" github.com/factorylabs/vimfiles
" github.com/lukerandall/dotvim/blob/master/vimrc
" github.com/mathiasbynens/dotfiles/blob/master/.vimrc
" viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
" }}}
" Plugins {{{
" Init vim-plug {{{
set nocompatible
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" }}}
" Sane defaults {{{
Plug 'tpope/vim-sensible'
" }}}
" Colors {{{
Plug 'chriskempson/base16-vim'
" }}}
" Languages {{{
" HTML {{{
Plug 'tmhedberg/matchit', { 'for': 'html' }
Plug 'othree/html5.vim', { 'for': 'html' }
" }}}
" Templates {{{
Plug 'lepture/vim-jinja', { 'for': 'jinja' }
Plug 'tpope/vim-liquid', { 'for': 'liquid' }
" }}}
" C++ {{{
Plug 'bfrg/vim-cpp-modern', { 'for': 'cpp' }
Plug 'prabirshrestha/async.vim', { 'for': 'cpp' }
Plug 'prabirshrestha/vim-lsp', { 'for': 'cpp' }
Plug 'pdavydov108/vim-lsp-cquery', { 'for': 'cpp' }
" }}}
" CSS {{{
Plug 'wavded/vim-stylus', { 'for': 'stylus' }
" }}}
" Clojure {{{
Plug 'fbeline/kibit-vim', { 'for': 'clojure' }
Plug 'guns/vim-clojure-highlight', { 'for': 'clojure' }
Plug 'guns/vim-clojure-static', { 'for': 'clojure' }
Plug 'guns/vim-slamhound', { 'for': 'clojure' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
Plug 'tpope/vim-salve', { 'for': 'clojure' }
" }}}
" Javascript {{{
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'othree/javascript-libraries-syntax.vim', { 'for': 'javascript' }
Plug 'ternjs/tern_for_vim', { 'for': 'javascript' }
Plug 'elzr/vim-json', { 'for': ['json', 'javascript'] }
" }}}
" Typescript {{{
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }
" }}}
" Python {{{
Plug 'hdima/python-syntax', { 'for': 'python' }
Plug 'tmhedberg/SimpylFold', { 'for': 'python' }
Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' }
Plug 'jmcantrell/vim-virtualenv', { 'for': 'python' }
" }}}
" Go {{{
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" }}}
" sh,bash,zsh {{{
Plug 'vitalk/vim-shebang' ", { 'for': ['sh', 'zsh', 'csh', 'ash', 'dash', 'ksh', 'pdksh', 'mksh', 'tcsh'] }
" }}}
" Docker {{{
" Plug 'ekalinin/Dockerfile.vim'
Plug 'tianon/vim-docker', { 'for': 'dockerfile' }
" }}}
" Markdown {{{
Plug 'godlygeek/tabular', { 'for': ['clojure', 'markdown'] } " plasticboy dependency
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
" }}}
" i3 {{{
Plug 'PotatoesMaster/i3-vim-syntax', { 'for': 'i3' }
" }}}
" Nginx {{{
Plug 'fatih/vim-nginx', { 'for': 'nginx' }
" }}}
" HCL {{{
Plug 'fatih/vim-hclfmt', { 'do': 'go get -u github.com/fatih/hclfmt' }
Plug 'hashivim/vim-terraform'
" }}}
" YAML {{{
Plug 'pedrohdz/vim-yaml-folds', { 'for': 'yaml' }
" }}}
" TOML {{{
Plug 'cespare/vim-toml', { 'for': 'toml' }
" }}}
" Solidity {{{
Plug 'tomlion/vim-solidity'
" }}}
" }}}
" }}}
" Everything else {{{
Plug 'Chiel92/vim-autoformat'
Plug 'Konfekt/FastFold'
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
Plug 'bkad/CamelCaseMotion'
Plug 'henrik/vim-indexed-search'
Plug 'junegunn/vim-easy-align'
Plug 'justinmk/vim-sneak'
Plug '/usr/bin/fzf'
Plug 'junegunn/fzf.vim'
Plug 'majutsushi/tagbar'
Plug 'mhinz/vim-signify'
Plug 'romainl/vim-qf'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'ryanoasis/vim-devicons', { 'on': 'NERDTreeToggle' }
Plug 'tiagofumo/vim-nerdtree-syntax-highlight', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-syntastic/syntastic'
Plug 'xolox/vim-misc' | Plug 'xolox/vim-easytags'
function! BuildYCM(info)
if a:info.status == 'installed' || a:info.force
!python install.py --gocode-completer --ts-completer --clang-completer --system-libclang
endif
endfunction
" load YCM on first insert command
Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif
" }}}
" Finish Init vim-plug {{{
call plug#end()
" }}}
" Options {{{
" Colors {{{
set background=dark
let base16colorspace=256
if !exists('g:colors_name') || g:colors_name != 'base16-eighties'
colorscheme base16-eighties
endif
" }}}
" Spaces {{{
set expandtab tabstop=4 softtabstop=4 shiftwidth=4
" }}}
" Status Line {{{
set shortmess=atI
set noshowmode
" }}}
" Ignored {{{
set wildignore+=*.swp,.git/,*.jpg,*.jpeg,*.png,*.gif,*.psd,*.pdf,\.DS_Store,\.empty
set wildignore+=*.pyc,*.pyo,*.egg,*.egg-info
set wildignore+=*.a,*.o,*.so
set wildignore+=*.class
" }}}
" Keys {{{
let mapleader=","
cabbrev vhelp vert help
inoremap jk <Esc>
inoremap jj <Esc>
nnoremap j gj
nnoremap k gk
nnoremap <leader>3 <C-^>
nnoremap <silent> <C-j> <C-W>j
nnoremap <silent> <C-k> <C-W>k
nnoremap <silent> <C-h> <C-W>h
nnoremap <silent> <C-l> <C-W>l
nnoremap <c-]> g<c-]>
vnoremap <c-]> g<c-]>
" inoremap 1 !
" inoremap 2 @
" inoremap 3 #
" inoremap 4 $
" inoremap 5 %
" inoremap 6 ^
" inoremap 7 &
" inoremap 8 *
" inoremap 9 (
" inoremap 0 )
" inoremap - _
" inoremap ! 1
" inoremap @ 2
" inoremap # 3
" inoremap $ 4
" inoremap % 5
" inoremap ^ 6
" inoremap & 7
" inoremap * 8
" inoremap ( 9
" inoremap ) 0
" inoremap _ -
" }}}
" Searching {{{
set smartcase
set ignorecase
set gdefault
set wildmode=list:longest
if exists('&wildignorecase') | set wildignorecase | endif
" }}}
" Format {{{
set nowrap
set linebreak
set textwidth=79
set relativenumber
set number
set matchtime=3
set nolist
set nosmartindent
set cindent
syntax sync minlines=256
set lazyredraw
set ttyfast
nnoremap <silent> <Leader>r :redraw!<CR>
augroup Format-Options
autocmd!
autocmd BufEnter * setlocal formatoptions=crqn2l1j
augroup END
" Set color column per file type.
function! ColorColumnPerFileType()
call clearmatches()
let langs = ["python"]
if index(langs, &filetype) >= 0 | call matchadd('ColorColumn', printf('\%%%dv', &textwidth+1), -1) | endif
endfunc
" Set new/old regexp engine per file type.
function! RegExpEnginePerFileType()
call clearmatches()
let langs = ["go"]
if index(langs, &filetype) >= 0 | set regexpengine=1 | else | set regexpengine=0 | endif
endfunc
" Set maximum syntax color column.
function! SynMaxColPerFileType()
let langs = ["go"]
if index(langs, &filetype) >= 0 | set synmaxcol=1000 | else | set synmaxcol=3000 | endif
endfunc
" }}}
" Folding {{{
set foldenable
if &diff | set foldmethod=diff | else | set foldmethod=syntax | endif
set foldlevel=0
set foldopen=block,hor,tag,percent,mark,quickfix
function! FoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2)
let fillcharcount = windowwidth - len(line)
return line . repeat(" ", fillcharcount)
endfunction " }}}
set foldtext=FoldText()
" }}}
" Backup {{{
set nobackup
set nowritebackup
set directory=~/.vim/swp//
" }}}
" Mouse {{{
behave xterm
set mouse-=a
set mousehide
" }}}
" Bells {{{
set novisualbell
" }}}
" Misc. {{{
set nostartofline
set splitbelow splitright
set hidden
set title
set clipboard=unnamedplus
" }}}
" Languages {{{
" sh,bash,zsh {{{
let g:sh_fold_enabled = 3
let g:zsh_fold_enable = 1
let g:is_bash=1
" }}}
" }}}
" }}}
" Plugin configurations {{{
" Airline {{{
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_symbols_ascii = 1
let g:airline#extensions#branch#displayed_head_limit = 15
" }}}
" Autoformat {{{
let g:formatters_go = ['gofmt_1', 'gofmt_2'] " disable goimports
" }}}
" Camelcase motion {{{
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
sunmap w
sunmap b
sunmap e
" }}}
" EasyTags {{{
set cpoptions+=d
let g:easytags_file = '~/.vim/.vimtags'
let g:easytags_events = ['BufReadPost', 'BufWritePost']
let g:easytags_dynamic_files = 2
let g:easytags_async = 1
let g:easytags_resolve_links = 1
let g:easytags_suppress_report = 1
let g:easytags_suppress_ctags_warning = 1
" let g:easytags_languages = {
" \ 'javascript': {
" \ 'cmd': 'jsctags',
" \ 'args': [],
" \ 'fileoutput_opt': '-f',
" \ 'stdout_opt': '-f-',
" \ 'recurse_flag': '-R'
" \ }
" \}
" }}}
" fzf {{{
let g:fzf_command_prefix = 'Fzf'
nnoremap <silent> <Leader>f :FzfFiles<CR>
nnoremap <silent> <Leader>b :FzfBuffers<CR>
nnoremap <silent> <Leader>a :FzfAg<CR>
" }}}
" Vim-Go {{{
let g:go_template_autocreate = 0
let g:go_dispatch_enabled = 1
let g:go_guru_tags = 'integration'
let g:go_def_reuse_buffer = 1
let g:go_fmt_autosave = 0
let g:go_metalinter_autosave = 0
let g:go_highlight_array_whitespace_error = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_chan_whitespace_error = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_space_tab_error = 1
let g:go_highlight_structs = 1
let g:go_highlight_trailing_whitespace_error = 0
" let g:go_highlight_types = 1
" }}}
" LSP (C++) {{{
if executable('cquery')
au User lsp_setup call lsp#register_server({
\ 'name': 'cquery',
\ 'cmd': {server_info->['cquery']},
\ 'root_uri': {server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'compile_commands.json'))},
\ 'initialization_options': { 'cacheDirectory': '/tmp/' . $USER . '/cquery/cache' },
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
\ })
endif
" }}}
" NERDTree {{{
let g:WebDevIconsNerdTreeGitPluginForceVAlign = 1
let NERDChristmasTree = 1
let NERDTreeShowHidden = 1
let NERDTreeChDirMode = 1
let NERDTreeShowFiles = 1
let NERDTreeMinimalUI = 1
let NERDTreeWinPos = 'right'
let NERDTreeIgnore = [
\ '.DS_Store', '\.swp$', '\~$', '.empty',
\ '\.jpg$', '\.jpeg$', '\.png$', '\.gif$', '\.pdf$',
\ '\.class$',
\ '\.a$', '\.o$', '\.so$',
\ '\.pyc$', '\.pyo$',
\ '\.tags$'
\ ]
noremap <silent> <Leader>n :NERDTreeToggle<CR>
" }}}
" Python {{{
let python_slow_sync = 1
let python_highlight_indent_errors = 0
let python_highlight_space_errors = 0
let python_highlight_all = 1
" }}}
" Quickfix {{{
nmap <Leader>q <Plug>(qf_qf_toggle)
nmap <Leader>l <Plug>(qf_loc_toggle)
" }}}
" Repeat {{{
silent! call repeat#set("\<Plug>.", v:count)
" }}}
" Signify {{{
let g:signify_vcs_list = [ 'git' ]
" }}}
" Sneak {{{
highlight link SneakPluginTarget Visual
map ; <Plug>SneakNext
nmap f <Plug>Sneak_f
nmap F <Plug>Sneak_F
xmap f <Plug>Sneak_f
xmap F <Plug>Sneak_F
omap f <Plug>Sneak_f
omap F <Plug>Sneak_F
nmap t <Plug>Sneak_t
nmap T <Plug>Sneak_T
xmap t <Plug>Sneak_t
xmap T <Plug>Sneak_T
omap t <Plug>Sneak_t
omap T <Plug>Sneak_T
" }}}
" Syntastic {{{
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
let g:syntastic_filetype_map = {
\ 'jinja': 'html',
\ 'liquid': 'html',
\ 'stylus': 'css',
\ 'scss': 'css',
\ 'less': 'css'
\ }
let g:syntastic_id_checkers = 0
let g:syntastic_aggregate_errors = 1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_auto_loc_list = 2
let g:syntastic_enable_signs = 1
let g:syntastic_error_symbol = 'E'
let g:syntastic_warning_symbol = 'W'
let g:syntastic_style_warning_symbol = 'SW'
let g:syntastic_style_error_symbol = 'SE'
highlight link SyntasticStyleErrorSign Todo
let g:syntastic_python_checkers = ['pylint', 'pycodestyle', 'pydocstyle']
let g:syntastic_html_checkers = ['tidy', 'eslint']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_yaml_checkers = ['yamllint']
" }}}
" Tagbar {{{
nnoremap <silent> <Leader>g :TagbarToggle<CR>
let g:tagbar_sort = 0
let g:tagbar_autofocus = 1
let g:tagbar_compact = 1
let g:tagbar_type_javascript = { 'ctagsbin' : 'jsctags' }
let g:tagbar_type_markdown = {
\ 'ctagstype': 'markdown',
\ 'ctagsbin' : 'markdown2ctags',
\ 'ctagsargs' : '-f - --sort=yes',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '|',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0,
\ }
" }}}
" Tern {{{
let g:tern#command = ['tern', '--no-port-file']
let g:tern_show_signature_in_pum = 1
let g:tern_show_argument_hints = 'on_move'
" }}}
" Virtualenv {{{
" let g:virtualenv_directory = 'venv'
" }}}
" YouCompleteMe - YCM {{{
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
" Call YCM/Go/js GoTo depending on file type.
function! GoToDef()
if &ft == 'clojure'
execute "normal \<Plug>FireplaceDjump"
elseif &ft == 'go'
execute 'GoDef'
elseif &ft == 'javascript'
execute 'TernDef'
else
execute 'YcmCompleter GoTo'
endif
endfunction
nnoremap <leader>] :call GoToDef()<CR>
" }}}
" Autocmds {{{
" Actions on opening a new buffer {{{
augroup Buf-Win-Enter
autocmd!
autocmd BufWinEnter * call ColorColumnPerFileType() | call RegExpEnginePerFileType() | call SynMaxColPerFileType()
augroup END
" }}}
" AutoFormat plugin actions {{{
augroup AutoFormat
autocmd!
autocmd BufWrite *.go :Autoformat
" don't format json if filetype is jinja
" autocmd BufWrite *.json if &ft !~? 'jinja' | :Autoformat | endif
augroup END
" }}}
" Set file types {{{
augroup SetFileTypes
autocmd!
autocmd BufWinEnter *.less setfiletype less
autocmd BufWinEnter *.sql setfiletype mysql
autocmd BufWinEnter *.zsh-theme setfiletype zsh
autocmd BufWinEnter *.x setfiletype c " XDR
autocmd BufWinEnter Pipfile setfiletype toml
autocmd BufWinEnter Pipfile.lock,.tern-config,.tern-project,*.abi setfiletype json
" }}}
" Filetype actions {{{
augroup FileTypeActions
autocmd!
autocmd FileType * set tags=./.tags;,~/.vim/.vimtags
autocmd FileType gitcommit setlocal textwidth=72
autocmd FileType go |
\ setlocal textwidth=100 |
\ nmap <leader>c <Plug>(go-test-compile) |
\ nmap <leader>m <Plug>(go-metalinter)
autocmd FileType html,json,xml,jinja,liquid,css,scss,less,stylus,yaml,gitcommit,nginx,toml setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType html,xml,jinja,liquid runtime! macros/matchit.vim
autocmd FileType qf setlocal wrap
autocmd FileType scss,less,stylus setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType tex setlocal number norelativenumber
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" Set comment strings {{{
augroup CommentStrings
autocmd!
autocmd FileType conf setlocal commentstring=#\ %s
autocmd FileType gohtmltmpl setlocal commentstring={{/*\ %s\ */}}
autocmd FileType i3 setlocal commentstring=#\ %s
autocmd FileType jinja2 setlocal commentstring={#\ %s\ #}
autocmd FileType nginx setlocal commentstring=#\ %s
autocmd FileType terraform setlocal commentstring=#\ %s
autocmd FileType toml setlocal commentstring=#\ %s
autocmd FileType xdefaults setlocal commentstring=!\ %s
augroup END
" }}}
" }}}
" }}}