-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnvimrc
585 lines (546 loc) · 17.1 KB
/
nvimrc
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
" vim:fdm=marker
" __ _
" / /_ _______ ______ _____ _ __(_)___ ___ __________
" / __ \/ ___/ / / / __ `/ __ \ | | / / / __ `__ \/ ___/ ___/
" / /_/ / / / /_/ / /_/ / / / / | |/ / / / / / / / / / /__
" /_.___/_/ \__, /\__,_/_/ /_/ |___/_/_/ /_/ /_/_/ \___/
"
"
" essential state and remappings {{{
set nocompatible
:set nu
nnoremap <leader>rl :set rnu!<CR>
set clipboard=unnamedplus
set cursorline
filetype indent on
set wildmenu
set lazyredraw
set showmatch
set updatetime=500
set tabstop=4
set softtabstop=4
set expandtab
"allow sb to jump to existing tab
:set swb=usetab
"ruler 80
:set cc=80
imap <C-i> <Esc>
imap jj <Esc>
tnoremap jj <C-\><C-n>
" virtual j k
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
tnoremap <Esc> <C-\><C-N>
nnoremap <silent><Leader><C-]> <C-w><C-]><C-w>T
" }}}
" fvim {{{
if exists('g:fvim_loaded')
nnoremap <silent> <C-1> :set guifont=+<CR>
nnoremap <silent> <C-2> :set guifont=-<CR>
guifont=Fira Code Retina
FVimCursorSmoothMove v:true
FVimCursorSmoothBlink v:true
FVimFontNormalWeight 400
FVimFontBoldWeitht 700
FVimUIPopupMenu v:true
FVimBackgroundOpacity 0.85
FVimFontLigature v:true
FVimFontSubpixel v:true
endif
" }}}
" Plugins {{{
" Plug autoload {{{
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" }}}
"Plug
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdcommenter'
Plug 'artur-shaik/vim-javacomplete2'
Plug 'scrooloose/nerdtree'
Plug 'wesQ3/vim-windowswap'
Plug 'vim-scripts/PapayaWhip'
Plug 'vim-scripts/a.vim'
Plug 'airblade/vim-gitgutter'
" tag plugins {{{
Plug 'vim-scripts/taglist.vim'
Plug 'ludovicchabant/vim-gutentags'
Plug 'craigemery/vim-autotag'
Plug 'simplyzhao/cscope_maps.vim'
" }}}
" fzf {{{
Plug 'junegunn/fzf.vim'
"local fzf install watch out on new machines
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" }}}
Plug 'mhinz/neovim-remote'
Plug 'raghur/vim-ghost', {'do': ':GhostInstall'}
Plug 'embear/vim-localvimrc'
Plug 'gburca/vim-logcat'
Plug 'neomutt/neomutt.vim'
Plug 'tfnico/vim-gradle'
Plug 'wincent/replay'
Plug 'Houl/repmo-vim'
" formatting plugins {{{
Plug 'rhysd/vim-grammarous'
Plug 'bennyyip/vim-yapf'
Plug 'Rip-Rip/clang_complete'
Plug 'maksimr/vim-jsbeautify'
Plug 'Chiel92/vim-autoformat'
" }}}
" language/file format specific plugins {{{
Plug 'slashmili/alchemist.vim'
Plug 'sheerun/vim-polyglot'
Plug 'elzr/vim-json'
Plug 'lervag/vimtex'
" }}}
" CoC Extensions {{{
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#build()}}
Plug 'tjdevries/coc-zsh'
Plug 'neoclide/coc-vimtex', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-sources', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'}
"}}}
" snippet extensions {{{
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'vim-scripts/csv.vim'
" }}}
" cosmetic plugins {{{
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" }}}
Plug 'gcmt/taboo.vim'
" markdown plugins {{{
Plug 'plasticboy/vim-markdown'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
Plug 'esalter-va/vim-checklist'
" }}}
Plug 'tpope/vim-surround'
Plug 'Raimondi/delimitMate'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'alvan/vim-closetag'
Plug 'vim-scripts/vim-auto-save'
Plug 'vim-scripts/textutil.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tommcdo/vim-fubitive'
Plug 'christoomey/vim-conflicted'
Plug 'jeetsukumaran/vim-buffergator'
Plug 'godlygeek/tabular'
Plug 'vimlab/split-term.vim'
Plug 'vim-scripts/vcscommand.vim'
" numbers and colors {{{
Plug 'qwertologe/nextval.vim'
Plug 'glts/vim-radical'
Plug 'glts/vim-magnum'
Plug 'chrisbra/Colorizer'
Plug 'junegunn/rainbow_parentheses.vim'
" }}}
" refactor plugins {{{
Plug 'LucHermitte/vim-refactor'
Plug 'apalmer1377/factorus'
" }}}
Plug 'sedm0784/vim-you-autocorrect'
Plug 'danro/rename.vim'
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
Plug 'junegunn/limelight.vim'
Plug 'junegunn/goyo.vim'
" mac plugins {{{
if has('mac')
Plug 'Dinduks/vim-holylight'
endif
" }}}
" color schemes {{{
Plug 'wimstefan/vim-artesanal'
Plug 'lifepillar/vim-wwdc17-theme'
Plug 'plan9-for-vimspace/acme-colors'
Plug 'altercation/vim-colors-solarized'
Plug 'gruvbox-community/gruvbox'
Plug 'icymind/NeoSolarized'
" }}}
call plug#end()
" }}}
"addbreviations {{{
:abbreviate #t # TODO(btidwell):
" }}}
" Custom leader mappings {{{
"refresh
map <leader>e :e!<CR>
" close
map <leader>zz :q!<CR>
nmap gzz :q!<CR>
nnoremap go <C-w>gf
nnoremap gw <C-w><C-]>1<CR><CR>
nnoremap gwn :tn<CR>
nnoremap gwp :tp<CR>
nmap gq @q
map <leader>tl :tabclose<CR>
nmap tl :tabclose<CR>
"save
map <leader>ss :w<CR>
nnoremap <C-s> :w<CR>
nnoremap s :w<CR>
"nnoremap s i_<Esc>r
nnoremap <leader>y ggVGy''
nnoremap <leader>sa :wa<CR>
"add line spacing without leaving normal mode
nmap <leader>o o<Esc>x
nmap <leader>O O<Esc>x
nmap <leader>np :set nopaste<CR>
nnoremap <leader>u :silent w\|!urlview %<CR>
"other
map <leader>nn :noh<CR>
map <leader>nf :NERDTreeFind<CR>
map <leader>nt :NERDTreeToggle<CR>
map <leader>fm :Autoformat<CR>
"stolen from Erik Falor
nnoremap Q !!sh<CR>
nnoremap <leader>sb :set scrollbind!<CR>
" insert date
" todo
" 1. don't insert on new line
" 2. use function and support formatting
" CheckList Mappings {{{
map <leader>dte :put =strftime(\"%c\")<CR>
noremap <leader>ct :ChecklistToggleCheckbox<cr>
noremap <leader>ce :ChecklistEnableCheckbox<cr>
noremap <leader>cd :ChecklistDisableCheckbox<cr>
noremap <leader>ct :ChecklistToggleCheckbox<cr>
vnoremap <leader>ce :ChecklistEnableCheckbox<cr>
vnoremap <leader>cd :ChecklistDisableCheckbox<cr>
" }}}
" }}}
" fzf {{{
map <leader>fi :Files<CR>
map <leader>hi :History:<CR>
map <leader>hp :History/<CR>
map <leader>hh :History<CR>
map <leader>rg :Rg<CR>
map <leader>gf :GFiles<CR>
map <leader>gs :GFiles?<CR>
map <leader>ff :Buffers<CR>
map <leader>ec :EnableAutoCorrect<CR>
"fzf config
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
" }}}
" open config files {{{
nnoremap <leader>rr :source $MYVIMRC<CR>
nnoremap <leader>re :tabnew $MYVIMRC<CR>
if !has('mac') && !has('wsl')
nnoremap <leader>i3 :tabnew ~/.config/i3/config<CR>
endif
if has('mac')
nnoremap <leader>sk :tabnew ~/.skhdrc<CR>
if filereadable($HOME + ".chunkwmrc")
nnoremap <leader>ch :tabnew ~/.chunkwmrc<CR>
else
nnoremap <leader>yr :tabnew ~/.yabairc<CR>
endif
endif
nnoremap <leader>rz :tabnew ~/.zshrc<CR>
nnoremap <leader>rlz :tabnew ~/.lzshrc<CR>
nnoremap <leader>gls :tabnew ~/Documents/writing/2020_goals.md<CR>
nnoremap <leader>pb :tabnew ~/.config/polybar/config<CR>
"}}}
" spelling {{{
nnoremap <leader>sp :setlocal spell! spell?<CR>
set complete+=kspell
set thesaurus+=~/moby.txt
nnoremap zn ]s
nnoremap zp [s
nnoremap ze z=
" override color scheme to make bad spellings red.
augroup vimrc
autocmd!
autocmd ColorScheme * highlight SpellBad ctermbg=red guibg=red
augroup END
" }}}
" colors {{{
"NeoSolarized color options
syntax enable
set background=light
set termguicolors
let g:solarized_termcolors=256
let g:neosolarized_contrast = "high"
let g:neosolarized_visibility = "high"
let g:gruvbox_contrast_light = "hard"
let g:gruvbox_contrast_dark = "hard"
colorscheme gruvbox
if has("gui_running")
unset termguicolors
endif
" }}}
"vim session settings {{{
let g:session_autosave_silent = 'true'
let g:session_autosave_periodic = 5
let g:session_autoload = 'no'
let g:session_autosave = 'yes'
let g:session_default_name = 'default'
" }}}
"diff settings {{{
set diffopt+=vertical
set diffopt+=iwhite
set diffexpr="\n"
"show vim-confliced info in statusbar
set stl+=%{ConflictedVersion()}
" }}}
"tab remappings {{{
noremap <left> :tabprevious<CR>
nnoremap <right> :tabnext<CR>
" }}}
"folds {{{
autocmd FileType c setlocal foldmethod=syntax
autocmd FileType python setlocal foldmethod=indent
autocmd FileType vim setlocal foldmethod=foldmarker
"toggle all folds
:nnoremap <expr> <leader>zf &foldlevel ? 'zM' :'zR'
" }}}
" close tags {{{
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.txt'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'
let g:closetag_filetypes = 'html,xhtml,phtml,txt'
let g:closetag_xhtml_filetypes = 'xhtml,jsx'
let g:closetag_emptyTags_caseSensitive = 1
"let g:closetag_regions = {
"\ 'typescript.tsx': 'jsxRegion,tsxRegion',
"\ 'javascript.jsx': 'jsxRegion',
"\ }
let g:closetag_shortcut = '>'
let g:closetag_close_shortcut = '<leader>+>'
let delimitMate_matchpairs = "(:),[:],{:},<:>"
au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:}"
" }}}
" search macros and mappings {{{
function! Search_clipboard()
execute '/' . @*
endfunction
function! Find_trailing_spaces()
execute '/\s$'
endfunction
function! Find_Exception()
execute '/Exception'
endfunction
function! Leader_Off()
autocmd!
echo "autocmd cleared"
endfunction
" {{{ save file with date
function! SaveWithTS(filename) range
let l:extension = '.' . fnamemodify( a:filename, ':e' )
if len(l:extension) == 1
let l:extension = '.txt'
endif
let l:filename = escape( fnamemodify(a:filename, ':r') . strftime(" - %Y-%m-%d_%H-%M") . l:extension, ' ' )
execute "write " . l:filename
endfunction
command! -nargs=1 SWT call SaveWithTS( <q-args> )
" }}}
" split sentences to lines
map <leader>nln :%s/\([.!?]\)\s\+/\1\ \r/g <CR> \nn
"search for copied text
map <leader>sh :call Search_clipboard()<CR>
map <leader>tsp :call Find_trailing_spaces()<CR>
map <leader>err :call Find_Exception()<CR>
" }}}
"Markdown {{{
let g:mkdp_auto_start = 0
let g:mkdp_auto_close = 1
let g:mkdp_refresh_slow = 0
let g:mkdp_command_for_global = 0
let g:mkdp_open_to_the_world = 0
if has('mac')
let g:mkdp_browser = 'FireFox'
else
let g:mkdp_browser='firefox'
endif
"vim-markdown options {{{
let g:vim_markdown_no_extensions_in_markdown = 1
let g:vim_markdown_new_list_item_indent = 0
autocmd filetype markdown noremap <buffer> <C-m> :MarkdownPreview<CR>
autocmd filetype markdown EnableAutocorrect
autocmd BufRead,BufNewFile *.md setlocal spell
autocmd filetype markdown hi SpellBad ctermfg=red guifg=red guibg=black
au BufRead,BufNewFile *.md setlocal textwidth=80
au BufRead,BufNewFile *.txt setlocal textwidth=80
" }}}
" }}}
" ghost config {{{
let g:ghost_autostart = 1
augroup ghost
au!
autocmd BufNewFile,BufRead *stackexchange.com* set filetype=markdown
autocmd BufNewFile,BufRead *stackoverflow.com* set filetype=markdown
autocmd BufNewFile,BufRead *www.betterhelp.com* set filetype=html
autocmd BufNewFile,BufRead *www.betterhelp.com* EnableAutocorrect
autocmd BufNewFile,BufRead *www.betterhelp.com* setlocal textwidth=80
augroup END
" }}}
" auto save {{{
let g:auto_save_in_insert_mode = 0
let g:auto_save_silent = 1
" }}}
" vagrant ruby highlight {{{
" Teach vim to syntax highlight Vagrantfile as ruby
"
" Install: $HOME/.vim/plugin/vagrant.vim
" Author: Brandon Philips <[email protected]>
augroup vagrant
au!
au BufRead,BufNewFile Vagrantfile set filetype=ruby
augroup END
" }}}
" GitGutter remappings {{{
nmap gs :GitGutterStageHunk<CR>
nnoremap gu :GitGutterUndoHunk<CR>
nnoremap <leader>gp :GitGutterPreviewHunk<CR>
nnoremap gn :GitGutterNextHunk<CR>
nnoremap gp :GitGutterPrevHunk<CR>
" }}}
" nvim remote {{{
" set neovim remote
if has('nvim')
let $VISUAL = 'nvr -cc split --remote-wait'
endif
" }}}
" vim folder/files stuff {{{
nnoremap gk :let @+ = expand("%:p")<cr>
nnoremap gke :let @+ = expand("%:t")<cr>
nnoremap pwd :let @+ = getcwd()<cr>
" }}}
" Crontab {{{
" "https://www.calebthompson.io/crontab-and-vim-sitting-in-a-tree
autocmd filetype crontab setlocal nobackup nowritebackup
"}}}
" autoformat options {{{
let b:formatdef_custom_c='"clang-format-3.9 -style=file"'
let b:formatters_c = ['custom_c']
" ensure all c files are formatted on save
au BufWrite *.c :Autoformat
au BufWrite *.h :Autoformat
" ensure all python files are formatted on save
au BufWrite *.py :Autoformat
let g:yapf#auto_format_on_insert_leave='0'
" }}}
" remember last pos in file {{{
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" }}}
" airline {{{
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_solarized_bg='dark'
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
" }}}
" Android {{{
"android
let g:android_sdk_path = $ANDROID_SDK
" }}}
" startify {{{
let g:startify_session_dir = '~/.vim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' MRU'] },
\ { 'type': 'dir', 'header': [' MRU '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ { 'type': 'commands', 'header': [' Commands'] },
\ ]
" }}}
" Coc mostly copied from github {{{
autocmd BufRead coc-settings.json syntax match Comment +\/\/.\+$+
" __coc config__ bunch of arcane stuff for the rest of the file
" if hidden not set, TextEdit might fail.
set hidden
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> for trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> for confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[c` and `]c` for navigate diagnostics
"nmap <silent> [c <Plug>(coc-diagnostic-prev)
"nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K for show documentation in preview window
" I accidentally trigger this all the time and it's annoying
"nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
"autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
vmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Use `:Format` for format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` for fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Shortcuts for denite interface
" Show extension list
nnoremap <silent> <space>e :<C-u>Denite coc-extension<cr>
" Show symbols of current buffer
nnoremap <silent> <space>o :<C-u>Denite coc-symbols<cr>
" Search symbols of current workspace
nnoremap <silent> <space>t :<C-u>Denite coc-workspace<cr>
" Show diagnostics of current workspace
nnoremap <silent> <space>a :<C-u>Denite coc-diagnostic<cr>
" Show available commands
nnoremap <silent> <space>c :<C-u>Denite coc-command<cr>
" Show available services
nnoremap <silent> <space>s :<C-u>Denite coc-service<cr>
" Show links of current buffer
nnoremap <silent> <space>l :<C-u>Denite coc-link<cr>
" }}}