-
Notifications
You must be signed in to change notification settings - Fork 4
/
.vimrc
590 lines (488 loc) · 15.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
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
" zacanger's .vimrc
if has('vim_starting')
set nocompatible " Be iMproved
endif
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-tsserver',
\ 'coc-html',
\ 'coc-css',
\ 'coc-yaml',
\ 'coc-sh',
\ ]
" \ 'coc-pyright',
" \ 'coc-go',
call plug#begin('~/.local/share/vim/plugged')
Plug 'vim-jp/vital.vim' " deps
Plug 'vim-scripts/SyntaxRange' " deps
Plug 'vim-scripts/ingo-library' " deps
Plug 'FooSoft/vim-argwrap' " wrap items in blocks/lists
Plug 'airblade/vim-rooter' " set path to project root
Plug 'ervandew/supertab' " tab insert-mode completions
Plug 'bling/vim-airline' " better statusline
Plug 'bounceme/poppy.vim' " simple highlight/rainbow parens plugin
Plug 'bronson/vim-trailing-whitespace' " highlight trailing whitespace
Plug 'jiangmiao/auto-pairs' " auto-complete pairs of things
Plug 'junegunn/seoul256.vim' " colo
Plug 'junegunn/vim-easy-align' " align stuff on a symbol (like the comments in this block)
" Plug 'fatih/vim-go' " go support
Plug 'junegunn/vim-peekaboo' " see registers easily
Plug 'junegunn/vim-slash' " better buffer search
Plug 'mhinz/vim-signify' " vcs markers in gutter, also see 'airblade/vim-gitgutter'
Plug 'moll/vim-node' " enchance vim for node (for example, better gf)
Plug 'scrooloose/nerdcommenter' " there are so many commenter plugins, but this one just works
Plug 'sgur/vim-editorconfig' " support editorconfig
Plug 'sheerun/vim-polyglot' " language support
Plug 'tpope/vim-surround' " surround things with other things
Plug 'vim-scripts/paredit.vim' " balance parens
Plug 'vim-scripts/syntaxcomplete' " super simple syn completion
Plug 'vim-utils/vim-husk' " bash emacs-mode mappings in command mode
Plug 'vim-utils/vim-troll-stopper' " highlight unicode chars that look like ascii chars
Plug 'tmux-plugins/vim-tmux-focus-events' " fix focus events from tmux
Plug 'blueyed/vim-diminactive' " dim inactive windows, works with the tmux fix
Plug 'dhruvasagar/vim-table-mode' " instant tables
Plug 'neoclide/coc.nvim', { 'branch': 'release' } " LSP support
call plug#end()
"" Basic Setup
filetype plugin indent on
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
" Fix backspace indent
set backspace=indent,eol,start
" Tabs. May be overriten by autocmd rules
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set smarttab
set autoindent
" Map leader to ,
let mapleader="\<Space>"
" Enable hidden buffers
set hidden
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
highlight clear Search
highlight Search ctermfg=White
" Clean search (highlight)
nnoremap <silent> <leader>/ :noh<cr>
" blink the line containing the match
fu! HLNext (blinktime)
set invcursorline
redraw
exec 'sleep ' . float2nr(a:blinktime * 250) . 'm'
set invcursorline
redraw
endfu
" highlight matches when jumping to next
" This rewires n and N to do the highlighing...
nnoremap <silent> n n:call HLNext(0.4)<cr>
nnoremap <silent> N N:call HLNext(0.4)<cr>
" Encoding
set bomb
set binary
" Don't write these, it's not like Vim crashes all that often
set nobackup
set noswapfile
set fileformats=unix,dos,mac
set showcmd
set shell=/bin/bash
"" Visual Settings
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set cursorline
set guioptions=egmrti
set gfn=Monospace\ 10
if &term =~ '256color'
set t_ut=256
endif
" Disable the blinking cursor.
set gcr=a:blinkon0
set scrolloff=3
" Map cursor for insert mode
if &term =~ "xterm\\|rxvt"
let &t_SI .= "\<Esc>[5 q"
let &t_EI .= "\<Esc>[0 q"
endif
" Status bar
set laststatus=2
" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
" vim-airline
let g:airline_theme = 'seoul256'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#tabline#enabled = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
if !exists('g:airline_powerline_fonts')
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_left_sep = '▶'
let g:airline_left_alt_sep = '»'
let g:airline_right_sep = '◀'
let g:airline_right_alt_sep = '«'
let g:airline#extensions#branch#prefix = '⤴' "➔, ➥, ⎇
let g:airline#extensions#readonly#symbol = '⊘'
let g:airline#extensions#linecolumn#prefix = '¶'
let g:airline#extensions#paste#symbol = 'ρ'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
else
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
" powerline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
endif
" abbrs
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qa! qa!
cnoreabbrev qa1 qa!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev WQ wq
cnoreabbrev E e
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev X x
cnoreabbrev stu sort u
cnoreabbrev Stu sort u
cnoreabbrev Set set
cnoreabbrev Bd bd
inoreabbr lmbd λ
inoreabbr frll ∀
inoreabbr (tm) ™
inoreabbr (c) ©
inoreabbr (r) ®
inoreabbr hamsic ☭
inoreabbr neccessary necessary
inoreabbr neccesary necessary
" wild
set wildmenu
set path+=**
set wildmode=list:longest,list:full
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
set wildignore+=*.o,*.obj,.git,*.rbc,__pycache__,node_modules/**,bower_components/**
set wildignore+=solr/**,log/**,*.psd,*.PSD,.git/**,.gitkeep,.gems/**
set wildignore+=*.ico,*.ICO,backup/**,*.sql,*.dump,*.tmp,*.min.js,Gemfile.lock
set wildignore+=*.png,*.PNG,*.JPG,*.jpg,*.JPEG,*.jpeg,*.GIF,*.gif,*.pdf,*.PDF
set wildignore+=vendor/**,coverage/**,tmp/**,rdoc/**,*.BACKUP.*,*.BASE.*,*.LOCAL.*,*.REMOTE.*,.sass-cache/**
if !exists('*s:setupWrapping')
fu s:setupWrapping()
set wrap
set wm=4
set textwidth=79
endfu
endif
"" aus
" syntax highlight syncing from start
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync fromstart
augroup END
" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
au BufRead,BufNewFile *.md setlocal textwidth=80
autocmd FileType css set omnifunc=csscomplete#CompleteCSS noci
set autoread
"" mappings
nnoremap > >>
nnoremap < <<
" select most recently edited text
nnoremap vp `[v`]
" gq: format, ip: in paragraph. i do this a lot, so leader-q is nice.
noremap <Leader>q gqip
" split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>
" Disable visualbell
set noeb vb t_vb=
"" system clipboard
set clipboard^=unnamed,unnamedplus
noremap YY "+y<CR>
noremap P "+gP<CR>
noremap XX "+x<CR>
" Switching windows
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h
" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=4
\ formatoptions+=croq softtabstop=4 smartindent
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
" vim-airline
let g:airline#extensions#virtualenv#enabled = 1
let g:javascript_enable_domhtmlcss = 1
inoremap <Esc> <Esc>`^
cnoremap sudow w !sudo tee & >/dev/null
let g:seoul256_background = 233
try
colorscheme seoul256
catch /^Vim\%((\a\+)\)\=:E185/
colorscheme elflord
endtry
let g:netrw_banner=0
let g:netrw_browser_split=4
let g:netrw_altv=1
let g:netrw_liststyle=3
let g:netrw_list_hide=netrw_gitignore#Hide()
let g:netrw_gx="<cWORD>"
" commit message thing
autocmd Filetype gitcommit setlocal spell textwidth=80
autocmd Filetype markdown set spell
autocmd Filetype text set spell
" clear screen between shell commands
nnoremap :! :!clear;
vnoremap :! :!clear;
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" keep Y consistent
nnoremap Y y$
" vim-markdown (from polyglot)
let g:vim_markdown_conceal = 0
let g:vim_markdown_new_list_item_indent = 4
let g:vim_markdown_folding_disabled = 1
let g:csstoinline_wrap_pixels = 1
" match % on more stuff
if !exists('g:loaded_matchit')
runtime macros/matchit.vim
endif
" better ctrl-l
nnoremap <leader>l :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>
" show tabs
set list lcs=tab:\|\
" except in go, because gofmt says so
autocmd FileType go set nolist
" break line on words
set linebreak
" keep indentation
set breakindent
set showbreak=\\\\\
" fix where new splits show up
set splitbelow
set splitright
" relative dirs
set autochdir
" use relative numbers in most modes
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
let g:paredit_mode=0
let g:paredit_leader="\<Space>"
let g:parinfer_mode="off"
" use <F8> to go to next conflict marker
map <silent> <F8> /^\(<\{7\}\\|>\{7\}\\|=\{7\}\\|\|\{7\}\)\( \\|$\)<cr>
if has('mouse')
set mouse=a
endif
" pixie
au BufNewFile,BufRead *.pxi set ft=clojure
" I don't ever write Verilog, but might try out V
au BufNewFile,BufRead *.v set ft=vlang
" cshtml
au BufNewFile,BufRead *.cshtml set ft=html
" alternate jenkinsfiles
au BufNewFile,BufRead Promotionfile set ft=jenkinsfile
au BufNewFile,BufRead *.jenkinsfile set ft=jenkinsfile
" babelrc
au BufNewFile,BufRead .babelrc set ft=json
" highlight the 121st column of wide lines
hi ColorColumn ctermbg=235
call matchadd('ColorColumn', '\%121v', 100)
" syntaxcomplete
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
nnoremap <leader>w :w<CR>
nnoremap <leader>x :x<CR>
nnoremap <leader>m :make<CR>
" nerdcommenter
let g:NERDSpaceDelims=1
let g:NERDCommentEmptyLines=1
" argwrap
let g:argwrap_padded_braces = '[{'
let g:argwrap_tail_comma_braces = '[{'
nnoremap <silent> <leader>a :ArgWrap<CR>
" match angle brackest
set matchpairs+=<:>
" preserve flags for pattern when repeating substitution with &
nnoremap <silent> & :<C-U>&&<CR>
vnoremap <silent> & :<C-U>&&<CR>
" don't redraw the screen when executing macros, etc
set lazyredraw
if has('virtualedit')
set virtualedit+=block
endif
set nojoinspaces
set display=lastline
" node native addons
au BufNewFile,BufRead *.gyp set ft=json
" easyalign
" start in visual mode (vipga)
xmap ga <Plug>(EasyAlign)
" start for object/motion (gaip)
nmap ga <Plug>(EasyAlign)
" vim-trailing-whitespace
let g:extra_whitespace_ignored_filetypes = ['go', 'md']
" if Poppy isn't loaded (like when first installing plugins),
" calling it will error, so we just set some defaults instead
if exists('poppyhigh')
au! cursormoved * call PoppyInit()
else
" match pairs
inoremap { {}<Esc>ha
inoremap ( ()<Esc>ha
inoremap [ []<Esc>ha
inoremap " ""<Esc>ha
inoremap ' ''<Esc>ha
inoremap ` ``<Esc>ha
endif
" don't use {{{ }}}, also syntax never really works the way i want
set foldmethod=manual
let g:AutoPairsShortcutToggle = ''
" Silence the cd echo
let g:rooter_silent_chdir = 1
" dimming settings
let g:diminactive_enable_focus = 1
let g:diminactive_use_colorcolumn = 1
let g:diminactive_use_syntax = 1
" fix imports + format on save
" let g:go_fmt_command = "goimports"
" convert camelCase to snake_case
nnoremap <leader>crs :g;<c-r><c-w>; s;[a-z]\@<=[A-Z];_\l&;g<cr>
" coc settings
" use <tab> to trigger completion and navigate to the next complete item
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <Tab>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
inoremap <expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>"
" TODO: maybe use these instead of some plugins
" function! StripTrailingWhitespaces() abort
" let l:save = winsaveview()
" keeppatterns %s/\v\s+$//e
" call winrestview(l:save)
" endfunction
" autocmd BufWritePost * StripTrailingWhitespaces
"
" " dylan araps wrote this. i don't think he'll mind.
" let g:root#patterns = get(g:, 'root#patterns', ['.git', '_darcs', '.hg', '.bzr', '.svn'])
" let g:root#auto = get(g:, 'root#auto', 0)
" let g:root#autocmd_patterns = get(g:, 'root#autocmd_patterns', '*')
" let g:root#echo = get(g:, 'root#echo', 1)
"
" function! s:findRoot()
" if &buftype ==? ''
" " The plugin doesn't work with autochdir
" set noautochdir
"
" " The plugin only works with local directories
" if expand('%:p') =~? '://'
" return
" endif
"
" " Start in open file's directory
" silent! lcd %:p:h
" let l:liststart = 0
"
" for l:pattern in g:root#patterns[l:liststart : len(g:root#patterns)]
" " If l:pattern is a file use findfile() else use finddir()
" if matchstr(l:pattern, '\m\C\w\+\.\w*$') == l:pattern
" let l:fullpath = findfile(l:pattern, ';')
" else
" let l:fullpath = finddir(l:pattern, ';')
" endif
"
" " Split the directory into path/match
" let l:match = matchstr(l:fullpath, '\m\C[^\/]*$')
" let l:path = matchstr(l:fullpath, '\m\C.*\/')
"
" " $HOME + match
" let l:home = $HOME . '/' . l:pattern
" if l:fullpath == '' || l:fullpath == l:home
" let l:liststart = l:liststart + 1
" lcd %:p:h
" elseif empty(l:match) == 0
" break
" endif
"
" " If the search hits the end of the list start over
" if l:liststart == len(g:root#patterns)
" let l:liststart = 0
" endif
" endfor
"
" " If path is anything but blank
" if l:path !=? ''
" exe 'lcd' . ' ' l:path
" endif
"
" if g:root#echo == 1 && l:match !=? ''
" echom 'Found' l:match 'in' getcwd()
" elseif g:root#echo == 1
" echom 'Root dir not found'
" endif
" endif
" endfunction
"
" command! Root call s:findRoot()
" augroup root
" au!
" exe 'autocmd BufEnter ' . g:root#autocmd_patterns . ' :Root'
" augroup END