-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.vimrc
1620 lines (1479 loc) · 52.7 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
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
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" --- David Hegland's .vimrc file
" --- designed for vim 8.2
" --- 2020
" --- Initialization {{{1
" --- Envinroment varaiables information {{{2
" The following envinronment variables are used in this resource script
" $CSCOPE_DB : looks for a cscope database
" $TAGDIR : Defines the VIM tag directory to look for ctags
" $HOME : Used to define 'makeprg' for make tasks
" $USE_UNICODE : If set use unicode characters for some plugin definitions
" $USE_DEVPANEL : Use the devpanel by default
" $GIT_ROOT : Used for repo specific bookmark file
" $USER : Used to filter file names for title formatting
" $SRC_PATH_PREFIX : Used to filter file names for title formatting
" $AUTOSAVE : Set to 0|1 to Disable|Enable autosave for all files
" --- End Envonrment Variables
" --- Default /etc/vimrc contents {{{2
if v:lang =~# 'utf8$' || v:lang =~# 'UTF-8$'
set fileencodings=utf-8
endif
" --- Encoding Setup {{{2
if has('multi_byte')
if &termencoding ==# ''
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
" setglobal bomb
set fileencodings=ucs-bom,utf-8,latin1
scriptencoding utf-8
endif
" --- Setup textwidth for text files {{{2
if has('autocmd')
augroup redhat
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line('$') |
\ exe "normal! g'\"" |
\ endif
augroup END
endif
" --- Setup cscope {{{2
if has('cscope') && filereadable('/usr/bin/cscope')
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable('cscope.out')
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB !=# ''
cs add $CSCOPE_DB
endif
set csverb
endif
" --- Setup GUI parameters {{{2
if has('gui_running')
set guifont=Monospace\ 8
set mouse=a
set ttymouse=sgr
set termguicolors
endif
" --- setup xterm parameters {{{2
if &term =~# 'xterm'
if has('terminfo')
set t_Co=16
set t_Sf=[3%p1%dm
set t_Sb=[4%p1%dm
set t_vb=
set t_kh=[7%p1%dm
set t_@7=[4%p1%dm
else
set t_Co=16
set t_Sf=[3%dm
set t_Sb=[4%dm
set t_vb=
set t_kh=[7%dm
set t_@7=[4%dm
endif
" Handle terminal raw mode correctly
" FIXME: This should be temporary until a better fix is found
" This limits vim from recognizing <C-a> and <C-S-a> as separate
" key sequences. For more info see :help modifyOtherKeys
set t_TI=
set t_TE=
endif
" --- Syntax Highlighting Defintions {{{2
" --- For more colors, see 256 color pallet in ~/.vim/sample-256.colors
" Primary color highlighting moved into ~/.vim/colors/ and will use
" the colorscheme command to load a <colorscheme>.vim file.
syntax on " ---- turn on syntax highlighting
set background=dark
set hlsearch
colorscheme xterm
" --- Setup VIM defaults {{{2
" --- GNU Coding Standards
" setlocal cindent
" setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
" setlocal shiftwidth=2
" setlocal softtabstop=2
" setlocal textwidth=79
" setlocal fo-=ro fo+=cql
let $TMPDIR=$HOME . '/tmp'
set bs=indent,eol,start " ---- allow backspacing over everything in insert mode
" set viminfo=%,<800,'10,/50,:100,h,f0,n~/.vim/cache/.viminfo
" " | | | | | | | + viminfo file path
" " | | | | | | + file marks 0-9,A-Z 0=NOT stored
" " | | | | | + disable 'hlsearch' loading viminfo
" " | | | | + command-line history saved
" " | | | + search history saved
" " | | + files marks saved
" " | + lines saved each register (old name for <, vi6.2)
" " + save/restore buffer list
set viminfo='50,<1000,:100,n~/.viminfo
set history=50 " ---- keep 50 lines of command line history
set ruler " ---- show the cursor position all the time
set confirm " ---- Ask to continue when necessary
set noinsertmode " ---- don't don't out in insert mode
set backspace=2 " ---- allow us to backspace before an insert
set tabstop=4 " ---- set tabs to 4 spaces
set shiftwidth=4 " ---- set shift width to 4 spaces
set softtabstop=4 " ---- set tabs to 4 spaces when using softtabs
set noexpandtab " ---- use real tab characters
set ttymouse=sgr " ---- turn on the mouse in the xterm
set mouse=a " ---- enable mouse for all VIM options
set mousetime=1000 " ---- increase the mouse double click time to 1 second
set iskeyword=@,48-57,_,192-255,.,-
set showcmd " ---- show the command in the status line
set noerrorbells " ---- STOP BEEPING!
set showmatch " ---- show matching brackets
set ttyfast " ---- smoother output
set laststatus=2 " ---- Always show the status line
set showtabline=2 " ---- Always show tabline, even if only one file open
set updatetime=1000 " ---- Default updatetime=4000 to slow
set hidden " ---- Don't close buffers when switching
set splitbelow " ---- Open all new splits below current window
set cindent " ---- Enabled C indenting
set autoindent " ---- autoindenting is good
set smartindent " ---- Recognize syntax for formatting
set autoread " ---- Autoread file when change is detected
" set shortmess=aIt
set textwidth=0 " ---- Set default character width before autowrap
set foldlevel=10
set makeprg=$HOME/bin/cmk
set clipboard=unnamed,autoselect,exclude:cons\|linux
set number
if v:version >= 800
set modelineexpr
set modeline
endif
let tagfiles = ''
for tagfile in split(globpath($TAGDIR, '*'), '\n')
if tagfiles ==# ''
let tagfiles=tagfile
else
let tagfiles .= ',' . tagfile
endif
endfor
execute 'set tags=' . tagfiles
filetype plugin on
filetype indent on
augroup jsonfiles
autocmd FileType json set expandtab
autocmd FileType json set tabstop=4
autocmd FileType json set softtabstop=4
autocmd FileType json set shiftwidth=4
augroup END
" --- have java highlight our functions
"let java_highlight_functions=1
" --- have php3 highlight SQL, and keep in better sync.
let php3_sql_query = 1
let php3_minlines = 3000
let php3_baselib = 1
nnoremap ; :
nnoremap qq :q<CR>
" nnoremap wqq :wq<CR>
nnoremap W b
" .vimrc autocmds
augroup vimrc
"----- Let's try the following settings for C/C++
autocmd FileType c,cpp
\ setlocal formatoptions=croql
\ cindent
\ comments=sr:/*,mb:*,ex:*/,://
" --- We need real tabs for Makefiles.
autocmd FileType make setlocal noexpandtab
autocmd FileType make setlocal nosmarttab
" --- :help cinoptions-values
" NOTE: additional formatting options specified in .vim/after/ftplugin.vim
autocmd FileType c,cpp setlocal cinoptions=>4,t0,#0,:0,l1,p2,+2s,c0,(0,m1,)50,J1,#N
" | | | | | | | | | | | | + Recognize shell/perl script comment style
" | | | | | | | | | | | + Don't confuse object declarations with labels
" | | | | | | | | | | + Look for unclosed paranthesis 50 lines away
" | | | | | | | | | + Line up close paren on new line with open paren
" | | | | | | | | + Line up arguments under unclosed parens
" | | | | | | | + Align lines after comment opener
" | | | | | | + Indent continuation line by 2 shift-width
" | | | | | + indent parameter declarations after function but before open bracket
" | | | | + align with case label instead of statement after it
" | | | + case labels align with switch instead of shift-width in
" | | + preprocessor directives should be left aligned
" | + function return type left justified intead of shift-width
" + normal indentation after start of a block
autocmd FileType python,sh setlocal cinoptions=>4,t0,#s
autocmd BufWinEnter *.c,*.cpp,*.h,*.py match Whitespace /\s\+$/
autocmd InsertEnter *.c,*.cpp,*.h,*.py match Whitespace /\s\+\%#\@<!$/
autocmd InsertLeave *.c,*.cpp,*.h,*.py match Whitespace /\s\+$/
autocmd BufWinEnter *.py 2match Whitespace /^\t\+/
" autocmd BufWinEnter *.py set fileformat=unix
autocmd BufWinLeave * call clearmatches()
" When we attempt to do a :quit then instead do a :quitall
" autocmd QuitPre * qa
augroup END
" Hit // to search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
" }}}1
" --- PLUGIN Configurations {{{1
" ---- Only load plugins if VIM version 8 or higher {{{2
if v:version >= 800
" ---- Character Map {{{2
" Here are a couple unicode characters used for any formatted output
" E0A0 Branch 25E2 ◢
" E0A1 Line number 25E3 ◣
" E0A2 Padlock (read-only) 25E4 ◤
" E0A3 Column number 25E5 ◥
" E0B0 Right angle solid 21B2 ↲ Enter
" E0B1 Right angle line 26A0 ⚠ Warning
" E0B2 Left angle solid 26A1 ⚡Lightning
" E0B3 Left angle line 2714 ✔ Checkmark
" E0B8 2716 ✖ X-Mark
" E0B9 2718 ✘ X-Mark
" E0BA 271A ✚ Plus-Mark
" E0BB 2260 ≠ Not Equals
" E0BC 2264 ≤ Less-than or equal
" E0BD 2265 ≥ Greater-than or equal
" E0BE 00A9 © Copyright
" E0BF 00AE ® Rights-Reserved
" 25BC ▼ Arrow Down 23F3 ⏳Timer
" 25B2 ▲ Arrow Up 23F0 ⏰Alarm Clock
" 25B6 ▶ Arrow Right
" 25C0 ◀ Arrow Left
" NOTE: To enter unicode ctrl-v then u for 2 byte or U for 4 byte unicode
" Ex: <Ctrl-V>u2714 for \u2714 (checkmark)
" Flags to disable some plugins
let g:loaded_nerdtree_git_status = 1
"let g:loaded_tagbar = 1
"let g:loaded_devpanel = 1
if $USE_UNICODE !=# ''
let g:use_unicode = $USE_UNICODE
else
let g:use_unicode = 1
endif
let g:charmap_unicode = {
\ 'branch' : '',
\ 'line-num' : '',
\ 'lock' : '',
\ 'write' : '✎',
\ 'column-num' : '',
\ 'left-separator' : '',
\ 'right-separator' : '',
\ 'left-subseparator' : '',
\ 'right-subseparator' : '',
\ 'arrow-up' : '⯅',
\ 'arrow-down' : '⯆',
\ 'arrow-left' : '⯇',
\ 'arrow-right' : '⯈',
\ 'line-added' : '',
\ 'line-modified' : '',
\ 'line-modified-removed' : '',
\ 'line-removed-above' : '◤',
\ 'line-removed' : '◣',
\ 'modified' : '✚',
\ 'staged' : '✔',
\ 'untracked' : '✭',
\ 'renamed' : '➜',
\ 'unmerged' : '═',
\ 'deleted' : '✖',
\ 'dirty' : '✗',
\ 'ignored' : '!',
\ 'clean' : ' ',
\ 'unknown' : '?',
\ 'fold-fillchar' : '═',
\ 'fold-leftchar' : '╣',
\ 'fold-rightchar' : '╠'
\ }
let g:charmap_normal = {
\ 'branch' : '',
\ 'line-num' : '',
\ 'lock' : 'r',
\ 'write' : '+',
\ 'column-num' : '',
\ 'left-separator' : '',
\ 'right-separator' : '',
\ 'left-subseparator' : '|',
\ 'right-subseparator' : '|',
\ 'arrow-up' : '^',
\ 'arrow-down' : '-',
\ 'arrow-left' : '<',
\ 'arrow-right' : '>',
\ 'line-added' : '+',
\ 'line-modified' : '~',
\ 'line-modified-removed' : '~',
\ 'line-removed-above' : '-',
\ 'line-removed' : '-',
\ 'modified' : '+',
\ 'staged' : '*',
\ 'untracked' : 'u',
\ 'renamed' : 'r',
\ 'unmerged' : '=',
\ 'deleted' : '-',
\ 'dirty' : 'x',
\ 'ignored' : '!',
\ 'clean' : ' ',
\ 'unknown' : '?',
\ 'fold-fillchar' : '-',
\ 'fold-leftchar' : '|',
\ 'fold-rightchar' : '|'
\ }
let g:nummap_unicode = {
\ 1: '❶', 2: '❷', 3: '❸', 4: '❹', 5: '❺',
\ 6: '❻', 7: '❼', 8: '❽', 9: '❾', 10: '❿',
\ 11: '⓫', 12: '⓬', 13: '⓭', 14: '⓮', 15: '⓯',
\ 16: '⓰', 17: '⓱', 18: '⓲', 19: '⓳', 20: '⓴',
\ }
let g:nummap_normal = {
\ 1: '1.', 2: '2.', 3: '3.', 4: '4.', 5: '5.',
\ 6: '6.', 7: '7.', 8: '8.', 9: '9.', 10: '10.',
\ 11: '11.', 12: '12.', 13: '13.', 14: '14.', 15: '15.',
\ 16: '16.', 17: '17.', 18: '18.', 19: '19.', 20: '20.',
\ }
" ---- SetUnicode() {{{2
if g:use_unicode
let g:charmap = g:charmap_unicode
let g:nummap = g:nummap_unicode
else
let g:charmap = g:charmap_normal
let g:nummap = g:nummap_normal
endif
" ---- Lightline Plugin Configuration {{{2
let g:lightline = {
\ 'active': {
\ 'left': [['mode', 'paste', 'modified'], ['readonly', 'filename'], ['functionName']],
\ 'right': [['lineinfo'], ['percent'], ['fileformat', 'fileencoding', 'filetype']]
\ },
\ 'inactive': {
\ 'left': [['mode'], ['filename', 'modified']],
\ 'right': [['lineinfo'], ['percent']]
\ },
\ 'tabline': {
\ 'left': [ ['buffers'] ],
\ 'right': [ ['hunksummary'], ['branch'] ]
\ },
\ 'tab': {
\ 'active': ['filename', 'modified'],
\ 'inactive': ['filename', 'modified'],
\ },
\ 'component': {
\ 'lineinfo': g:charmap['line-num'] . '%3l:%-2v',
\ },
\ 'component_expand': {
\ 'buffers': 'lightline#bufferline#buffers'
\ },
\ 'component_type': {
\ 'buffers': 'tabsel'
\ },
\ 'component_function': {
\ 'branch': 'LightlineBranchInfo',
\ 'fileencoding': 'LightlineFileEncoding',
\ 'fileformat': 'LightlineFileFormat',
\ 'filename': 'LightlineFilename',
\ 'filetype': 'LightlineFileType',
\ 'hunksummary': 'LightlineGitgutterHunks',
\ 'mode' : 'LightlineMode',
\ 'modified' : 'LightlineModified',
\ 'readonly': 'LightlineReadonly',
\ 'functionName': 'LightlineFunctionName',
\ },
\ 'separator': {
\ 'left': g:charmap['left-separator'],
\ 'right': g:charmap['right-separator'],
\ },
\ 'subseparator': {
\ 'left': g:charmap['left-subseparator'],
\ 'right': g:charmap['right-subseparator']
\ }
\ }
let g:short_mode_map = {
\ 'n': 'NORM',
\ 'i' : 'INS',
\ 'R' : 'REPL',
\ 'v' : 'VIS',
\ 'V' : 'VISL',
\ "\<C-v>": 'VB',
\ 'c' : 'CMD',
\ 's' : 'S',
\ 'S' : 'SL',
\ "\<C-s>": 'SB',
\ 't': 'T',
\ }
" ---- Lightline#Bufferline Configuration {{{2
let g:lightline#bufferline#composed_number_map = g:nummap
let g:lightline#bufferline#show_number = 2
let g:lightline#bufferline#unicode_symbols = 1
let g:lightline#bufferline#filename_modifier = ':t'
let g:lightline#bufferline#unnamed = 'No Name'
let g:lightline#bufferline#number_separator = ' '
" ---- NERDTree Configuration {{{2
let NERDTreeMouseMode = 2 " --- Open/Close dirs on single mouse click
let NERDTreeNaturalSort = 1 " --- Sort order of files more natural
let NERDTreeShowHidden = 1 " --- Show hidden files/folders by default
let NERDTreeIgnore = [
\ '\.o$', '\.d$', '\~$', '\.pyc$',
\ '\.swp$', '\.swo$', '\.swn$',
\ '\.swm$', '\.swl$', '\.swk$', ]
let g:NERDTreeDirArrowExpandable = g:charmap['arrow-right']
let g:NERDTreeDirArrowCollapsible = g:charmap['arrow-down']
if $GIT_ROOT !=# ''
let BookmarksFile = $GIT_ROOT . '/.rc/NERDTreeBookmarks'
if filereadable(BookmarksFile)
let NERDTreeBookmarksFile = BookmarksFile
let NERDTreeShowBookmarks = 1 " --- Show bookmarks on startup
elseif filereadable('~/.NERDTreeBookmarks')
let NERDTreeShowBookmarks = 1 " --- Show bookmarks on startup
endif
endif
" ---- NERDTree Git Configuration {{{2
let g:NERDTreeGitStatusShowClean = 0
let g:NERDTreeGitStatusConcealBrackets = 1
let g:NERDTreeStatusUpdateOnCursorHold = 0
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' : g:charmap['modified'],
\ 'Staged' : g:charmap['staged'],
\ 'Untracked' : g:charmap['untracked'],
\ 'Renamed' : g:charmap['renamed'],
\ 'Unmerged' : g:charmap['unmerged'],
\ 'Deleted' : g:charmap['deleted'],
\ 'Dirty' : g:charmap['dirty'],
\ 'Ignored' : g:charmap['ignored'],
\ 'Clean' : g:charmap['clean'],
\ 'Unknown' : g:charmap['unknown']
\ }
" ---- NERDCommenter Configuration {{{2
let g:NERDCustomDelimiters = { 'c': { 'left': '/***','right': '***/' } }
let g:NERDSpaceDelims = 1 " --- add space after delimiter
let g:NERDCompactSexyComs = 1 " --- use compact syntax for multi-line
let g:NERDDefaultAlign = 'left' " --- align line-wise comments to left
let g:NERDAltDelims_java = 1 " --- set language to use alternate delims
let g:NERDCommentEmptyLines = 1 " --- allow empty lines to be commented
let g:NERDTrimTrailingWhitespace = 1 " --- trim whitespace when uncommenting
let g:NERDToggleCheckAllLines = 1 " --- check all lines for comment or not
let g:NERDCommentWholeLinesInVMode = 1 " --- Comment entire line in visual
let g:NERDCreateDefaultMappings = 0 " --- Don't use default mappings
" ---- GitGutter Configuration {{{2
let g:gitgutter_highlight_lines = 1
let g:gitgutter_preview_win_location = 'rightbelow'
let g:gitgutter_sign_added = g:charmap['line-added']
let g:gitgutter_sign_modified = g:charmap['line-modified']
let g:gitgutter_sign_removed = g:charmap['line-removed']
let g:gitgutter_sign_removed_first_line = g:charmap['line-removed-above']
let g:gitgutter_sign_remove_above_and_below = g:charmap['line-modified-removed']
let g:gitgutter_sign_modified_removed = g:charmap['line-modified-removed']
" ---- Tagbar Configuration {{{2
let g:tagbar_no_status_line = 1
let g:tagbar_iconchars = [ g:charmap['arrow-right'], g:charmap['arrow-down'] ]
let g:tagbar_file_size_limit = 1000000
let g:tagbar_jump_offset = winheight(0) / 4
let g:tagbar_show_data_type = 1
let g:tagbar_show_tag_count = 1
let g:tagbar_case_insensitive = 1
let g:tagbar_highlight_method = 'scoped-stl'
let g:tagbar_autoclose = 0
let g:tagbar_autoclose_netrw = 1
" let g:no_status_line = 1
" let g:tagbar_autofocus = 0
" let g:tagbar_autopreview = 0
" let g:tagbar_autoshowtag = 1
" let g:tagbar_compact = 1
" let g:tagbar_indent = 1
" let g:tagbar_jump_offset = winheight(0)/4
" let g:tagbar_left = 1
" let g:tagbar_silent = 1
" let g:tagbar_sort = 0
" let g:tagbar_width = max([40, winwidth(0) / 6])
" let g:tagbar_wrap = 1
" let g:tagbar_long_help = 1
" let g:tagbar_compact = 1
" let g:tagbar_autoshowtag = 0
" Override 'c' type that doesn't include unions to avoid issues with
" unions inside of functions messing up with display and scoping issues.
let g:tagbar_type_c = {
\ 'ctagstype' : 'c',
\ 'regex' : [
\ '/(TODO).*//T,ToDo,ToDo Messages/{_anonymous=todo_}',
\ '/(FIXME).*//Q,FixMe,FixMe Messages/{_anonymous=fixme_}',
\ ],
\ 'kinds' : [
\ 'h:header files:1:0',
\ 'd:macros:1:0',
\ 'p:prototypes:1:0',
\ 'g:enums:0:1',
\ 'e:enumerators:0:0',
\ 't:typedefs:0:0',
\ 's:structs:0:1',
\ 'm:members:1:0',
\ 'v:variables:0:0',
\ 'f:functions:0:1:{:}',
\ 'T:todo:0:0',
\ 'Q:fixme:0:0',
\ ],
\ 'sro' : '::',
\ 'kind2scope' : {
\ 'g' : 'enum',
\ 's' : 'struct',
\ },
\ 'scope2kind' : {
\ 'enum' : 'g',
\ 'struct' : 's',
\ }
\ }
let g:tagbar_type_cheatsheet = {
\ 'ctagstype' : 'cheatsheet',
\ 'kinds' : [
\ 'h:header:0:1',
\ 's:section:0:1',
\ 'u:unused:0:1',
\ ],
\ 'sro' : '::',
\ 'kind2scope' : {
\ 'h' : 'header',
\ },
\ 'scope2kind' : {
\ 'header' : 'h',
\ },
\ }
let g:tagbar_type_javascript = {
\ 'ctagstype' : 'javascript',
\ 'regex' : [
\ '/async[ \t]+(.*)[ \t]*\(.*\)/\1/f/func/function/',
\ ],
\ 'kinds' : [
\ 'v:global variables:0:0',
\ 'C:constants:0:0',
\ 'c:classes:0:1',
\ 'g:generators:0:0',
\ 'p:properties:0:0',
\ 'm:methods:0:1',
\ 'f:functions:0:0',
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 'c' : 'class',
\ 'f' : 'function',
\ 'm' : 'method',
\ 'p' : 'property',
\ },
\ 'scope2kind' : {
\ 'class' : 'c',
\ 'function' : 'f',
\ },
\ }
" let g:tagbar_type_perl = {
" \ 'kinds' : [
" \ 'c:constants:0:0',
" \ 'f:formats:0:0',
" \ 'l:labels:0:1',
" \ 'p:packages:1:0',
" \ 's:subroutines:0:1',
" \ 'd:subroutineDeclaration:0:0',
" \ 'M:modules:0:0',
" \ ],
" \ 'deffile' : '~/projects/tagbar-test-files/perl.ctags',
" \ }
" let g:tagbar_type_asciidoc2 = {
" \ 'ctagstype': 'asciidoc2',
" \ 'deffile': '/home/dh404494/.vim/vim-asciidoc/ctags/asciidoc.cnf',
" \ 'sort': 0,
" \ 'kinds': [
" \ 's:Table of Contents',
" \ 'i:Included Files',
" \ 'I:Images',
" \ 'v:Videos',
" \ 'a:Set Attributes',
" \ 'A:Unset Attributes'
" \ ]
" \}
" Tagbar Debug Options:
" Note: when using the logfile, don't VI the file or it will overwrite what is there
" let g:tagbar_ctags_bin = '/usr/bin/ctags' " XXX: To test with exhuberant ctags
" let g:tagbar_logfile = $HOME . '/tagbar.log'
" let g:tagbar_no_autocmds = 1
" let g:tagbar_ignore_anonymous = 1
" let g:tagbar_width = max([25, winwidth(0) / 5])
" let g:tagbar_wrap = 2
" ---- Syntastic Configuration {{{2
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" ---- AnyFold Configuration {{{2
let g:anyfold_fold_comments=1
let g:anyfold_fold_display=1
" ---- Flake8 Configuration {{{2
let g:flake8_show_quickfix = 1
let g:flake8_show_in_gutter = 1
let g:flake8_show_in_file = 0
let g:flake8_quickfix_height = 10
let g:flake8_always_visible = 1
let g:flake8_auto_update = 0
" ---- Auto-pairs Configuration {{{2
let g:AutoPairsShortcutToggle = ''
let g:AutoPairsShortcutFastWrap = '<Leader>)'
" ---- UndoTree Configuration {{{2
let g:undotree_WindowLayout = 3
let g:undotree_SplitWidth = 30
let g:undotree_DiffpanelHeight = 20
let g:undotree_HighlightChangedText = 0
let g:undotree_HighlightChangedWithSign = 0
let g:undotree_DiffAutoOpen = 0
" ---- AutoSave Configuration {{{2
let g:auto_save = $AUTOSAVE
" ---- Minimap Configuration {{{2
let g:minimap_block_filetypes = ['fugitive', 'nerdtree', 'tagbar', 'qf', 'preview', 'diff']
" ---- DevPanel Configuration {{{2
if $USE_DEVPANEL !=# ''
let g:use_devpanel = $USE_DEVPANEL
else
let g:use_devpanel = 1
endif
if g:use_devpanel
let g:devpanel_auto_open_files = '*.c,*.cpp,*.h,*.py,*.vim,Makefile,*.make,.vimrc,.bashrc,*.sh'
else
let g:devpanel_auto_open_files = 'no_files'
endif
let g:devpanel_panel_min = 40
let g:devpanel_panel_max = 45
let g:devpanel_open_min_width = 120
let g:devpanel_use_nerdtree = 1
let g:devpanel_use_tagbar = 1
let g:devpanel_use_minimap = 0
let g:devpanel_use_flake8 = 1
" ---- Generic definitions used by functions for plugins {{{2
let g:ignored_filetypes = '\v(nerdtree|tagbar|undotree|qf)'
let g:ignored_files = '\v(hunk-preview)'
" ---- Load Plugins {{{2
packloadall
" --- https://github.com/majutsushi/tagbar
let g:have_tagbar = &runtimepath =~# 'tagbar' ? 1 : 0
" --- https://github.com/preservim/nerdtree
let g:have_nerdtree = &runtimepath =~# 'nerdtree' ? 1 : 0
" --- https://github.com/tpope/vim-fugitive
let g:have_fugitive = &runtimepath =~# 'fugitive' ? 1 : 0
" --- https://github.com/airblade/vim-gitgutter
let g:have_gitgutter = &runtimepath =~# 'gitgutter' ? 1 : 0
" --- https://github.com/arecarn/vim-fold-cycle
let g:have_foldcycle = &runtimepath =~# 'foldcycle' ? 1 : 0
" --- https://github.com/Chiel92/vim-autoformat
let g:have_autoformat = &runtimepath =~# 'autoformat' ? 1 : 0
" --- https://github.com/pseewald/vim-anyfold
let g:have_anyfold = &runtimepath =~# 'anyfold' ? 1 : 0
" --- https://github.com/itchyny/lightline.vim
let g:have_lightline = &runtimepath =~# 'lightline' ? 1 : 0
" --- https://github.com/nvie/vim-flake8
let g:have_flake8 = &runtimepath =~# 'flake8' ? 1 : 0
" --- https://github.com/preservim/nerdcommenter.git
let g:have_nerdcommenter = &runtimepath =~# 'nerdcommenter' ? 1 : 0
" --- https://github.com/raven42/devpanel-vim.git
let g:have_devpanel = &runtimepath =~# 'devpanel' ? 1 : 0
" --- https://github.com/dkprice/vim-easygrep.git
let g:have_easygrep = &runtimepath =~# 'easygrep' ? 1 : 0
" --- https://github.com/mbbill/undotree.git
let g:have_undotree = &runtimepath =~# 'undotree' ? 1 : 0
" --- https://github.com/vim-scripts/searchfold.vim.git
let g:have_searchfold = &runtimepath =~# 'searchfold' ? 1 : 0
" --- https://github.com/wfxr/minimap.vim
let g:have_minimap = &runtimepath =~# 'minimap' ? 1 : 0
if g:have_tagbar && exists('g:tagbar_logfile')
execute 'TagbarDebug ' . g:tagbar_logfile
endif
" ---- LightlineFileEncoding() {{{2
function! LightlineFileEncoding()
return &filetype =~# g:ignored_filetypes ? '' :
\ &fenc !=# '' ? &fenc : &enc
endfunction
" ---- LightlineFileFormat() {{{2
function! LightlineFileFormat()
return winwidth(0) < 90 ? '' :
\ &filetype =~# g:ignored_filetypes ? '' :
\ &fileformat
endfunction
" ---- LightlineFilename() {{{2
function! LightlineFilename()
return &filetype =~# g:ignored_filetypes ? '' :
\ expand('%:t') !=# '' ? expand('%:t') : '[No Name]'
endfunction
" ---- LightlineFileType() {{{2
function! LightlineFileType()
return &filetype !~# g:ignored_filetypes ? &filetype : ''
endfunction
" ---- LightlineGitgutterHunks() {{{2
function! LightlineGitgutterHunks()
let [a, m, r] = GitGutterGetHunkSummary()
return printf('+%d ~%d -%d', a, m, r)
endfunction
" ---- LightlineMode() {{{2
function! LightlineMode()
return &filetype ==# 'nerdtree' ? 'File Explorer' :
\ &filetype ==# 'tagbar' ? 'Tags' :
\ &filetype ==# 'undotree' ? 'History' :
\ &filetype ==# 'diff' ? 'Diffs' :
\ exists('w:flake8_window') ? 'Python Errors/Warnings' :
\ winwidth(0) < 90 ? get(g:short_mode_map, mode(), '') :
\ lightline#mode()
endfunction
" ---- LightlineModified() {{{2
function! LightlineModified()
return !&modified ? '' :
\ &filetype =~# g:ignored_filetypes ? '' :
\ g:charmap['write']
endfunction
" ---- LightlineReadonly() {{{2
function! LightlineReadonly()
return !&readonly ? '' :
\ &filetype =~# g:ignored_filetypes ? '' :
\ g:charmap['lock']
endfunction
" ---- LightlineBranchInfo() {{{2
function! LightlineBranchInfo()
if !g:have_fugitive || &filetype =~# g:ignored_filetypes
return ''
endif
let branch = FugitiveHead()
return branch !=# '' ? ' '. g:charmap['branch'] . branch : ''
endfunction
" ---- LightlineFunctionName() {{{2
function! LightlineFunctionName()
if !g:have_tagbar || &filetype =~# g:ignored_filetypes
return ''
endif
return tagbar#currenttag('%s', '', 'f', 'nearest-stl')
endfunction
let g:lineline_colorscheme = 'powerline'
function! LightlineColorScheme(...) abort
if !exists('g:loaded_lightline')
return
endif
let color_name = a:0 > 0 ? a:1 : g:lightline_colorscheme
try
if color_name =~# 'powerline\|wombat\|solarized\|landscape\|jellybeans\|seoul256\|Tomorrow'
let g:lightline.colorscheme =
\ substitute(substitute(color_name, '-', '_', 'g'), '256.*', '', '')
call lightline#init()
call lightline#colorscheme()
call lightline#update()
endif
catch
endtry
endfunction
function! s:set_lightline_colorscheme(name) abort
let g:lightline.colorscheme = a:name
call lightline#init()
call lightline#colorscheme()
call lightline#update()
endfunction
function! s:lightline_colorschemes(...) abort
return join(map(
\ globpath(&rtp, 'autoload/lightline/colorscheme/*.vim',1,1),
\ 'fnamemodify(v:val,":t:r")'),
\ '\n')
endfunction
command! -nargs=1 -complete=custom,s:lightline_colorschemes LightlineColorscheme
\ call s:set_lightline_colorscheme(<q-args>)
" ---- LastOpenFileNmae() {{{2
function! LastOpenFileName() abort
if !exists('t:lastfilename')
let t:lastfilename = fnamemodify(bufname('%'), ':p')
endif
if &filetype !~# g:ignored_filetypes
let bufname = fnamemodify(bufname('%'), ':p')
if bufname ==# ''
let bufname = 'No Name'
endif
let t:lastfilename = bufname
endif
return t:lastfilename
endfunction
" ---- Flake8Update() {{{2
function! Flake8Update() abort
" The flake8 when calling the flake8 plugin via an autocmd, it appears
" to be changing the window focus so the lightline and tagbar info
" doesn't match what it should. So record the winnr() and switch to it
" again when we are done, then call some update routines and redraw
let l:win = winnr()
call flake8#Flake8()
execute l:win 'wincmd w'
call lightline#update()
call tagbar#Update()
redraw!
endfunction
" ---- UpdateTitle() {{{2
function! UpdateTitle()
let &titlestring = 'VIM - ' . expand('%:t')
let branch_info = ''
if g:have_fugitive
let branch = FugitiveHead()
if branch !=# ''
let branch_info = ' '. g:charmap['branch'] . ' (' . branch . ') '
endif
endif
let file_info = LastOpenFileName()
let file_info = substitute(file_info, '\/work\/' . $USER, '', '')
let file_info = substitute(file_info, '\/home\/' . $USER, '~', '')
let file_info = substitute(file_info, $SRC_PATH_PREFIX, '..', '')
let &titlestring = 'VIM ' . branch_info . file_info
set title
endfunction
" ---- FilterBuffer() {{{2
function! FilterBuffer(i)
return bufexists(a:i) && buflisted(a:i) && !(getbufvar(a:i, '&filetype') =~# g:ignored_filetypes) && !(bufname('%') =~# g:ignored_files)
endfunction
" ---- FilteredBuffers() {{{2
function! FilteredBuffers()
let l:buffers = filter(range(1, bufnr('$')), 'FilterBuffer(v:val)')
return l:buffers
endfunction
" ---- BufActivateNth() {{{2
function! BufActivateNth(bufnr) abort
if winnr('#') > 1
" Find the main window... don't switch to another buffer while
" in a devpanel window
while &readonly && &filetype =~# g:ignored_filetypes && bufname('%') =~# g:ignored_files
execute 'wincmd w'
endwhile
endif
let l:buffers = FilteredBuffers()
if a:bufnr < len(l:buffers)
execute 'buffer ' . l:buffers[a:bufnr]
endif
endfunction
" ---- BufCloseNth() {{{2
function! BufCloseNth(bufnr) abort
let l:buffers = FilteredBuffers()
if a:bufnr < len(l:buffers)
execute 'bdelete ' . l:buffers[a:bufnr]
endif
endfunction
" ---- BufClose() {{{2
function! BufClose() abort
" If only one buffer open and listed (ignoring hidden buffers) don't close
let l:buffers = FilteredBuffers()
if len(l:buffers) <= 1
echo '...No more buffers to close'
return
endif
let bufnr = bufnr('%')
bprevious
execute 'bdelete ' . bufnr
endfunction
" ---- ToggleGitHunkPreview() {{{2
function! ToggleGitHunkPreview() abort
for winnr in range(1, winnr('#'))
if getwinvar(winnr, '&filetype') ==# 'diff'
execute winnr . 'wincmd w'
quit
return
endif
endfor
GitGutterPreviewHunk
endfunction
" ---- ToggleGitQuickFix() {{{2
function! ToggleGitQuickFix() abort
if exists('g:quickfix_window')
unlet g:quickfix_window
cclose
return
endif
GitGutterQuickFix
copen
let g:quickfix_window = 1
endfunction
" ---- CheckForDotFiles() {{{2
function! CheckForDotFiles() abort
let file = expand('%:t')
let path = expand('%:p:h')
let githome_repo = [
\ $HOME,
\ $HOME . '/sbin',
\ $HOME . '/doc',
\ ]
if index(githome_repo, path) !=# -1
" let g:gitgutter_git_args = '--git-dir=' . $HOME . '/.cfg/'
let g:gitgutter_git_args = '--git-dir=' . $HOME . '/.cfg/ --work-tree=' . $HOME
let g:gitgutter_diff_args = '--no-index'
else
let g:gitgutter_git_args = ''
let g:gitgutter_diff_args = ''
endif
endfunction
" ---- Key Mappings for all plugins {{{2
nmap <Leader>cc <plug>NERDCommenterToggle
vmap <Leader>cc <plug>NERDCommenterToggle
nmap <Leader>cm <plug>NERDCommenterMinimal
vmap <Leader>cm <plug>NERDCommenterMinimal
nmap <Leader>ci <plug>NERDCommenterInvert
vmap <Leader>ci <plug>NERDCommenterInvert
nmap <Leader>cy <plug>NERDCommenterYank
vmap <Leader>cy <plug>NERDCommenterYank