-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
executable file
·575 lines (485 loc) · 16.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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Get plugin manager if we don't already have it
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" Cosmetic
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-python/python-syntax'
Plug 'posva/vim-vue'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'sainnhe/edge'
Plug 'sickill/vim-monokai'
Plug 'sainnhe/sonokai'
Plug 'fneu/breezy'
Plug 'morhetz/gruvbox'
Plug 'KeitaNakamura/neodark.vim'
Plug 'joshdick/onedark.vim'
Plug 'tomasiser/vim-code-dark'
" Language Servers & Linting
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'dense-analysis/ale'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" VIM slime
Plug 'jpalardy/vim-slime', { 'branch': 'main' }
" Utils
Plug 'christoomey/vim-tmux-navigator'
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --bin'}
Plug 'junegunn/fzf.vim'
Plug 'tomtom/tcomment_vim'
Plug 'airblade/vim-gitgutter'
Plug 'heavenshell/vim-pydocstring', { 'do': 'make install' }
call plug#end()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ALE
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ale_disable_lsp = 1
let g:ale_sign_column_always = 1
let g:airline#extensions#ale#enabled = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
let g:ale_linters_explicit = 1
let g:ale_fixers = {
\"python": [
\"add_blank_lines_for_python_control_statements",
\"yapf",
\"isort",
\"remove_trailing_lines",
\"trim_whitespace",
\"black"
\],
\"sh": [
\"shfmt",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"c": [
\"clang-format",
\"clangtidy",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"cpp": [
\"clang-format",
\"clangtidy",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"go": [
\"gofmt",
\"goimports",
\"trim_whitespace",
\"remove_trailing_lines"
\],
\"rust": [
\"rustfmt",
\"trim_whitespace",
\"remove_trailing_lines"
\],
\"json": [
\"jq",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"javascript": [
\"prettier",
\"eslint",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"javascript.jsx": [
\"prettier",
\"eslint",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"typescript": [
\"prettier",
\"eslint",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"typescriptreact": [
\"prettier",
\"eslint",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"html": [
\"prettier",
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"sql": [
\"remove_trailing_lines",
\"trim_whitespace"
\],
\"vue": [
\"eslint",
\"remove_trailing_lines",
\"trim_whitespace"
\]
\}
let g:ale_linter_aliases = {
\"jsx": [
\"css",
\"javascript"
\],
\"vue": [
\"vue",
\"javascript"
\]
\}
let g:ale_linters = {
\"python": [
\"flake8",
\"bandit",
\"pylint"
\],
\"sh": [
\"shellcheck"
\],
\"c": [
\"clangd",
\],
\"cpp": [
\"clangd",
\],
\"go": [
\"gotype",
\"golint",
\"gofmt",
\"gopls",
\"gobuild",
\"govet"
\],
\"rust": [
\"cargo",
\"rls",
\"rustc"
\],
\"json": [
\"jq"
\],
\"javascript": [
\"eslint",
\"prettier"
\],
\"typescript": [
\"eslint",
\"prettier"
\],
\"jsx": [
\"stylelint",
\"eslint",
\"prettier"
\],
\"vue": [
\"eslint",
\"vls"
\]
\}
let g:ale_python_pylint_options = "--disable=C0111,C0112,C0301,C0302"
let g:ale_python_flake8_options = "--ignore=E501"
let g:ale_python_mypy_options = "--ignore-missing-imports"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Go
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn off gopls (coc.nvim already running)
let g:go_gopls_enabled = 0
let g:go_def_mapping_enabled = 0
let g:go_code_completion_enabled = 0
let g:go_auto_type_info = 0
let g:go_jump_to_error = 0
let g:go_fmt_autosave = 0
let g:go_mod_fmt_autosave = 0
let g:go_doc_keywordprg_enabled = 0
" Extra Syntax Highlighting
let g:go_highlight_extra_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_variable_declarations = 1
let g:go_highlight_variable_assignments = 1
let g:go_highlight_diagnostic_errors = 0
let g:go_highlight_diagnostic_warnings = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Main Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" Turn on spellcheck
set spell spelllang=en_us
" Yank into system clipboard
set clipboard=unnamed
" Persistent undo
set undodir=~/.vim/undodir
set undofile
" Don't wrap lines
set nowrap
" No swap files
set noswapfile
" Blink cursor on error instead of beeping (grr)
set visualbell
" Show line numbers
set number
" Encodings
set encoding=utf-8
set fileencoding=utf-8
" Fix backspace
set backspace=indent,eol,start
" Enable the mouse
set mouse=a
" Render whitespace
:set list
:set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¬,precedes:«,extends:»
" Tabs & Indents
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab
set scrolloff=5
set autoindent
" Highlight current line
set cursorline
" New splits will be at bottom or to the right
set splitbelow
set splitright
" Visual autocomplete for command menu
set wildmenu
" Highlight matching brackets, parens, etc.
set showmatch
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap / /\v
vnoremap / /\v
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmatch
map <leader><space> :let @/=''<cr> " clear search
" Search will center on line if found
nnoremap n nzzzv
nnoremap N Nzzzv
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Handy Remaps
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap leader
let mapleader = " "
" Remap escape key
inoremap fd <ESC>
vnoremap fd <ESC>
" Switch buffers
nnoremap <silent> gb :bp<CR>
nnoremap <silent> gB :bn<CR>
" Visual Mode Indenting
vnoremap < <gv
vnoremap > >gv
" Turn off search highlight
nnoremap <leader><space> :nohlsearch<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pydocstring
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <silent> ss <Plug>(pydocstring)
let g:pydocstring_formatter = "numpy"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntax Highlighting
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enhanded python highlighting (needs to be before syntax)
let g:python_highlight_all = 1
" Syntax highlighting
syntax on
" For plugins to load correctly
filetype plugin indent on
" C++ Enhanced Highlighting
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
let g:cpp_posix_standard = 1
let g:cpp_experimental_template_highlight = 1
let g:cpp_concepts_highlight = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Color Scheme
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set theme neodark
colorscheme neodark
highlight Normal ctermbg=None
"if exists('$TMUX')
"let g:dracula_colorterm = 0
"endif
" Airline
"let g:airline#extensions#coc#enabled = 1
let g:airline_theme = 'gruvbox'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Coc Nvim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set hidden
set nobackup
set nowritebackup
set cmdheight=2
set shortmess+=c
set signcolumn=auto
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
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> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)ndif
" 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 to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Remap <C-f> and <C-b> for scroll float windows/popups.
" Note coc#float#scroll works on neovim >= 0.4.0 or vim >= 8.2.0750
nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" use `:Sort` for organize python imports isort
command! -nargs=0 Sort :call CocAction('runCommand', 'python.sortImports'
" auto close scratch/preview window after completion
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" File Formatting
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup yaml_files
autocmd!
au BufRead,BufNewFile *.yml setfiletype yaml
au FileType yaml setlocal tabstop=2 softtabstop=2 shiftwidth=2
augroup END
augroup make_files
autocmd!
au FileType make setlocal noexpandtab
augroup END
augroup docker_files
autocmd!
au BufRead,BufNewFile Dockerfile.* set syntax=Dockerfile
augroup END
augroup go_files
autocmd!
au BufRead,BufNewFile go.mod set filetype=gomod
augroup markdown_files
autocmd!
autocmd FileType markdown set wrap
augroup END
augroup FiletypeGroup
autocmd!
au BufNewFile,BufRead *.jsx set filetype=javascript.jsx tabstop=2
augroup END
augroup json_files
autocmd!
au FileType json setlocal tabstop=2 softtabstop=2 shiftwidth=2
augroup END
augroup typescript_files
autocmd!
au FileType typescript setlocal tabstop=2 softtabstop=2 shiftwidth=2
augroup END
augroup xml_files
autocmd!
au FileType xml setlocal tabstop=2 softtabstop=2 shiftwidth=2
augroup END
augroup html_files
autocmd!
au FileType html setlocal tabstop=2 softtabstop=2 shiftwidth=2
augroup END
autocmd bufwritepost *.sql silent %!sqlfluff fix --dialect=snowflake --force -
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" FZF
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:fzf_preview_window = 'right:50%'
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
" search filenames
nmap <LEADER>ff :Files <CR>
" search tags in current buffer
nmap <LEADER>ft :BTags <CR>
" search tags in the project
nmap <LEADER>fT :Tags <CR>
" search lines in current buffer
nmap <LEADER>fl :BLines <CR>
" search lines in loaded buffers
nmap <LEADER>fL :Lines <CR>
" ripgrep search results
nmap <LEADER>fr :Rg <CR>
" another alias for ripgrep
nmap <LEADER>rg :Rg <CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Netrw Settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 3
let g:netrw_altv = 1
let g:netrw_winsize = 20
augroup ProjectDrawer
autocmd!
autocmd VimEnter * :Vexplore
augroup END
" Unbind <C-l> so it doesn't interfere with split navigation
nmap <LEADER>rr <Plug>NetrwRefresh
" Shortcut Vexplore
nmap <LEADER>vv :Vexplore<CR>
" Delete netrw buffer once it's hidden
autocmd FileType netrw setl bufhidden=delete
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim-Slime
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:slime_target = "tmux"
let g:slime_default_config = {"socket_name": "default", "target_pane": "{last}"}
let g:slime_dont_ask_default = 1