-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins.vim
635 lines (477 loc) · 17.2 KB
/
plugins.vim
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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
filetype plugin on
call plug#begin('~/.vim/plugged')
" 'github_user/repo_name'
" -----------------------------------
" coc language server BEGIN
Plug 'neoclide/coc.nvim', {'branch': 'release'}
let g:coc_global_extensions = ['coc-json', 'coc-yaml', 'coc-jedi', 'coc-diagnostic', 'coc-clangd', 'coc-markdownlint', 'coc-rust-analyzer']
let g:coc_buffers_to_apply_to = '*.c,*.py,*.json,*.yaml,*.rs'
if os ==# 'Darwin' || os ==# 'Mac'
"
call extend(g:coc_global_extensions, ['coc-groovy', '@yaegassy/coc-ansible'])
"
" custom for Coc Mappings below
let g:coc_buffers_to_apply_to = '*.groovy,*.conf,*.md,' . g:coc_buffers_to_apply_to
let g:coc_filetype_map = {
\ 'yaml.ansible': 'ansible',
\ }
" DISABLED on purpose
" augroup playbooks
" autocmd BufNewFile,BufRead */playbooks/*.yaml set ft=yaml.ansible
" autocmd BufNewFile,BufRead */tests/*.yaml set ft=yaml.ansible
" autocmd BufNewFile,BufRead */roles/*/*.yaml set ft=yaml.ansible
" augroup END
elseif os ==# 'Linux'
" custom for Coc Mappings below
let g:coc_buffers_to_apply_to = '' . g:coc_buffers_to_apply_to
endif
function! CocDiagnosticsReopen()
:lcl
:CocDiagnostics
endfunction
augroup coc_mappings
" do not duplicate autocmds on reload
autocmd!
" Symbol renaming.
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . ' nnoremap <leader>rn <Plug>(coc-rename)'
" GoTo code navigation.
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . ' nnoremap <silent> gd <Plug>(coc-definition)'
" Show References
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . ' nnoremap <silent> gR <Plug>(coc-references)'
" Show function signature
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . " nnoremap <silent> gs :call CocActionAsync('doHover')<cr>"
" Mappings for CoCList
" Show all diagnostics.
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . ' nnoremap <silent><nowait> <BackSpace><BackSpace> :call CocDiagnosticsReopen()<cr>'
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . ' nnoremap <silent><nowait> <BackSpace><Enter> :lcl<cr>'
" Show commands.
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . ' nnoremap <silent><nowait> <space>c :CocList commands<cr>'
" Find symbol of current document.
execute 'autocmd BufEnter,FocusGained ' . g:coc_buffers_to_apply_to . ' nnoremap <silent><nowait> <space>o :CocList outline<cr>'
augroup END
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" 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>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <silent><expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" coc language server END
" -----------------------------------
"
" :[range]Join[!] [separator] [count] [flags]
"
" flags :
" r : (reverse) join lines in reverse
" k : (keep) don't remove joined line after join
"
" e.g.
" replace new lines with literal '\n', use `!` to keep leading/trailing whitespace
" :'<,>'Join! '\n'
" :'<,>'Join '\n'
"
Plug 'sk1418/Join'
" re-evaluated on 2024-03-06. keeping this in case I ever want to
" convert a binary plist file
Plug 'tpope/vim-afterimage' " edit ICO, PNG, and GIF, PDFs and macos plists
" -----------------
" vim-commentary
Plug 'tpope/vim-commentary'
" custom comment strings
augroup custom_comment_strings
" do not duplicate autocmds on reload
autocmd!
autocmd FileType firejail setlocal commentstring=#\ %s
autocmd FileType text setlocal commentstring=#\ %s
autocmd FileType json setlocal commentstring=//\ %s
augroup END
" -----------------
" netrw replacement
Plug 'justinmk/vim-dirvish'
" improve vim's netrw
" Plug 'tpope/vim-vinegar'
"
" -----------------------
" justinmk/vim-sneak
" f / t command improved
Plug 'justinmk/vim-sneak'
noremap f <Plug>Sneak_f
noremap F <Plug>Sneak_F
noremap t <Plug>Sneak_t
noremap T <Plug>Sneak_T
" :help sneak
" forward jump in normal mode ... s<whattosearchfor>
" backward jump in normal mode S<whattosearchfor>
"
let g:sneak#label = 1
" TODO 2024-03-06 use label-mode -> minimalist alternative
" to https://github.com/easymotion/vim-easymotion
" -----------------------
" ----------------------
" tagbar
"
Plug 'majutsushi/tagbar'
let g:tagbar_left = 1
" set shorcut for tagbar plugin
nnoremap <f8> :TagbarToggle<cr>
" set path to tags file
set tags=.git/tags
" ----------------------
" tmux-resurrect dependency (do :mksession automatically...)
" :Obsession <path-to-store>
Plug 'tpope/vim-obsession'
" ----------------------------
" check with `set runtimepath?
" let &runtimepath = '<path-to-ack.vim>,' . &runtimepath
" e.g.
" let &runtimepath = '/root/.vim/plugged/ack.vim,' . &runtimepath
Plug 'mileszs/ack.vim'
" Page up/down bindings
let g:ack_mappings = {
\ 'H': '<c-b>',
\ 'L': '<c-f>' }
" replace ack by the silverlight seacher
" let g:ackprg = 'ag --exclude -f -a --vimgrep'
let g:ackprg = 'ag -f --vimgrep
\ --ignore-dir .git
\ --ignore-dir .helm
\ --ignore-dir .tox
\ --ignore-dir .pulumi
\ --ignore-dir .cache
\ --ignore-dir .mypy_cache
\ --ignore-dir .eggs
\ --ignore-dir *.egg-info
\ --ignore-dir *venv*
\ --ignore-dir _build
\ --ignore-dir __pycache__
\ --ignore "*.pyc"
\ --ignore-dir .pytest_cache
\ --ignore poetry.lock
\ --ignore-dir htmlcov
\ --ignore "*.html"
\ --ignore build.*trace
\ --ignore Session.vim'
" if only grep available
" let g:ackprg = 'grep -n
" \ --exclude-dir=.git
" \ --exclude-dir=.helm
" \ --exclude-dir=.tox
" \ --exclude-dir=.pulumi
" \ --exclude-dir=.cache
" \ --exclude-dir=.mypy_cache
" \ --exclude-dir=.eggs
" \ --exclude-dir=*.egg-info
" \ --exclude-dir=*venv*
" \ --exclude-dir=_build
" \ --exclude-dir=__pycache__
" \ --exclude="*.pyc"
" \ --exclude-dir=.pytest_cache
" \ --exclude=poetry.lock
" \ --exclude-dir=htmlcov
" \ --exclude="*.html"
" \ --exclude=build.*trace
" \ --exclude=Session.vim
"
" close quickfix window mapping
execute 'autocmd BufEnter,FocusGained * nnoremap <silent><nowait> <BackSpace><Space> :ccl<cr>'
" ----------------------------
Plug 'airblade/vim-gitgutter'
" ---------------------
" fzf integration
"
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
noremap <leader>B :Buffers<CR>
noremap <leader>E :Files<CR>
let g:fzf_preview_window = ['up:50%:hidden', 'ctrl-/']
" ---------------------
" how to use it? the easiest way
" vim -b <filename>
Plug 'rootkiter/vim-hexedit'
" --------------------------------
" rainbow plugin
"
Plug 'luochen1990/rainbow'
" highlight corresponding parentheses
" :RainbowToggle
let g:rainbow_active = 1 " enabled
"
" Check current text object by pressing <F4>
"
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody'
\ },
\ 'sh': {
\ 'parentheses_options': 'containedin=Function,shFunction,shFunctionOne,shTestDoubleQuote,shDoubleQuote,shSetList,shSingleQuote,shConditional,shRange,shIf,shSet,shDblBrace contained',
\ },
\ 'yaml': {
\ 'parentheses_options': 'containedin=yamlFlowString,yamlPlainScalar contained',
\ },
\ 'rst': {
\ 'parentheses_options': 'containedin=rstExDirective',
\ },
\ }
\}
" check the syntax name and definitions under the cursor
nnoremap <f1> :echo synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
nnoremap <f2> :echo ("hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">")<cr>
nnoremap <f3> :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>
nnoremap <f4> :exec 'syn list '.synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
" --------------------------------
" --------------------------------
" colorscheme onehalf
Plug 'sonph/onehalf', { 'rtp': 'vim' }
function! <sid>SetColorScheme()
if &ft =~? '^yaml$\|^rst$\|^markdown$'
call ColorOneHalfLight()
else
call ColorOff()
endif
endfunction
augroup set_colorscheme_for_yaml_files
" do not duplicate autocmds on reload
autocmd!
autocmd FocusGained,BufEnter * :call <sid>SetColorScheme()
augroup END
" --------------------------------
" --------------------------------
" colorscheme almost without color
"
Plug 'pbrisbin/vim-colors-off'
" ! On mac we cannot call this in the plugin section
" it won't find the colorscheme that way.
" --------------------------------
Plug 'vim-syntastic/syntastic'
let g:syntastic_vim_checkers = ['vint']
let g:syntastic_python_checkers = [''] " disable syntastic for python
" helps to end certain structures automatically
" e.g. adds "endfunction" if you start a function in vimscript
Plug 'tpope/vim-endwise'
" increase and decrease numbers and dates ... <ctrl-a>/<ctrl-x>
Plug 'tpope/vim-speeddating'
" e.g. ds" to delete surrounding quotes ; ysTEXTOBJECT' to surround TEXTOBJECT with ' ; cs"' to change " to '
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat' " support native repeat operation '.' for plugins that implement tpope/vim-repeat
Plug 'inkarkat/vim-ingo-library' " dependency for vim-mark and vim-ReplaceWithRegister
Plug 'inkarkat/vim-visualrepeat' " dependency for vim-ReplaceWithRegister
Plug 'inkarkat/vim-ReplaceWithRegister'
" -----------------
" vim-mark
"
" highlight a word under your cursor ... <leader>m
" highlight based on a regex pattern ... <leader>r
" to remove all highlights do: :MarkClear
"
" jump to the next mark (any) ... <leader>/
" jump to the next mark (same pattern) ... <leader>*
"
" set the palette ... :MarkPalette extended
" note: MarkPalette supports autocompletion
"
Plug 'inkarkat/vim-mark'
let g:mwDefaultHighlightingPalette = 'extended'
" -----------------
" ---------
" ShellCheck config
Plug 'itspriddle/vim-shellcheck'
function! ShellCheckReopen()
:ccl
:ShellCheck!
endfunction
augroup ShellCheck
" do not duplicate autocmds on reload
autocmd!
autocmd FileType sh nnoremap <silent><nowait> <BackSpace><BackSpace> :call ShellCheckReopen()<cr>
autocmd FileType sh nnoremap <silent><nowait> <BackSpace><Enter> :ccl<cr>
augroup end
" ----------
Plug 'diepfote/vim-primitive-yamlsort'
" built-in yaml syntax highlighting breaks if
" you have a array bracket expression.
"
" e.g.
" "{{ sources[0]}}"
Plug 'stephpy/vim-yaml'
" ---
" improve yaml file movement
"
" shows current yaml item in statusline
" Plug 'Einenlum/yaml-revealer'
" jump based on indentation level
"
" [- : Move to previous line of lesser indent than the current line.
" [+ : Move to previous line of greater indent than the current line.
" [= : Move to previous line of same indent as the current line that is separated from the current line by lines of different indents.
" ]- : Move to next line of lesser indent than the current line.
" ]+ : Move to next line of greater indent than the current line.
" ]= : Move to next line of same indent as the current line that is separated from the current line by lines of different indents.
Plug 'jeetsukumaran/vim-indentwise'
map K <Plug>(IndentWisePreviousEqualIndent)
map J <Plug>(IndentWiseNextEqualIndent)
" ---
" narrow range plugin / NarrowRange plugin
Plug 'chrisbra/NrrwRgn'
" tmux integration
" re-evaluated on 2024-03-06
Plug 'tpope/vim-tbone' " select text, then do :Twrite pane-id/alias
" ---------------------------------------
Plug 'tpope/vim-fugitive' " git from vim
function! <sid>FugitiveAddGoToParentTreeMapping()
if !exists('b:fugitive_type')
return
endif
if b:fugitive_type =~# '^\%(tree\|blob\)$'
nnoremap <buffer> .. :edit %:h<CR>
endif
endfunction
augroup fugitiveVim
" do not duplicate autocmds on reload
autocmd!
autocmd BufEnter * :call <sid>FugitiveAddGoToParentTreeMapping()
augroup end
" ---------------------------------------
" -----------------------------------
" zig-vim
Plug 'ziglang/zig.vim'
augroup zig-vim-autocommands
" do not duplicate autocmds on reload
autocmd!
" Symbol renaming.
au FileType zig :compiler zig_build_exe
augroup END
" -----------------------------------
" -----------------------------------
" vim-go settings start
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
augroup vim-go-mappings
" do not duplicate autocmds on reload
autocmd!
" Symbol renaming.
au FileType go nnoremap <leader>rn :GoRename<cr>
" GoTo code navigation.
au FileType go nnoremap <silent>gd <Plug>(go-def)
au FileType go nnoremap <silent>gR :GoReferrers<cr>
augroup END
" vim-go settings end
" -----------------------------------
" the following does not work in neovim:
" ```
" cnoremap W! w !sudo tee % >/dev/null
" ```
" thus:
Plug 'lambdalisue/suda.vim'
" When pasting, it compresses all blank
" lines that result from the paste to a
" single one
" (or none, at the top and bottom of the file).
Plug 'AndrewRadev/whitespaste.vim'
" check `vimrc` for `@Disabled 2024-02-15` and `lessspace`
" trim whitespace on modified lines
Plug 'thirtythreeforty/lessspace.vim'
let g:lessspace_blacklist = ['diff', 'markdown']
" The plugin is designed to automatically rename closing
" HTML/XML tags when editing opening ones (or the other way around)
Plug 'AndrewRadev/tagalong.vim'
" add filetype bpftrace
Plug 'mmarchini/bpftrace.vim'
" ------------------------------
" bufferize BEGIN
" I previously used 'sjl/clam.vim' which only bufferizes shell commands.
"
Plug 'AndrewRadev/bufferize.vim'
nnoremap ! :Bufferize<space>!<space>source<space>~/.vim/source-me;<space>
" bufferize END
" ------------------------------
call plug#end()
function ChangeHighlightSearch()
" set search highlight color
" hi Search cterm=NONE ctermfg=black ctermbg=white
"
set hlsearch "to highlight in cterm
set incsearch
"
highlight Search gui=bold guifg=black guibg=yellow cterm=bold term=NONE ctermfg=black ctermbg=yellow
highlight IncSearch gui=underline,bold guifg=white guibg=red cterm=underline,bold term=NONE ctermfg=white ctermbg=DarkRed
endfunction
function ChangeHighlightSelection()
highlight Visual ctermbg=lightmagenta guibg=lightmagenta
" highlight Visual ctermbg=lightblue guibg=lightblue
" highlight Visual ctermbg=lightgray guibg=lightgray
endfunction
function ChangeHighlightCurrentLine()
highlight CursorLine guifg=NONE guibg=lightyellow cterm=NONE ctermfg=NONE ctermbg=lightyellow
endfunction
function ChangeHighlightStatusLine()
highlight StatusLine guibg=lightred guifg=#444444 ctermfg=grey ctermbg=lightred
endfunction
function ChangeHighlightTabLine()
highlight TabLineFill guibg=lightblue guifg=#444444 ctermfg=grey ctermbg=lightblue
endfunction
function ChangeHighlightVerticalLine()
" indicates character limit
highlight ColorColumn guifg=NONE guibg=lightyellow
endfunction
function ColorSharedSettings()
:RainbowToggleOn
:MarkPalette extended
call ChangeHighlightCurrentLine()
call ChangeHighlightStatusLine()
call ChangeHighlightTabLine()
call ChangeHighlightVerticalLine()
call ChangeHighlightSearch()
call ChangeHighlightSelection()
endfunction
function ColorOneHalfLight()
let l:colorscheme_name = 'onehalflight'
if exists('g:colors_name')
if g:colors_name ==# l:colorscheme_name
return
endif
endif
execute 'colorscheme ' . l:colorscheme_name
call ColorSharedSettings()
endfunction
function ColorOff()
let l:colorscheme_name = 'off'
if exists('g:colors_name')
if g:colors_name ==# l:colorscheme_name
return
endif
endif
" pbrisbin/vim-colors-off
set background=light
execute 'colorscheme ' . l:colorscheme_name
call ColorSharedSettings()
endfunction
" -------------
" Abbreviations
cabbrev __commit cheatsheets_commit_and_push
cabbrev __pull cheatsheets_pull
cabbrev __rezepte rezepte_commit_and_push
" -------------