-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
593 lines (489 loc) · 14.1 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
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
" Yeah, bye vi
set nocompatible
" THE FUTURE
set encoding=UTF-8
" Tab config
set smarttab
set shiftwidth=2
set tabstop=2
set autoindent
set expandtab
" Wrap while searching for strings
set wrapscan
" Wrap at whitespace instead of the middle of a word.
set linebreak
set wrap
set wrapmargin=2
set display+=lastline
" Formatting options - help formatoptions/fo-table
set formatoptions=cn1
" Show matching parens
set showmatch
" Time to wait before matching parens (tenths of seconds)
set matchtime=1
" The opposite is set noignorecase
set ignorecase
set smartcase " Global replace by default set gdefault
" You may want to turn off the beep sounds (if you want quite) with visual bell
set vb
" Make command line two lines high
set ch=2
" Allow deleting previously entered charecters in insert mode
set backspace=indent,eol,start
" I like highlighting strings inside C comments
let c_comment_strings=1
" Always show the status line
set laststatus=2
"Shows the current editing mode
set showmode
" Set line numbers
set number
"Show the ruler
set ruler
"Highlight all matches
set hlsearch
"Show search while typing
set incsearch
" Show tabs as >-
set list
set listchars=tab:>-,trail:-
" Make backup files end in .bak instead of ~
set backupext=.bak
" Allow the creation of hidden buffers
set hidden
" Save up to 500 lines of history
set history=500
" Menus Gone Wild!
set wildmenu
" isomorphic-copy clipboard magic
if has('nvim')
" use unnamedplus only! or else will double set
set clipboard=unnamedplus
if getenv('DISPLAY') == v:null
exe setenv('DISPLAY', 'FAKE')
endif
else
autocmd TextYankPost * call system("c", getreg('"'))
endif
" I guess I have to do this to make my cursor wrap lines?
set whichwrap+=<,h,l,[,]
" Commands start with ,
let mapleader = ","
""""""""""""""""""""""""""""""""""""""""""
" Functions
""""""""""""""""""""""""""""""""""""""""""
" Strip trailing whitespace and delete blanks
function! <SID>StripTrailingWhitespaces()
let _s=@/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let @/=_s
call cursor(l, c)
endfunction
command! StripTrail call <SID>StripTrailingWhitespaces()
command! DeleteBlank :g/^$/d
function! HtmlEntities()
silent %s/À/\À/e silent %s/Á/\Á/e
silent %s/Â/\Â/e
silent %s/Ã/\Ã/e
silent %s/Ä/\Ä/e
silent %s/Å/\Å/e
silent %s/Æ/\Æ/e
silent %s/Ç/\Ç/e
silent %s/È/\È/e
silent %s/É/\É/e
silent %s/Ê/\Ê/e
silent %s/Ë/\Ë/e
silent %s/Ì/\Ì/e
silent %s/Í/\Í/e
silent %s/Î/\Î/e
silent %s/Ï/\Ï/e
silent %s/Ð/\Ð/e
silent %s/Ñ/\Ñ/e
silent %s/Ò/\Ò/e
silent %s/Ó/\Ó/e
silent %s/Ô/\Ô/e
silent %s/Õ/\Õ/e
silent %s/Ö/\Ö/e
silent %s/Ø/\Ø/e
silent %s/Ù/\Ù/e
silent %s/Ú/\Ú/e
silent %s/Û/\Û/e
silent %s/Ü/\Ü/e
silent %s/Ý/\Ý/e
silent %s/Þ/\Þ/e
silent %s/ß/\ß/e
silent %s/à/\à/e
silent %s/á/\á/e
silent %s/â/\â/e
silent %s/ã/\ã/e
silent %s/ä/\ä/e
silent %s/å/\å/e
silent %s/æ/\æ/e
silent %s/ç/\ç/e
silent %s/è/\è/e
silent %s/é/\é/e
silent %s/ê/\ê/e
silent %s/ë/\ë/e
silent %s/ì/\ì/e
silent %s/í/\í/e
silent %s/î/\î/e
silent %s/ï/\ï/e
silent %s/ð/\ð/e
silent %s/ñ/\ñ/e
silent %s/ò/\ò/e
silent %s/ó/\ó/e
silent %s/ô/\ô/e
silent %s/õ/\õ/e
silent %s/ö/\ö/e
silent %s/ø/\ø/e
silent %s/ù/\ù/e
silent %s/ú/\ú/e
silent %s/û/\û/e
silent %s/ü/\ü/e
silent %s/ý/\ý/e
silent %s/þ/\þ/e
silent %s/ÿ/\ÿ/e
silent %s/“/"/e
silent %s/”/"/e
silent %s/’/'/e
endfunction
command! HtmlEntities :call HtmlEntities()
""""""""""""""""""""""""""""""""""""""""""
" Filetype-Specific Config
""""""""""""""""""""""""""""""""""""""""""
" AutoCmds
if has("autocmd")
filetype plugin indent on
au BufNewFile,BufRead *.rss,*.atom setfiletype xml
au BufNewFile,BufRead Gemfile,Rakefile,*.ru,*.thor setfiletype ruby
au BufNewFile,BufRead *.json,*.draftsSyntax setfiletype json
au BufNewFile,BufRead *.mst set filetype=mustache
au BufNewFile,BufRead Supfile,*.sup setfiletype yaml
" Syntax options
au FileType java :set shiftwidth=4
function! SetPythonOptions()
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
endfunction
au FileType python call SetPythonOptions()
" Delimitmate
function! SetGitOptions()
set spell
let b:delimitMate_autoclose = 0
endfunction
au FileType gitcommit call SetGitOptions()
" Autoload vimrc and gvimrc
au! BufWritePost .vimrc source ~/.vimrc | source ~/.gvimrc
au! BufWritePost .gvimrc source ~/.gvimrc
" Crontab
autocmd filetype crontab setlocal nobackup nowritebackup
" Latex
autocmd filetype tex set conceallevel=0 spell
endif
" HTML Escaping
function! <SID>HtmlEscape()
silent '<,'>s/&/\&/eg
silent '<,'>s/</\</eg
silent '<,'>s/>/\>/eg
endfunction
command! HtmlEscape call <SID>HtmlEscape()
function! <SID>HtmlUnEscape()
silent '<,'>s/</</eg
silent '<,'>s/>/>/eg
silent '<,'>s/&/\&/eg
endfunction
command! HtmlUnEscape call <SID>HtmlUnEscape()
command! PreviewHTML :!open %<CR>
"""""""""""""""""""""""""""""""""""""""
" Plugins!
" Managed with https://github.com/junegunn/vim-plug
"""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim-plugged')
" Color Schemes
Plug 'vim-scripts/Colour-Sampler-Pack'
" ChromeReload
Plug 'tell-k/vim-browsereload-mac'
nnoremap <leader>r :ChromeReload<CR>
let g:returnApp = "kitty"
" FZF
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>f :GFiles<CR>
nnoremap <leader>F :Files<CR>
nnoremap <leader>a :Ag<CR>
nnoremap <leader>h :Helptags<CR>
nnoremap <leader>c :Commands<CR>
nnoremap <leader>l :Lines<CR>
" AnyJump
Plug 'pechorin/any-jump.vim'
let g:any_jump_disable_default_keybindings = 1
nnoremap <leader>aj :AnyJump<CR>
xnoremap <leader>aj :AnyJumpVisual<CR>
nnoremap <leader>ajb :AnyJumpBack<CR>
nnoremap <leader>ajl :AnyJumpLastResults<CR>
" Gundo
Plug 'sjl/gundo.vim'
nnoremap <leader>G :GundoToggle<CR>
" Quick Dash search
Plug 'rizzatti/dash.vim'
nnoremap <leader>d :Dash
" Funcoo is a Dependency
Plug 'rizzatti/funcoo.vim'
" Gitgutter
Plug 'airblade/vim-gitgutter'
highlight clear SignColumn
highlight SignColumn guibg=NONE ctermbg=NONE
" MiniMap
Plug 'wfxr/minimap.vim'
let g:minimap_width = 10
let g:minimap_auto_start = 1
let g:minimap_auto_start_win_enter = 1
" Gist
Plug 'mattn/webapi-vim'
Plug 'mattn/gist-vim'
let g:gist_open_browser_after_post = 1
let g:gist_show_privates = 1
let g:gist_detect_filetype = 1
let g:gist_clip_command = 'pbcopy'
let g:github_user = "chrismetcalf"
" GH Line
Plug 'ruanyl/vim-gh-line'
" vim-airline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline_powerline_fonts = 1
let g:airline_theme='jellybeans'
let g:airline#extensions#bufferline#enabled = 1
" Misc fun stuff
Plug 'timcharper/gitosis.vim'
Plug 'rhysd/git-messenger.vim'
Plug 'godlygeek/tabular'
Plug 'airblade/vim-rooter'
Plug 'junegunn/goyo.vim'
Plug 'gcmt/wildfire.vim'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'Yggdroot/indentLine'
" Color Scheme
Plug 'NLKNguyen/papercolor-theme'
Plug 'sheerun/vim-polyglot'
Plug 'pineapplegiant/spaceduck', { 'branch': 'main' }
" vim-test
Plug 'janko/vim-test'
Plug 'benmills/vimux'
let test#strategy='vimux'
nnoremap <leader>tn :TestNearest<CR>
nnoremap <leader>tf :TestFile<CR>
nnoremap <leader>ta :TestSuite<CR>
nnoremap <leader>tt :TestLast<CR>
" Snipmate and its friends
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
let g:snipMate = { 'snippet_version' : 1 }
Plug 'honza/vim-snippets'
" tpope is my spirit animal
Plug 'tpope/vim-haml'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-git'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-pastie'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rvm'
Plug 'tpope/vim-tbone'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-heroku'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-jdaddy'
Plug 'tpope/vim-vinegar'
" Easy Align
Plug 'junegunn/vim-easy-align'
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" Capitalization
Plug 'arthurxavierx/vim-caser'
" Syntax
Plug 'vim-scripts/vim-json-bundle'
Plug 'tclem/vim-arduino'
Plug 'honza/dockerfile.vim'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-liquid'
Plug 'lrampa/vim-apib'
Plug 'davidoc/taskpaper.vim'
Plug 'nikvdp/ejs-syntax'
" Markdown
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
" Docker
Plug 'kevinhui/vim-docker-tools'
" Completion
Plug 'ervandew/supertab'
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'zchee/deoplete-jedi'
let g:deoplete#enable_at_startup = 1
" Tmux
Plug 'christoomey/vim-tmux-navigator'
Plug 'tmux-plugins/tpm'
Plug 'tmux-plugins/vim-tmux'
Plug 'tmux-plugins/vim-tmux-focus-events'
" Open current selection in Github
Plug 'prakashdanish/vim-githubinator'
" incsearch
Plug 'haya14busa/incsearch.vim'
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" illuminates word matches in movement modes
Plug 'RRethy/vim-illuminate'
" Syntastic!
" Plug 'vim-syntastic/syntastic'
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
Plug 'w0rp/ale'
let g:airline#extensions#ale#enabled = 1
nmap <silent> <C-s-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-s-j> <Plug>(ale_next_wrap)
" Keymapping pop-up
Plug 'liuchengxu/vim-which-key'
nnoremap <silent> <leader> :WhichKey ','<CR>
" REPL magic
Plug 'rhysd/reply.vim'
" Startup screen, why not?
Plug 'mhinz/vim-startify'
" DevIcons always needs to be last
Plug 'ryanoasis/vim-devicons'
" EasyMotion
Plug 'easymotion/vim-easymotion'
let g:EasyMotion_do_mapping = 0 " Disable default mappings
" Jump to anywhere you want with minimal keystrokes, with just one key binding.
" `s{char}{label}`
nmap s <Plug>(easymotion-overwin-f)
" or
" `s{char}{char}{label}`
" Need one more keystroke, but on average, it may be more comfortable.
nmap s <Plug>(easymotion-overwin-f2)
" Turn on case-insensitive feature
let g:EasyMotion_smartcase = 1
" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
call plug#end()
""""" END Plugins """""""""""""""""""""
" Set colorscheme
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
colorscheme spaceduck
let g:airline_theme = 'spaceduck'
""""""""""""""""""""""""""""""""""""""""""
" Key Mappings
""""""""""""""""""""""""""""""""""""""""""
" Mappings for window keys
nmap <silent> <C-k> :wincmd k<CR>
nmap <silent> <C-j> :wincmd j<CR>
nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-l> :wincmd l<CR>
nmap <silent> <C-down> :wincmd k<CR>
nmap <silent> <C-up> :wincmd j<CR>
nmap <silent> <C-left> :wincmd h<CR>
nmap <silent> <C-right> :wincmd l<CR>
" Toggle through buffers
nmap <silent> <C-Tab> :bprevious<CR>
" Quick search clear
nnoremap <leader><space> :noh<cr>
" Make
nnoremap <leader>m :Make<CR>
" Reselect just pasted
nnoremap <leader>v V`]
" Move one screen line at a time while wrapped
nmap j gj
nmap k gk
vmap j gj
vmap k gk
" Quick exit out of insert mode
inoremap jj <Esc>
inoremap jjw <Esc>:w<CR>
inoremap jjwq <Esc>:wq<CR>
" Quick save
nnoremap <leader>w :w!<CR>
" Vimux
map <leader>vp :VimuxPromptCommand<CR>
map <leader>vl :VimuxRunLastCommand<CR>
map <leader>vi :VimuxInspectRunner<CR>
" Duplicate the line below
vmap D y'>p
" Reverse the selected lines
vnoremap <leader>r !tac<CR>
" Disable help, since its annoying as hell
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Pressing ,sp will toggle and untoggle spell checking
map <leader>sp :setlocal spell!<cr>
" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
" Tab skips
map <leader>] :tabn<CR>
map <leader>[ :tabp<CR>
" Jekyll magic
nnoremap <leader>jw :silent !tmux split-window -d -l 8 'cd $(pwd); jekyll build --watch --safe'<cr>
nnoremap <leader>mw :silent !tmux split-window -b -l 8 'cd $(pwd); make watch<cr>
" Quick search/replace from
" http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
vnoremap <silent> s //e<C-r>=&selection=='exclusive'?'+1':'<CR><CR>
\:<C-u>call histdel('search',-1)<Bar>let @/=histget('search',-1)<CR>gv
omap s :normal vs<CR>
" Sudo to write
cmap w!! w !sudo tee % >/dev/null
" Don't replace the buffer when you put
" vp doesn't replace paste buffer
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
vmap <silent> <expr> p <sid>Repl()
" Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif
" Don't store ~ and .swp files in the same directory.
if filewritable($HOME) && ! filewritable($HOME . "/.vimbackup")
silent call mkdir($HOME . "/.vimbackup", "p", 0700)
endif
if filewritable($HOME) && ! filewritable($HOME . "/.vimswap")
silent call mkdir($HOME . "/.vimswap", "p", 0700)
endif
set backupdir=~/.vimbackup,$TEMP,$TMP
set directory=~/.vimswap,$TEMP,$TMP
" Source local configs
if filereadable("$HOME/.vimrc.local")
source $HOME/.vimrc.local
end