-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
489 lines (392 loc) · 12.8 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Make Vim more useful
set nocompatible
" Enable filetype plugins
filetype plugin on
filetype indent on
" Allow backspace in insert mode
set backspace=indent,eol,start
" Ignore case when searching
set ignorecase
set smartcase
" Show search matches while typing
set incsearch
set smartindent
set mouse=
set foldlevelstart=10
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plug
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if !has("nvim")
call plug#begin('~/.vim/plugged')
else
call plug#begin('~/.config/nvim/plugged')
endif
Plug 'HerringtonDarkholme/yats.vim'
Plug 'airblade/vim-gitgutter'
Plug 'ap/vim-css-color'
Plug 'benjie/neomake-local-eslint.vim'
Plug 'bkad/CamelCaseMotion'
Plug 'cakebaker/scss-syntax.vim'
Plug 'chase/vim-ansible-yaml'
Plug 'chriskempson/base16-vim'
Plug 'corntrace/bufexplorer'
Plug 'digitaltoad/vim-jade', { 'for': 'jade' }
Plug 'docunext/closetag.vim'
Plug 'edkolev/tmuxline.vim'
Plug 'ekalinin/Dockerfile.vim', { 'for': 'Dockerfile' }
Plug 'editorconfig/editorconfig-vim'
Plug 'elzr/vim-json'
Plug 'flowtype/vim-flow'
Plug 'geekjuice/vim-mocha', { 'for': 'javascript' }
Plug 'gilsondev/searchtasks.vim'
Plug 'hail2u/vim-css3-syntax', { 'for': 'css' }
Plug 'hashivim/vim-terraform'
Plug 'hashivim/vim-packer'
Plug 'heavenshell/vim-jsdoc'
Plug 'janko-m/vim-test'
Plug 'jiangmiao/auto-pairs'
Plug 'justinmk/vim-gtfo'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': 'yes \| ./install' }
Plug 'juvenn/mustache.vim'
Plug 'kchmck/vim-coffee-script'
Plug 'keith/swift.vim'
Plug 'kristijanhusak/vim-hybrid-material'
Plug 'majutsushi/tagbar'
Plug 'mariappan/dragvisuals.vim'
Plug 'martinda/Jenkinsfile-vim-syntax'
Plug 'mattn/emmet-vim'
Plug 'mhinz/vim-startify'
Plug 'moll/vim-node'
Plug 'othree/html5.vim'
Plug 'othree/yajs.vim'
Plug 'osyo-manga/vim-over'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'rdolgushin/groovy.vim'
Plug 'scrooloose/nerdtree'
Plug 'shime/vim-livedown'
Plug 'suan/vim-instant-markdown'
Plug 'svermeulen/vim-easyclip'
Plug 'terryma/vim-expand-region'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-ragtag'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
Plug 'vim-scripts/Align'
Plug 'vim-scripts/Crunch'
Plug 'vim-scripts/directionalWindowResizer'
Plug 'vim-scripts/bash-support.vim'
Plug 'vim-scripts/gitignore.vim'
Plug 'vim-scripts/groovy.vim'
Plug 'vim-scripts/nginx.vim'
Plug 'vim-scripts/tComment'
Plug 'w0ng/vim-hybrid'
Plug 'xolox/vim-misc'
Plug 'xolox/vim-notes'
Plug 'ryanoasis/vim-devicons' " Must load last
Plug 'Xuyuanp/nerdtree-git-plugin'
if !has('nvim')
Plug 'scrooloose/syntastic'
endif
if has('nvim')
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
Plug 'neomake/neomake'
Plug 'kassio/neoterm'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'scrooloose/syntastic'
Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Quramy/tsuquyomi'
Plug 'Shougo/vimproc.vim', {'do': 'make'}
Plug 'rudism/deoplete-tsuquyomi'
" Plug 'mhartington/nvim-typescript', { 'do': './install.sh' }
endif
call plug#end()
" Install plugins if this is the first run
if !isdirectory(expand(g:plug_home))
PlugInstall
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Debug
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" let g:neomake_logfile = "/tmp/neomake.log"
"
" let g:neomake_verbose = 3
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" User Interface
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set background color to dark
set background=dark
" Draw a vertical ruler at column 80
execute "set colorcolumn=" . join(range(81,335), ',')
" Highlight current line
set cursorline
" Adds - as a word separator
set iskeyword-=-
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Highlight unwanted whitespace
set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_
" Show whitespace
set list
" For regular expressions turn magic on
set magic
" Disables annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Set line numbers
set number
" Show ruler
set ruler
" Minimum of 5 lines above and below cursor must be visible
set scrolloff=5
" Don't show short message when starting Vim
set shortmess=atI
" Show the (partial) command as it’s being typed
set showcmd
" Show matching brackets
set showmatch
" Override 'ignorecase' if search pattern containers uppercase characters
set smartcase
" Lowers timeout length between commands
set timeoutlen=250
" Optimize for fast terminals
set ttyfast
" Enables autocomplete menu
set wildmode=longest:full
set wildmenu
" Wrap long lines
set wrap
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colors and Fonts
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax on
colorscheme hybrid_reverse
" Use Unix as the standard file type
set ffs=unix,dos,mac
" Highlight trailing whitespace
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd BufRead,InsertLeave * match ExtraWhitespace /\s\+$/
" Highlight too-long lines
autocmd BufRead,InsertEnter,InsertLeave * 2match OverLength /\%100v.*/
highlight OverLength ctermbg=black guibg=black
autocmd ColorScheme * highlight OverLength ctermbg=black guibg=black
" Set up highlight group & retain through colorscheme changes
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files, Backups, and Undo
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Centralize backups, swapfiles and undo history
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
if exists("&undodir")
set undodir=~/.vim/undo
endif
" Don't add empty newlines at the end of files
set noeol
" Ignore certain files
set wildignore+=
\.git,
\*/node_modules,
\*/tmp
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" File-specific
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufRead,BufNewFile *.handlebars,*.hbs set ft=html syntax=mustache
autocmd FileType markdown setlocal spell spelllang=en_us
" Autoremove trailing spaces when saving the buffer
autocmd FileType css,html,javascript,markdown autocmd BufWritePre <buffer> :%s/\s\+$//e
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indentation
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces
set expandtab
" Use 2 characters per indent
set shiftwidth=2
set softtabstop=2
set tabstop=2
" Disable maximum text width
set textwidth=0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Navigation
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Miscellaneous
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>
" Fast saving
nmap <leader>w :w!<cr>
" Fast quitting
nmap <leader>q :q<cr>
" Fast save + quit
nmap <leader>wq :wqa!<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin Settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Airline
let g:airline_theme = 'luna'
let g:airline_powerline_fonts = 1
" Devicons
let g:webdevicons_enable_nerdtree = 1
let g:WebDevIconsNerdTreeAfterGlyphPadding = ' '
let g:DevIconsEnableFolderPatternMatching = 1
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
let g:WebDevIconsNerdTreeGitPluginForceVAlign = 1
let WebDevIconsUnicodeDecorateFolderNodesExactMatches = 1
let g:DevIconsEnableFoldersOpenClose = 1
" Deoplete
let g:deoplete#enable_at_startup = 1
" let g:deoplete#file#enable_buffer_path = 1
inoremap <expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr> <S-TAB> pumvisible() ? "\<C-p>" : ""
" DragVisuals
runtime plugin/dragvisuals.vim
vmap <expr> <LEFT> DVB_Drag('left')
vmap <expr> <RIGHT> DVB_Drag('right')
vmap <expr> <DOWN> DVB_Drag('down')
vmap <expr> <UP> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
" Remove any introduced trailing whitespace after moving...
let g:DVB_TrimWS = 1
let g:syntastic_aggregate_errors = 1
" ESLint
" let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_javascript_eslint_exe = '$(npm bin)/eslint'
" tsuquyomi
let g:tsuquyomi_disable_quickfix = 1
let g:tsuquyomi_completion_detail = 1
" Flow
let g:flow#enable = 0
" TypeScript
let g:syntastic_typescript_checkers = ['tslint', 'tsuquyomi']
" if has('nvim')
" nmap <leader>df :TSTypeDef<CR>
" endif
" FZF
if !has('nvim')
let g:fzf_height = 20
map <C-p> :FZF<CR>
else
map <C-p> :call fzf#run({
\ 'sink': 'e',
\ 'window': 'topleft 20new'})<CR>
endif
" Gitgutter
let g:gitgutter_realtime = 0
let g:gitgutter_log = 0
let g:gitgutter_enabled = 0
" Hybrid
let g:hybrid_custom_term_colors = 1
" JSDoc
nmap <silent> <C-m> <Plug>(jsdoc)
let g:jsdoc_enable_es6 = 1
" Markdown
let g:markdown_fenced_languages = ['html', 'css', 'javascript', 'bash=sh']
" Mustache
let g:mustache_abbreviations = 1
" Neomake
if has('nvim')
let g:neomake_typescript_tslint_maker = {
\ 'args': ['%:p', '-t', 'verbose'],
\ 'errorformat': 'ERROR: %f[%l\, %c]: %m',
\ }
let g:neomake_javascript_enabled_makers = ['eslint']
let g:neomake_typescript_enabled_makers = ['tslint']
let g:neomake_open_list = 1
nmap <leader>df :TsuDefinition<CR>
nmap <leader>dt :TsuTypeDefinition<CR>
nmap <leader>t :let g:neomake_javascript_enabled_makers = ['jshint']<cr>:Neomake<cr>
nmap <leader>f :let g:neomake_javascript_enabled_makers = ['eslint']<cr>:Neomake<cr>
autocmd! BufWritePost * Neomake
endif
" Neoterm
let g:neoterm_shell = "zsh"
" NERDTree
let NERDTreeIgnore=['coverage', 'node_modules', 'tmp$']
let NERDTreeHijackNetrw = 0
let NERDTreeShowHidden = 1
map <silent> <LocalLeader>nt :NERDTreeToggle<CR>
map <silent> <LocalLeader>nr :NERDTree<CR>
map <silent> <LocalLeader>nf :NERDTreeFind<CR>
" Over
nnoremap <Leader>fr :call VisualFindAndReplace()<CR>
xnoremap <Leader>fr :call VisualFindAndReplaceWithSelection()<CR>
" Startify
let g:startify_change_to_dir = 0
let g:startify_change_to_vcs_root = 1
" Tagbar
map <silent> <LocalLeader>s :Tagbar<CR>
" TComment
map <silent> <LocalLeader>cc :TComment<CR>
" Terraform
let g:terraform_align=1
let g:terraform_fmt_on_save=1
" packer
augroup vim.packer.fmt
autocmd!
autocmd BufWritePost *.pkr.hcl silent! !packer fmt <afile>
autocmd BufWritePost * edit
autocmd BufWritePost * redraw!
augroup END
" Test
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>T :TestFile<CR>
nmap <silent> <leader>a :TestSuite<CR>
nmap <silent> <leader>l :TestLast<CR>
nmap <silent> <leader>g :TestVisit<CR>
let test#javascript#mocha#options = '--recursive -R spec -b'
function! TestStrategy(cmd)
execute 'T '.a:cmd
endfunction
let g:test#custom_strategies = {'test_strategy': function('TestStrategy')}
let g:test#strategy = 'test_strategy'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Functions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Trim trailing whitespace
function! Trim()
%s/\s*$//
endfunction
command! -nargs=0 Trim :call Trim()
nnoremap <silent> <Leader>cw :Trim<CR>
" Search & replace
function! VisualFindAndReplace()
:OverCommandLine%s/
endfunction
function! VisualFindAndReplaceWithSelection() range
:'<,'>OverCommandLine s/
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Development
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Reload vimrc when changed
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc,init.vim so $MYVIMRC
augroup END