Repository navigation
Expand file tree
/
Copy pathvimrc
More file actions
914 lines (779 loc) · 27.9 KB
/
Copy pathvimrc
File metadata and controls
914 lines (779 loc) · 27.9 KB
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
"
""""""""""""""""""""""""""""""""""""""""" Generic VIM settings
set ts=2
set tm=500
set t_vb=
set autoindent
set autoread
set lbr
set showcmd
set nocompatible
set backspace=indent,eol,start
set history=100
set showtabline=2
set ruler " show cursor
set nohidden
set nowrap
set number
set shiftwidth=2 " number of spaces to use for autoindenting
set softtabstop=2
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
set expandtab " spaces instead tabs
set title " change the terminal's title
set titlestring=VIM:\ %-25.55F\ %a%r%m titlelen=70
set visualbell " don't beep
set noerrorbells " don't beep
set showcmd " show incomplete cmds down the bottom
set showmode " show current mode down the bottom
set incsearch " find the next match as we type the search
set hlsearch " hilight searches by default
set ttyfast " more characters will be sent to the screen for redrawing
set scrolloff=3 " keep this number of lines below and above cursor
set clipboard=unnamed " all operations work with the OS clipboard
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:. " highlight problematic whitespace
set viminfo='20,<50,s10,h,% " remember some stuff after quiting vim: marks, registers, searches, buffer list
set sessionoptions=tabpages,sesdir,folds,options,globals,help,localoptions,resize,winsize,winpos
set wildignore=*.swp,*.bak,*.pyc,*.class,.git,.DS_Store
set cindent
set modeline
set lazyredraw
set magic
set cul
if exists("+undofile")
set undolevels=256
set undoreload=10000
set undodir=~/.vim/spool
set undofile
endif
set autochdir
"set mouse=a " NOTE: disabled, otherwise it is imposible to copy text using mouse
autocmd FileType make set noexpandtab
let g:tex_flavor = "latex"
" Wrap text in TeX files
augroup WrapLineInTeXFile
autocmd!
autocmd FileType tex setlocal wrap
augroup END
" Ignore filetypes for *.module files
augroup filetypedetect
autocmd! BufNewFile,BufRead *.module setfiletype ignored
augroup END
" Fix xterm (see modifyOtherKeys)
let &t_TI = ""
let &t_TE = ""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vundle
filetype on " required on MacOSX only
filetype plugin off " required by Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Plugin 'gmarik/vundle'
Plugin 'scrooloose/nerdtree'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'vcscommand.vim'
Plugin 'tpope/vim-surround'
Plugin 'dense-analysis/ale'
Plugin 'majutsushi/tagbar'
Plugin 'kuznetsss/shswitch'
Plugin 'SearchComplete'
Plugin 'nathanaelkane/vim-indent-guides.git'
Plugin 'jimenezrick/vimerl'
Plugin 'msanders/snipmate.vim'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-repeat'
Plugin 'marcinbiegun/vim-escript'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'kshenoy/vim-signature'
Plugin 'sheerun/vim-polyglot'
Plugin 'mhinz/vim-signify'
Plugin 'mhinz/vim-startify'
Plugin 'chrisbra/Recover.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'skywind3000/vim-quickui'
Plugin 'ryanoasis/vim-devicons'
Plugin 'bkad/CamelCaseMotion'
Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plugin 'junegunn/fzf.vim'
Plugin 'ryvnf/readline.vim'
Plugin 'nkantar/SPI.vim'
Plugin 'pechorin/any-jump.vim'
Plugin 'junegunn/vim-peekaboo'
Plugin 'markonm/traces.vim'
Plugin 'ludovicchabant/vim-gutentags'
Plugin 'rhysd/git-messenger.vim'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'itspriddle/vim-shellcheck'
Plugin 'tpope/vim-endwise'
Plugin 'itspriddle/vim-stripper'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-rooter'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'unblevable/quick-scope'
Plugin 'bfrg/vim-cpp-modern'
Plugin 'lepture/vim-jinja'
Plugin 'carlsmedstad/vim-bicep'
Plugin 'vimwiki/vimwiki'
Plugin 'morhetz/gruvbox'
filetype plugin indent on " required by Vundle
filetype plugin on
""""""""""""""""""""""""""""""""""""""""""""""" Wiki
let wiki_1 = {}
let wiki_1.name = 'NVIDIA'
let wiki_1.path = '~/OneDrive/work_diary/'
let wiki_1.syntax = 'markdown'
let wiki_1.ext = 'md'
let wiki_1.auto_export = 0
let wiki_1.auto_toc = 1
let wiki_1.index = 'index'
let wiki_1.diary_rel_path = 'diary/'
let wiki_1.diary_index = 'diary_index'
let wiki_1.auto_diary_index = 1
let g:vimwiki_list = [wiki_1]
let g:vimwiki_global_ext = 0
" Diary index maintenance
augroup VimwikiDiaryIndex
autocmd!
" When opening the diary index for this wiki, refresh links
autocmd BufReadPost */OneDrive/work_diary/diary_index.md VimwikiDiaryGenerateLinks
augroup END
" Inline diary template
augroup VimwikiDiaryTemplate
autocmd!
" New diary file, named like 2025-12-21.md under ~/OneDrive/work_diary/diary
autocmd BufNewFile ~/OneDrive/work_diary/diary/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].md
\ call s:VimwikiDiaryInlineTemplate()
augroup END
function! s:VimwikiDiaryInlineTemplate() abort
" Derive date from filename (2025-12-21.md -> 2025-12-21)
let l:date_str = expand('%:t:r')
" Clear buffer just in case
%delete _
" Insert simple template
call append(0, '# ' . l:date_str)
call append(1, '')
call append(2, '## Tasks')
call append(3, '')
call append(4, '## Notes')
call append(5, '')
" Put cursor on first task line
call cursor(4, 1)
endfunction
" Carry unchecked tasks from previous diary file
function! s:PrevDiaryFile() abort
let l:dir = expand('~/OneDrive/work_diary/diary')
" Use the current diary file's date (from filename) as reference
let l:today = expand('%:t:r')
let l:files = split(globpath(l:dir, '*.md'), '\n')
if empty(l:files)
return ''
endif
let l:prev = []
for f in l:files
let base = fnamemodify(f, ':t:r') " e.g. 2025-12-21
" Only consider files strictly older than this one
if base < l:today
call add(l:prev, [base, f])
endif
endfor
if empty(l:prev)
return ''
endif
" Select the latest older file
let l:prev = sort(l:prev)[-1][1]
return l:prev
endfunction
function! s:CheckboxBody(line) abort
return substitute(a:line, '^\s*-\s\[.\]\s\+', '', '')
endfunction
function! VimwikiCarryUncheckedFromPrev() abort
let l:prev = s:PrevDiaryFile()
if empty(l:prev)
echo "No previous diary file found"
return
endif
" Read all lines from previous file
let l:lines = readfile(l:prev)
" Collect bodies of tasks that are checked in the previous file
let l:done = {}
for l:line in l:lines
if l:line =~ '^\s*-\s\[[^ ]\]\s'
let l:done[s:CheckboxBody(l:line)] = 1
endif
endfor
" Keep only unchecked tasks whose body is not also present as checked
let l:tasks = filter(copy(l:lines), {_, v ->
\ v =~ '^\s*-\s\[\s\]\s' &&
\ !has_key(l:done, s:CheckboxBody(v))})
if empty(l:tasks)
echo "No unchecked tasks in " . fnamemodify(l:prev, ':t')
return
endif
" Build a set of task bodies already present in current buffer (any state)
let l:buf_lines = getline(1, '$')
let l:buf_bodies = {}
for l:line in l:buf_lines
if l:line =~ '^\s*-\s\[.\]\s'
let l:buf_bodies[s:CheckboxBody(l:line)] = 1
endif
endfor
" Keep only tasks not already in buffer (match by body, ignoring check state)
let l:new_tasks = filter(l:tasks, {_, v ->
\ !has_key(l:buf_bodies, s:CheckboxBody(v))})
if empty(l:new_tasks)
echo "No new unchecked tasks to import from " . fnamemodify(l:prev, ':t')
return
endif
" Find or create '## Tasks' section
let l:lnum = search('^## Tasks', 'nw')
if l:lnum == 0
call append(0, ['## Tasks', ''])
let l:lnum = 1
endif
" Append only non-duplicate tasks
call append(l:lnum, l:new_tasks)
echo "Imported " . len(l:new_tasks) . " new tasks from " . fnamemodify(l:prev, ':t')
endfunction
function! VimwikiDailyNoteFn() abort
silent VimwikiMakeDiaryNote
silent call VimwikiCarryUncheckedFromPrev()
silent VimwikiDiaryIndex
silent VimwikiDiaryGenerateLinks
silent VimwikiMakeDiaryNote
endfunction
command! VimwikiDailyNote call VimwikiDailyNoteFn()
""""""""""""""""""""""""""""""""""""""""""""""" ALE
let g:ale_enabled = 0
let g:ale_cpp_cc_options = '-std=c++17'
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:cpp_clangtidy_extra_options = '-extra-arg -Xanalyzer -extra-arg -analyzer-output=text'
""""""""""""""""""""""""""""""""""""""""""""""" FZF
"" Allow to open search with root in git root
function! FindTopGitRoot()
let l:my_cwd = getcwd()
let l:git_top_level = '.'
while 1
let l:git_top_level_tmp = system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
if l:git_top_level_tmp != ''
let l:git_top_level = l:git_top_level_tmp
exe "lcd " . l:git_top_level_tmp . '/../'
else
exe "lcd " . l:my_cwd
return l:git_top_level
endif
endwhile
endfunction
command! FzfProjectFiles execute 'FZF ' FindTopGitRoot()
""""""""""""""""""""""""""""""""""""""""""""""" shswitch
let g:shswitch_root_flags = ['CMakeLists.txt', 'configure.in', 'configure']
""""""""""""""""""""""""""""""""""""""""""""""" vim-cpp-modern
let g:cpp_attributes_highlight = 1
let g:cpp_member_highlight = 1
let g:cpp_simple_highlight = 1
""""""""""""""""""""""""""""""""""""""""""""""" Quick-Scope
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
""""""""""""""""""""""""""""""""""""""""""""""" EasyMotion
let g:camelcasemotion_key = ','
""""""""""""""""""""""""""""""""""""""""""""""" Peehaboo
let g:peekaboo_compact = 1
""""""""""""""""""""""""""""""""""""""""""""""" Stripper
let g:StripperNoStripOnSave = 1
""""""""""""""""""""""""""""""""""""""""""""""" vim-devicons
set encoding=UTF-8
set guifont=DroidSansMono\ Nerd\ Font\ 11
""""""""""""""""""""""""""""""""""""""""""""""" spell
setlocal spell spelllang=en
set spell!
""""""""""""""""""""""""""""""""""""""""""""""" vim-markdown
let g:vim_markdown_override_foldtext = 0
set nofoldenable
""""""""""""""""""""""""""""""""""""""""""""""" EditorConfig
au FileType gitcommit let b:EditorConfig_disable = 1 " disable for git commit messages
""""""""""""""""""""""""""""""""""""""""""""""" QuickUI
" clear all the menus
call quickui#menu#reset()
call quickui#menu#install('&File', [
\ [ "&Open file\tCtrl+t", 'NERDTreeToggle', 'Toggle file tree panel'],
\ [ "&Close current\tF10", 'close', 'Close current file' ],
\ [ "--", '' ],
\ [ "&Save current\tF2", ':w', 'Save file'],
\ [ "Save &as", 'call feedkeys(":saveas ")', 'Save file as'],
\ [ "Save all", 'Wall', 'Save all opened files'],
\ [ "Save with Sudo", 'SudoWrite', 'Write current file with sudo'],
\ [ "--", '' ],
\ [ "Chmod", 'call feedkeys(":Chmod ")', 'Change file permissions'],
\ [ "Rename", 'call feedkeys(":Rename ")', 'Rename file'],
\ [ "--", '' ],
\ [ "E&xit\tAlt+x", 'q', 'Exit the editor'],
\ ])
call quickui#menu#install("&Diary", [
\ ["&Go to Index", 'VimwikiDiaryIndex'],
\ ["&New diary note", 'VimwikiMakeDiaryNote'],
\ ])
call quickui#menu#install("&Navigation", [
\ ["&Show changes", ':changes'],
\ ["&Previous change\tg;", 'g;'],
\ ["&Newer change\tg,", 'g;'],
\ ["&Insert in newer position\tgi", 'g;'],
\ [ "--", '' ],
\ ["&Jump to\t<leader>+j ", 'AnyJump'],
\ ["J&ump previous\t<leader>+ab", 'AnyJumpBack'],
\ ["Jump &last\t<leader>+al", 'AnyJumpLastResults'],
\ ])
call quickui#menu#install("&Code", [
\ ['Check Shell Script', 'ShellCheck!', 'Check sheel script syntax with CheckShell plugin'],
\ ['Sort Python Headers', 'SPI', 'Sort python headers in selected lines'],
\ ['Set &Spell %{&spell? "Off":"On"}', 'set spell!', 'Toggle spell check %{&spell? "off" : "on"}'],
\ ['Set &Cursor Line %{&cursorline? "Off":"On"}', 'set cursorline!', 'Toggle cursor line %{&cursorline? "off" : "on"}'],
\ ['Set &Paste %{&paste? "Off":"On"}', 'set paste!', 'Toggle paste mode %{&paste? "off" : "on"}'],
\ ['Rebuild Project Tags', 'GutentagsUpdate', 'Rebuild tags with GutenTags plugin'],
\ ['Toggle Tags Update', 'GutentagsToggleEnabled', 'Toggle automatic tags update with GutenTags plugin'],
\ ['Remove Trailing Spaces', 'Stripper', 'Remove all trailing spaces (use :3,5Striper to remove in lines 3-5)'],
\ ])
call quickui#menu#install("&Git", [
\ ["&Show history", 'GitMessenger'],
\ ["&Forward in history\tO", 'O'],
\ ["&Back in history\to", 'o'],
\ ["&Log", 'Git log', 'git log'],
\ ["&Diff", 'Git diff', 'git diff'],
\ ["Diff &Split", 'Gdiffsplit', 'git diff + split tab'],
\ ["&Blame", 'Git blame', 'git blame'],
\ ["&", ''],
\ ])
call quickui#menu#install("&Plugin", [
\ ['&List', 'BundleList'],
\ ['&Search', 'BundleSearch'],
\ ['&Update', 'BundleUpdate'],
\ ['&Install', 'BundleInstall'],
\ ['&Clean', 'BundleClean'],
\ ])
" register HELP menu with weight 1000
call quickui#menu#install('H&elp', [
\ ["&Cheatsheet", 'help index', ''],
\ ['T&ips', 'help tips', ''],
\ ['--',''],
\ ["&Tutorial", 'help tutor', ''],
\ ['&Quick Reference', 'help quickref', ''],
\ ['&Summary', 'help summary', ''],
\ ['--',''],
\ ['&Vim Script', 'help eval', ''],
\ ['&Function List', 'help function-list', ''],
\ ], 10000)
let g:context_menu_k = [
\ ["&Peek Definition\tAlt+;", 'call quickui#tools#preview_tag("")'],
\ ["S&earch in Project\t\\cx", 'exec "silent! GrepCode! " . expand("<cword>")'],
\ [ "--", ],
\ [ "Find &Definition\t\\cg", 'call MenuHelp_Fscope("g")', 'GNU Global search g'],
\ [ "Find &Symbol\t\\cs", 'call MenuHelp_Fscope("s")', 'GNU Gloal search s'],
\ [ "Find &Called by\t\\cd", 'call MenuHelp_Fscope("d")', 'GNU Global search d'],
\ [ "Find C&alling\t\\cc", 'call MenuHelp_Fscope("c")', 'GNU Global search c'],
\ [ "Find &From Ctags\t\\cz", 'call MenuHelp_Fscope("z")', 'GNU Global search c'],
\ [ "--", ],
\ [ "Goto D&efinition\t(LSP)", 'ALEGoToDefinition'],
\ [ "Goto &References\t(LSP)", 'ALEFindReferences'],
\ [ "Get D&oc\t(LSP)", 'ALEHover'],
\ [ "Get &Type\t(LSP)", 'ALEGoToTypeDefinition'],
\ [ "--", ],
\ ['Dash &Help', 'call asclib#utils#dash_ft(&ft, expand("<cword>"))'],
\ ['Cpp&man', 'exec "Cppman " . expand("<cword>")', '', 'c,cpp'],
\ ['P&ython Doc', 'call quickui#tools#python_help("")', 'python'],
\ ]
let g:quickui_show_tip = 1
let g:quickui_border_style = 2
let g:quickui_color_scheme = 'papercol dark'
""""""""""""""""""""""""""""""""""""""""""""""" AnyJump
" Show line numbers in search rusults
let g:any_jump_list_numbers = 0
" Auto search references
let g:any_jump_references_enabled = 1
" Auto group results by filename
let g:any_jump_grouping_enabled = 0
" Amount of preview lines for each search result
let g:any_jump_preview_lines_count = 5
" Max search results, other results can be opened via [a]
let g:any_jump_max_search_results = 7
" Prefered search engine: rg or ag
let g:any_jump_search_prefered_engine = 'rg'
" Search results list styles:
" - 'filename_first'
" - 'filename_last'
let g:any_jump_results_ui_style = 'filename_first'
" Any-jump window size & position options
let g:any_jump_window_width_ratio = 0.6
let g:any_jump_window_height_ratio = 0.6
let g:any_jump_window_top_offset = 4
" Disable default any-jump keybindings (default: 0)
let g:any_jump_disable_default_keybindings = 1
" Remove comments line from search results (default: 1)
let g:any_jump_remove_comments_from_results = 1
let g:any_jump_disable_default_keybindings = 1
""""""""""""""""""""""""""""""""""""""""""""""" GitMessenger
let g:git_messenger_no_default_mappings = v:false
let g:git_messenger_include_diff = "current"
let g:git_messenger_into_popup_after_show = v:false
let g:git_messenger_always_into_popup = v:true
let g:git_messenger_preview_mods = "botright"
let g:git_messenger_max_popup_width = 40
let g:git_messenger_max_popup_height = 20
function! s:setup_git_messenger_popup() abort
nmap <buffer><Esc> q
endfunction
autocmd FileType gitmessengerpopup call <SID>setup_git_messenger_popup()
""""""""""""""""""""""""""""""""""""""""""""""" vimerl
set runtimepath+=$HOME/.vim/bundle/Vimerl
let g:erlang_skel_header = {"author": "Taras Shapovalov"}
let g:erlang_keywordprg = "erl -man"
""""""""""""""""""""""""""""""""""""""""""""""" Erlang file type
autocmd FileType erlang set shiftwidth=2
autocmd FileType erlang set ts=2
autocmd FileType erlang set softtabstop=2
autocmd FileType erlang set colorcolumn=120
autocmd Filetype erlang set omnifunc=erlang_complete#Complete
autocmd FileType erlang hi ColorColumn cterm=none ctermbg=7
autocmd Filetype erlang execute "set colorcolumn=" . join(range(121,355), ',')
""""""""""""""""""""""""""""""""""""""""""""""" Startify
let g:startify_enable_special = 0
let g:startify_session_dir = '~/.vim/sessions'
let g:startify_show_sessions = 1
let g:startify_show_files = 0
let g:startify_show_files_number = 0
let g:startify_bookmarks = []
let g:startify_skiplist = [
\ 'COMMIT_EDITMSG',
\ $VIMRUNTIME .'/doc',
\ 'bundle/.*/doc'
\ ]
let g:startify_skiplist_server = [ 'GVIM' ]
let g:startify_custom_indices = ['1','2','3','4','5','6','7','8','9']
let g:startify_enable_special = 0
function! SaveSessionWithName()
let sname = "default"
if strlen(v:this_session)
let sname = fnamemodify(substitute(v:this_session, ".vim$", "x.vim", ""), ":t")
endif
call startify#session_save(sname)
endfunction
"autocmd VimLeavePre * call SaveSessionWithName()
""""""""""""""""""""""""""""""""""""""""""""""" Signify
let g:signify_mapping_next_hunk = '<leader>gj'
let g:signify_mapping_prev_hunk = '<leader>gk'
let g:signify_mapping_toggle = '<leader>gt'
let g:signify_mapping_toggle_highlight = '<leader>gh'
let g:signify_skip_filetype = { 'vim': 1, 'c': 1 }
let g:signify_skip_filename = { '/home/taras/.vimrc': 1 }
let g:signify_vcs_list = ['git']
let g:signify_difftool = 'diff'
let g:signify_sign_overwrite = 1
let g:signify_update_on_bufenter = 1
let g:signify_line_highlight = 0
let g:signify_sign_weight = 'bold'
let g:signify_sign_add = ''
let g:signify_sign_delete = '-'
let g:signify_sign_change = '%'
let g:signify_sign_change_delete = '-'
let g:signify_sign_delete_first_line = '-'
let g:signify_sign_color_ctermfg_add = 2
let g:signify_sign_color_ctermfg_delete = 1
let g:signify_sign_color_ctermfg_change = 3
let g:signify_sign_color_ctermbg = 0
let g:signify_sign_color_group_add = 'MyAdd'
let g:signify_sign_color_group_delete = 'MyDelete'
let g:signify_sign_color_group_change = 'MyChange'
let g:signify_line_color_add = 'DiffAdd'
let g:signify_line_color_delete = 'DiffDelete'
let g:signify_line_color_change = 'DiffChange'
let g:signify_line_color_change_delete = 'DiffChange'
let g:signify_cursorhold_normal = 1
let g:signify_cursorhold_insert = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""" Statusline
let g:gitinfo = ''
function! GitInfo()
let branch = system("git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* //'")
if branch != ''
let g:gitinfo = ' ' . substitute(branch, '\n', '', 'g')
endif
endfun
au BufRead * call GitInfo()
function! FileSize()
let bytes = getfsize(expand("%:p"))
if bytes <= 0
return ""
endif
if bytes < 1024
return bytes . " B"
else
return (bytes / 1024) . " K"
endif
endfunction
function! LinterStatus() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? 'OK' : printf(
\ '%dW %dE',
\ all_non_errors,
\ all_errors
\)
endfunction
set statusline= " clear the statusline for when vimrc is reloaded
set statusline+=\ \ %<%F
set statusline+=%#VisualDelimeterWhite#
set statusline+=%*
"set statusline+=%{getfsize(expand('%:p'))>0?'┃\ ':''}
"set statusline+=%{FileSize()}
"set statusline+=%#VisualDelimeterWhite#\ ┃%*
set statusline+=%{gutentags#statusline('[',']')}
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'\['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
set statusline+=%1*
set statusline+=%h "help file flag
set statusline+=%r "read only flag
set statusline+=%m "modified flag
set statusline+=%w
set statusline+=%#warningmsg#
set statusline+=%*
set statusline+=\ %#error#
set statusline+=%{&paste?'paste':''}
set statusline+=%*
set statusline+=\ %#error#
set statusline+=%{LinterStatus()}
set statusline+=%*
set statusline+=%= "left/right separator ⤦
"set statusline+=%#VisualDelimeterWhite#\ ┃%*\
set statusline+=%{g:gitinfo}
set statusline+=%#VisualDelimeterWhite#\ ┃%*
set statusline+=\ line:\ %l/%L "cursor line/total lines
set statusline+=%#VisualDelimeterWhite#\ ┃%*
set statusline+=\ col:\ %c "cursor column
set statusline+=%#VisualDelimeterWhite#\ ┃%*
set statusline+=\ %P\ "percent through file
set statusline+=%#VisualDelimeterBlock#┃%*
set laststatus=2
" Recalculate the trailing whitespace warning when idle, and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
"""""""""""""""""""""""""""""""""""""""""""""""""""""""" tags, swp and backup
set tags=./.tags
set directory=~/.vim/spool/
set directory+=.
set backupdir=~/.vim/spool/
set backup
"""""""""""""""""""""""""""""""""""""""""""""""""""""""" GutenTags
let g:gutentags_cache_dir = expand($HOME . '/.cache/tags' )
if has('macunix')
let g:gutentags_ctags_executable = '/opt/homebrew/bin/ctags'
else
let g:gutentags_ctags_executable = '/usr/bin/ctags'
endif
let g:gutentags_resolve_symlinks=1
""""""""""""""""""""""""""""""""""""""""""""""""""""""" ALE LSP completion
set completeopt=menuone,noinsert,noselect
let g:ale_completion_enabled = 1
let g:ale_completion_autoimport = 0
set omnifunc=ale#completion#OmniFunc
augroup ale_cpp_lsp
autocmd!
autocmd FileType c,cpp nmap <buffer> gd <Plug>(ale_go_to_definition)
autocmd FileType c,cpp nmap <buffer> gr <Plug>(ale_find_references)
autocmd FileType c,cpp nmap <buffer> gy <Plug>(ale_go_to_type_definition)
autocmd FileType c,cpp nmap <buffer> K <Plug>(ale_hover)
autocmd FileType c,cpp nmap <buffer> <leader>rn <Plug>(ale_rename)
augroup END
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
""""""""""""""""""""""""""""""""""""""""" Cursor
function SetVisibleCursorLine()
hi CursorLine cterm=none ctermbg=7
endfunction
function SetInvisibleCursorLine()
hi CursorLine cterm=none ctermbg=15
endfunction
" Change a cursor shape (Gnome terminal only):
if has("autocmd")
au BufEnter __Tagbar__ silent call SetVisibleCursorLine()
au BufLeave __Tagbar__ silent call SetInvisibleCursorLine()
au BufEnter NERD_tree* silent call SetVisibleCursorLine()
au BufLeave NERD_tree* silent call SetInvisibleCursorLine()
au WinLeave * setlocal nocursorline
au WinEnter * setlocal cursorline
endif
""""""""""""""""""""""""""""""""""""""""" Tabs
function MyTabLine()
let tabline = '%#TabLine#'
let tabline .= repeat(' ', &numberwidth)
for i in range(tabpagenr('$'))
let buflist = tabpagebuflist(i + 1)
if i + 1 == tabpagenr()
let tabline .= '%#TabLineSel#'
for b in range(len(buflist))
if getbufvar(buflist[b], "&modified")
let tabline .= '%#TabLineModifiedSel#'
break
endif
endfor
else
let tabline .= '%#TabLine#'
for b in range(len(buflist))
if getbufvar(buflist[b], "&modified")
let tabline .= '%#TabLineModified#'
break
endif
endfor
endif
let tabline .= '%' . (i + 1) . 'T'
if i + 1 == tabpagenr()
let tabline .= ' %{MyTabLabel(' . (i + 1) . ')} '
let tabline .= '%#TabLineSel#'
else
let tabline .= ' %{MyTabLabel(' . (i + 1) . ')} ' . '%{MyTabNum(' . (i + 1) . ')}'
let tabline .= '%#TabLine#'
endif
if i + 1 != tabpagenr() && i+2 != tabpagenr()
let tabline .= '%#VisualDelimeter#'
let tabline .= '│'
endif
endfor
let tabline .= '%#TabLineFill#%T'
return tabline
endfunction
function MyTabNum(n)
if a:n == 0
return '₀'
elseif a:n == 1
return '₁'
elseif a:n == 2
return '₂'
elseif a:n == 3
return '₃'
elseif a:n == 4
return '₄'
elseif a:n == 5
return '₅'
elseif a:n == 6
return '₆'
elseif a:n == 7
return '₇'
elseif a:n == 8
return '₈'
elseif a:n == 9
return '₉'
elseif a:n == 10
return '₁₀'
elseif a:n == 11
return '₁₁'
elseif a:n == 12
return '₁₂'
elseif a:n == 13
return '₁₃'
elseif a:n == 14
return '₁₄'
elseif a:n == 15
return '₁₅'
elseif a:n == 16
return '₁₆'
elseif a:n == 17
return '₁₇'
elseif a:n == 18
return '₁₈'
elseif a:n == 19
return '₁₉'
elseif a:n == 20
return '₂₀'
elseif a:n == 21
return '₂₁'
elseif a:n == 22
return '₂₂'
elseif a:n == 23
return '₂₃'
elseif a:n == 24
return '₂₄'
elseif a:n == 25
return '₂₅'
elseif a:n == 26
return '₂₆'
elseif a:n == 27
return '₂₇'
elseif a:n == 28
return '₂₈'
elseif a:n == 29
return '₂₉'
elseif a:n == 30
return '₃₀'
elseif a:n == 31
return '₃₁'
elseif a:n == 32
return '₃₂'
else
return ''
endfunction
function MyTabLabel(n)
let label = ''
let buflist = tabpagebuflist(a:n)
let label = substitute(bufname(buflist[tabpagewinnr(a:n) - 1]), '.*/', '', '')
if label == ''
let label = '[No Name]'
endif
return label
endfunction
function MyGuiTabLabel()
return '%{MyTabLabel(' . tabpagenr() . ')}'
endfunction
set tabline=%!MyTabLine()
set guitablabel=%!MyGuiTabLabel()
""""""""""""""""""""""""""""""""""""""""" EasyMotion
let g:EasyMotion_leader_key = ','
""""""""""""""""""""""""""""""""""""""""" NERD tree
let g:NERDTreeMinimalUI = 1
let g:NERDTreeDirArrows = 1
let g:NERDTreeChDirMode=1
let g:NERDTreeQuitOnOpen=1
let g:NERDTreeShowHidden=1
let g:NERDTreeKeepTreeInNewTab=1
"""""""""""""""""""""""""""""""""""""""" TagBar
let g:tagbar_width = 60
let g:tagbar_compact = 1
let g:tagbar_iconchars = ['➱', '➢']
if has("autocmd")
"au FileType c,cpp nested :TagbarOpen
au FileType qf
\ if &buftype == "quickfix" |
\ setlocal statusline=%2*%-3.3n%0* |
\ setlocal statusline+=\ \[Compiler\ Messages\] |
\ setlocal statusline+=%=%2*\ %<%P |
\ endif
fun! <SID>FixMiniBufExplorerTitle()
if "-MiniBufExplorer-" == bufname("%")
setlocal statusline=%2*%-3.3n\ %0*\[MiniBufExplorer\]
elseif "__Tagbar__" == bufname("%")
setlocal statusline=%0*
setlocal statusline+=Tagbar
setlocal statusline+=%=\ %<%P
setlocal cursorline
endif
endfun
au BufWinEnter *
\ let oldwinnr=winnr() |
\ windo call <SID>FixMiniBufExplorerTitle() |
\ exec oldwinnr . " wincmd w"
endif
""""""""""""""""""""""""""""""""""""""""" Include keys map
source ~/.vim/keys.vim
" Use local vimrc if available
if filereadable(expand("./.vim/vimrc-custom"))
source ./.vim/vimrc-custom
endif
""""""""""""""""""""""""""""""""""""""""" Colors
syntax on
set termguicolors
set background=dark
colorscheme gruvbox