-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
561 lines (448 loc) · 18.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
"----------------------------------------------------------
" Plugins
"----------------------------------------------------------
" Auto install vim-plug if It's missing
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 --sync | source $MYVIMRC
endif
" Start vim-plug
call plug#begin()
" Visual
Plug 'bling/vim-airline' " Improved status line
Plug 'francoiscabrol/ranger.vim' " Adds file browser window that lets you view files
Plug 'scrooloose/nerdtree' " Adds file browser sidebar
Plug 'junegunn/fzf' " Adds fuzzy finder
Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'w0rp/ale' " Shows inline lint errors
Plug 'liuchengxu/vim-which-key' " Displays mappings for <leader> in window
Plug 'Kazark/vim-SimpleSmoothScroll' " Slows down scroll speed
Plug 'mbbill/undotree' " Visualize Vim undo tree.
" Plug 'edkolev/tmuxline.vim' " Tags of what function you are working in.
" Plug 'vim-syntastic/syntastic' " Syntax highighting
" Text
Plug 'tpope/vim-commentary' " Adds gc operator for toggling comments
" Plug 'scrooloose/nerdcommenter' " Adds Comment functions
Plug 'tpope/vim-surround' " Adds s text-object for surrounding ' } )
Plug 'tpope/vim-endwise' " Adds 'end' after def, if... in ruby/crystal
Plug 'michaeljsmith/vim-indent-object' " Adds i text-object for indentation
Plug 'bhurlow/vim-parinfer' " Balances lisp parenthesis
" Plug 'jiangmiao/auto-pairs' " Adds closing ' ] } ) chars in insert mode
" Git
Plug 'xuyuanp/nerdtree-git-plugin' " Shows git status in the nerd tree
Plug 'airblade/vim-gitgutter' " Shows unstaged lines on the file
Plug 'vim-scripts/gitignore' " Makes vim use gitignore for 'wildignore'
Plug 'tpope/vim-fugitive' " Adds :Gstatus, :Gcommit, :Gdiff and more
Plug 'tpope/vim-rhubarb' " Adds :Gbrowse for opening in Github
Plug 'junegunn/gv.vim' " Adds :GV command for viewing git logs
" Compilers
Plug 'dgraham/vim-eslint' " Adds eslint compiler. ':make .' populates quickfix
" Filetype
Plug 'rhysd/vim-crystal' " Adds .cr file type support
Plug 'udalov/kotlin-vim' " Adds .kt file type support
Plug 'pangloss/vim-javascript' " Improves .js file type support
Plug 'kchmck/vim-coffee-script' " Adds .coffee file type support
Plug 'leafgarland/typescript-vim' " Adds .ts file type support
Plug 'chrisbra/csv.vim' " Adds .csv file type support
Plug 'mklabs/jscs.vim', { 'do': 'npm i jscs -g' } " JSCS for vim
" Plug 'vim-ruby/vim-ruby'
" Plug 'mxw/vim-jsx'
" Colorschemes
Plug 'felixhummel/setcolors.vim' " :SetColors all then F8 to switch colorschemes
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-scripts/Spacegray.vim'
Plug 'rakr/vim-one'
" Plug 'daviddavis/vim-colorpack'
" Plug 'noahfrederick/vim-hemisu'
" Plug 'junegunn/seoul256.vim'
" Plug 'vim-scripts/playroom'
" Plug 'lifepillar/vim-wwdc17-theme'
" Plug 'oguzbilgic/sexy-railscasts-theme'
" Plug 'cormacrelf/vim-colors-github'
" Plug 'cocopon/iceberg.vim'
" Plug 'tomasr/molokai'
" Plug 'morhetz/gruvbox'
" brew install cmake
" cd ~/.vim/bundle/YouCompleteMe
" ./install.py --js-completer
" Plug 'Valloric/YouCompleteMe'
" End plugin list
call plug#end()
"----------------------------------------------------------
" Vim Settings
"----------------------------------------------------------
" General Settings
set nocompatible " Don't try to be compatible with Vi
set hidden " Enable unsaved buffers to be hidden
set clipboard=unnamed " Use system clipboard for copy/paste
set visualbell " Disable beeping by using visual bell
set history=500 " Increase command history
" File type
filetype plugin indent on " Enable filetype system
" Insert settings
set backspace=indent,eol,start " Enable backspace for deleting after insert
" Backup settings
set nobackup " Disable backup files
set nowritebackup " No backup files
set noswapfile " No swap files
" Search Settings
set ignorecase " Disable search case sensitivity
set incsearch " Enable instant search
set hlsearch " Highlight search term
" Indentation Settings
set tabstop=2 " Width of a tab character
set softtabstop=2 " # of visual spaces per Tab
set shiftwidth=2 " # of spaces in tab when editing
set smartindent " Add extra indent if new block started
set autoindent " Use current lines indent for new line
set expandtab " Insert <space> instead of tab
set smarttab
" Folding
set foldmethod=indent " Fold based on indentation
set foldlevel=9 " Fold all starting from the first
" set foldclose=all " Close folds if you leave them in any way
" set foldopen=all " Open folds if you touch them in any way
set foldnestmax=5 " Fold only maximum of 5 levels of indentation
set fillchars+=fold:\ " Don't use fold divider character
" set nofoldenable " disable folding
" Diff
set fillchars+=diff:\ " Don't fill deleted diff lines
set diffopt+=vertical " Always show diffs in a vertical split
" Performance
set lazyredraw
set ttyfast
"----------------------------------------------------------
" UI Settings
"----------------------------------------------------------
" Colorscheme
if &background == 'dark'
let g:spacegray_use_italics = 1
colorscheme spacegray
else
let g:one_allow_italics = 1
colorscheme one
endif
" Color Settings
syntax on
set t_Co=256 " Enable 256 color
" UI Settings
set mouse=a " Enable mouse
set showcmd " Show current command bottom right
set wildmenu " Show command line suggestions
set number " Show line numbers
set nowrap " Disable wrapping of long lines
set shortmess+=I " Hide Vim's welcome message
set showmatch " highlight matching [{()}]
" set cursorline " Highlight current line
" Invisible Character
set list " Show invisible characters
set showbreak=↪\ " Line breaks for wrap option
set listchars=tab:→\ ,nbsp:␣,trail:·,extends:⟩,precedes:⟨
" │ » → •
" Window Settings
set laststatus=2 " Always show window status line
set splitright " Vertical split to right side
set fillchars+=vert:\ " Don't use window divider character
" Set truecolor for 16 million colors
" INFO: https://gist.github.com/XVilka/8346728
" BUG: This checks if vim is built with +termguicolors feature.
" We need a way to check if the current terminal supports truecolor.
" Hyper.js and Terminal.app don't support truecolor.
if has('termguicolors')
set termguicolors
endif
" GUI Settings
if has("gui_running")
set fuoptions=maxvert,maxhorz " Full screen mode settings
" set guioptions=emgt " Hide toolbar and scrollbars
set guifont=Roboto\ Mono:h13
set linespace=3 " Increase line height
set lines=999 columns=95 " Set window size
endif
" Experimental tmux settings
if $TERM == 'tmux-256color'
" Italics and true color support in tmux+vim
" INFO: https://medium.com/@dubistkomisch/how-to-actually-get-italics-and-true-colour-to-work-in-iterm-tmux-vim-9ebe55ebc2be
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Mouse in tmux doesn't resize windows, but this option makes
" scrolling very slow in vim without tmux
set ttymouse=xterm2
endif
" Change cursor in insert mode
if $TERM_PROGRAM == 'iTerm.app'
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
"----------------------------------------------------------
" Mappings
"----------------------------------------------------------
" Set <space> as the <leader> key
let g:mapleader = "\<Space>"
" Disable Arrow Keys
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Experimental: Quickfix motions
nnoremap [q :cprevious<cr>
nnoremap ]q :cnext<cr>
nnoremap [Q :cfirst<cr>
nnoremap ]Q :clast<cr>
" Experimental: Location list motions
nnoremap [l :lprevious<cr>
nnoremap ]l :lnext<cr>
nnoremap [L :lfirst<cr>
nnoremap ]L :llast<cr>
" Experimental: Buffer motions
nnoremap [b :bprevious<cr>
nnoremap ]b :bnext<cr>
nnoremap [B :bfirst<cr>
nnoremap ]B :blast<cr>
" Turn off search highlight
nnoremap <leader>c :nohlsearch<cr>
" File management and quick quit
nnoremap <leader>s :w<cr>
nnoremap <leader>qq :q<cr>
nnoremap <leader>q1 :q!<cr>
" Open vimrc in a new tab
nnoremap <leader>ve :tabe $MYVIMRC<cr>
nnoremap <leader>vs :source $MYVIMRC<cr>
" Terminal mappings
nnoremap <leader>td :terminal<cr>docker-compose up -d --build
nnoremap <leader>tn :terminal<cr>npm install
" Undotree mappings
nnoremap <leader>ut :UndotreeToggle<cr>
nnoremap <leader>ui :earlier<cr>
nnoremap <leader>uo :later<cr>
" Ipad Settings
" map! ` <ESC>
" vmap! ` <ESC>
" Exit visual mode immediately
" vmap <esc> <C-c>
"----------------------------------------------------------
" Vim Plug Settings
"----------------------------------------------------------
nnoremap <leader>pi :PlugInstall<cr>
nnoremap <leader>pu :PlugUpdate<cr>
nnoremap <leader>pc :PlugClean<cr>
"----------------------------------------------------------
" Which Key Settings
"----------------------------------------------------------
set timeoutlen=500
let g:which_key_map = {}
let g:which_key_map.a = { 'name' : '+ale' }
let g:which_key_map.c = { 'name' : '+clear-highlight' }
let g:which_key_map.f = { 'name' : '+fuzy-finder' }
let g:which_key_map.f.b = 'buffer-finder'
let g:which_key_map.f.f = 'file-finder'
let g:which_key_map.f.h = 'help-finder'
let g:which_key_map.f.c = 'command-finder'
let g:which_key_map.g = { 'name' : '+git' }
let g:which_key_map.g.s = 'status'
let g:which_key_map.g.c = 'commit'
let g:which_key_map.g.d = 'diff'
let g:which_key_map.g.p = 'push'
let g:which_key_map.g.r = ':Gread'
let g:which_key_map.g.w = ':Gwrite'
let g:which_key_map.g.e = ':Gedit...'
let g:which_key_map.g.h = 'open-github'
let g:which_key_map.g.g = ':Git...'
let g:which_key_map.g.o = 'checkout...'
let g:which_key_map.g.b = 'branch'
let g:which_key_map.g.t = 'tree'
let g:which_key_map.g.f = 'fold'
let g:which_key_map.g.v = 'view'
let g:which_key_map.h = { 'name' : '+hunk' }
let g:which_key_map.h.s = 'stage-hunk'
let g:which_key_map.h.u = 'unstage-hunk'
let g:which_key_map.h.p = 'preview-hunk'
let g:which_key_map.n = { 'name' : '+nerd-tree' }
let g:which_key_map.n.t = 'toggle-nerd-tree'
let g:which_key_map.n.f = 'find-nerd-tree'
let g:which_key_map.p = { 'name' : '+plugin' }
let g:which_key_map.p.i = 'install-plugins'
let g:which_key_map.p.c = 'clean-plugins'
let g:which_key_map.p.u = 'update-plugins'
let g:which_key_map.q = { 'name' : '+quit' }
let g:which_key_map.qq = 'quit'
let g:which_key_map.q1 = 'quit without save'
let g:which_key_map.r = { 'name' : '+ranger' }
let g:which_key_map.r.n = 'ranger-new-tab'
let g:which_key_map.r.t = 'ranger-toggle'
let g:which_key_map.s = 'Save'
let g:which_key_map.t = { 'name' : '+terminal' }
let g:which_key_map.t.d = 'docker-compose-build'
let g:which_key_map.t.n = 'npm-install'
let g:which_key_map.u = { 'name' : '+undo-tree' }
let g:which_key_map.u.i = 'earlier'
let g:which_key_map.u.o = 'later'
let g:which_key_map.v = { 'name' : '+vim' }
let g:which_key_map.v.s = 'source-vimrc'
let g:which_key_map.v.e = 'edit-vimrc'
call which_key#register('<space>', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey '<leader>'<CR>
vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<leader>'<CR>
autocmd! FileType which_key
autocmd FileType which_key set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
"----------------------------------------------------------
" Airline Settings
"----------------------------------------------------------
" Airline picks the current theme, but specify for spacegray
if g:colors_name == 'spacegray'
let g:airline_theme = 'zenburn'
end
" Airline + A.L.E Integration
let g:airline#extensions#ale#enabled = 1
" Display all the buffers
" let g:airline#extensions#tabline#enabled = 1
" Don't show the file path in Airline's Tabline
let g:airline#extensions#tabline#formatter = 'unique_tail'
" Powerline fonts
let g:airline_powerline_fonts = 1
let g:Powerline_symbols = 'unicode'
"----------------------------------------------------------
" Ale Settings
"----------------------------------------------------------
let g:ale_sign_error = '✖'
let g:ale_sign_warning = '⚠'
let g:ale_completion_enabled = 1
nnoremap <silent> <leader>ah :ALEHover<CR>
nnoremap <silent> <leader>ad :ALEDetail<CR>
nnoremap <silent> <leader>af :ALEFix<CR>
nnoremap <silent> <leader>ai :ALEInfo<CR>
nnoremap <silent> <leader>at :ALEToggle<CR>
nnoremap <silent> <leader>ar :ALEFindReferences<CR>
nnoremap <silent> <leader>ag :ALEGoToDefinition<CR>
"----------------------------------------------------------
" NERDTree Settings
"----------------------------------------------------------
let NERDTreeMinimalUI=1
nnoremap <leader>nf :NERDTreeFind<CR>
nnoremap <leader>nt :NERDTreeToggle<CR>
" Make `/` character same as the folder name
highlight link NERDTreeDirSlash NERDTreeDir
"----------------------------------------------------------
" FZF Settings
"----------------------------------------------------------
" :Buffers Jump to the existing window if possible
let g:fzf_buffers_jump = 1
" Command key doesn't work, we are using option/alt key <command-t>
nnoremap <leader>fb :Buffers<CR>
nnoremap <leader>ff :GFiles<CR>
nnoremap <leader>fh :Helptags<CR>
nnoremap <leader>fc :Commands<CR>
"----------------------------------------------------------
" GitGutter Settings
"----------------------------------------------------------
" Faster updatetime so that GitGutter can update instantly
set updatetime=100
" Use line highlighting instead of signs if light background
if &background == "light"
let g:gitgutter_signs = 0
let g:gitgutter_highlight_lines = 1
endif
let g:gitgutter_sign_added = '┃'
let g:gitgutter_sign_modified = '┃'
let g:gitgutter_sign_removed = '━'
let g:gitgutter_sign_modified_removed = '┳'
" Folds all unchanged lines in the buffer
noremap <leader>gf :GitGutterFold<cr>
"----------------------------------------------------------
" Fugitive Settings
"----------------------------------------------------------
augroup fugitive_autocmds
autocmd!
autocmd Filetype fugitive setlocal nonumber
" autocmd Filetype fugitive setlocal winfixheight
autocmd Filetype gitcommit setlocal nonumber
autocmd Filetype gitcommit setlocal spell
" autocmd Filetype gitcommit exe "resize " . line('$')
augroup END
noremap <leader>gs :Gstatus<cr>
noremap <leader>gc :Gcommit<cr>
noremap <leader>gd :Gdiff<cr>
noremap <leader>gp :Gpush<cr>
noremap <leader>gr :Gread<cr>
noremap <leader>gw :Gwrite<cr>
noremap <leader>ge :Gedit<space>
noremap <leader>gh :Gbrowse @:<cr>
" Shell aliases
noremap <leader>gg :Git<space>
noremap <leader>go :Git checkout<space>
noremap <leader>gb :Git branch<cr>
noremap <leader>gt :Git tree --all<cr>
"----------------------------------------------------------
" GV Settings
"----------------------------------------------------------
noremap <leader>gv :GV --all<cr>
"----------------------------------------------------------
" Ranger Settings
"----------------------------------------------------------
let g:ranger_map_keys = 0
nnoremap <leader>rt :Ranger<CR>
nnoremap <leader>rn :RangerNewTab<CR>
"----------------------------------------------------------
" SimpleSmoothScroll Settings
"----------------------------------------------------------
map <ScrollWheelUp> <C-Y>
map <ScrollWheelDown> <C-E>
"----------------------------------------------------------
" Syntastic Settings
"----------------------------------------------------------
" let g:syntastic_check_on_open = 1
" let g:syntastic_always_populate_loc_list = 1
"----------------------------------------------------------
" Persistant Undo
"----------------------------------------------------------
set undodir=~/.vim/.undodir/
set undofile
"----------------------------------------------------------
" Vim Javascript Settings
"----------------------------------------------------------
" Highlight js code within JSDoc comment blocks
let g:javascript_plugin_jsdoc = 1
"----------------------------------------------------------
" Highlight Overwrites
"----------------------------------------------------------
if &background == "light"
highlight clear Visual
highlight clear Search
highlight clear IncSearch
highlight Visual guibg=#d7ffff
highlight Search guibg=#fffc38 cterm=italic gui=italic
highlight clear DiffAdd
highlight clear DiffChange
highlight clear DiffDelete
highlight clear DiffText
highlight DiffAdd ctermbg=194 guibg=#e7feed
highlight DiffChange ctermbg=230 guibg=#ffffd7
highlight DiffDelete ctermbg=224 guibg=#feeef0
highlight DiffText guibg=#ffe6bc
" Fugitive objects use these groups
highlight DiffFile guibg=NONE
highlight DiffNewFile guibg=NONE
highlight! link DiffAdded DiffAdd
highlight! link DiffRemoved DiffDelete
highlight! link DiffLine Folded
endif
if g:colors_name == 'spacegray'
highlight clear Todo
highlight! link VertSplit StatusLineNC
highlight! link TabLineFill StatusLineNC
highlight! link TabLineSel StatusLine
highlight DiffText guibg=#d88735 guifg=black cterm=italic,bold
highlight DiffChange guibg=#815d3a guifg=black
highlight Error cterm=NONE
end
if g:colors_name == 'one' && &background == "light"
highlight clear Folded
highlight Folded guibg=#e8f1fb guifg=#868c90 cterm=italic
" Remove underline
highlight TabLine cterm=NONE gui=NONE
highlight! link VertSplit StatusLine
end