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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
|
" vim: noai:ts=2:sw=2:sts=2 iskeyword+=\:,\!,\<,\>,\-,\& number
"=======================================================================================================================
" GENERAL:
"=======================================================================================================================
set exrc | " enable exrc, a specific .exrc per project, which can contain usual .vimrc commands
set textwidth=0 | " better done with modeline or local exrc and not here
set ts=4 sts=4 sw=4 expandtab | " better done with a modeline or local exrc
set virtualedit=all | " virtual edit should be default behaviour, because I don't see any reason against
set nonumber norelativenumber | " do not show numbers by default, because that causes a performance loss, instead activate them on a file type basis
set ignorecase smartcase hlsearch | " search with ignore case by default, but use case sensitive search when one capital char is contained and highlight while typing (even though its slower)
set cindent cinoptions+=(0 | " indent at parentheses
set path+=** | " allow recursive searches for files
let &path = &path.",/usr/lib/modules/".substitute(system('uname -r'), "\n", "", "")."/build/include"
"=======================================================================================================================
" SHELL
"=======================================================================================================================
if filereadable("/bin/bash")
set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here
elseif filereadable("/usr/local/bin/bash")
set shell=/usr/local/bin/bash
endif
"=======================================================================================================================
" Persistent undo
"=======================================================================================================================
if has('persistent_undo')
if isdirectory('/dev/shm')
set undodir=/dev/shm/ | " save undo file in memory. That is volatile, but fast and we have GIT for longer lasting undoes
set directory=/dev/shm/ | " swap file directory to RAM
set swapfile
elseif isdirectory('/tmp/')
set undodir=/tmp/
endif
set undofile | " preserve undo history when closing and reopening buffers (see :help undo-persistence)
endif
"=======================================================================================================================
" multi byte
"=======================================================================================================================
if has("multi_byte")
scriptencoding utf-8 | " tell vim that we are using UTF-8 here
set encoding=utf-8 | " we need default UTF-8 encoding to use cool chars as line break and so on (see below)
let &termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those
set fillchars+=fold:\ | "
set fillchars+=vert:\║ | " cool vertical split char
set fillchars+=diff:\ | " a white space gets used here
set listchars= | " initialize empty listchars
set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars)
set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars)
set listchars+=tab:▏\ | "
set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars)
" set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars)
" set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars)
set showbreak+=› | " symbol used in the beginning of a wrapped line
" automatically enter list mode when going in insert mode (makes above syntax command temporarily ineffective)
set nolist
autocmd InsertEnter * set list
autocmd InsertLeave * set nolist
" set fillchars+=stlnc:\― | "
end
"=======================================================================================================================
" SPELL_CHECKING
"=======================================================================================================================
let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell'
" add local user default spell file as primary source for words
let &spellfile=fnamemodify($MYVIMRC, ":p:h")."/spell/spellfile-user.UTF-8.add"
set nospell | " disable spell checker by default
set spelllang=en,de | " languages for the spell checker
set spellsuggest=10 | " how many words will z= suggest?
set thesaurus+=~/.vim/thesaurus/php.txt
"=======================================================================================================================
" cscope
"=======================================================================================================================
" http://vim.wikia.com/wiki/Cscope
if has('cscope') " compiled with cscope support?
set cscopetag " CTRL-] uses cscope first, then ctags
set cscopeverbose
if has('quickfix')
set cscopequickfix=s+,c+,d+,i+,t+,e+
endif
if has('menu')
1001menu &Cscope.find.c\ symbol
\<tab>s
\ :cscope find s <cword><:cR>
1001menu &Cscope.find.definition
\<tab>g
\ :cscope find g <cword><:cR>
1001menu &Cscope.find.functions\ called\ by\ this
\<tab>d
\ :cscope find d <cword><:cR>
1001menu &Cscope.find.functions\ calling\ this
\<tab>c
\ :cscope find c <cword><:cR>
1001menu &Cscope.find.text\ string
\<tab>t
\ :cscope find t <cword><:cR>
1001menu &Cscope.find.egrep\ pattern
\<tab>e
\ :cscope find e <cword><:cR>
1001menu &Cscope.find.this\ file
\<tab>f
\ :cscope find f <cword><:cR>
1001menu &Cscope.find.files\ including\ this\ file
\<tab>i
\ :cscope find i <cword><:cR>
1001menu &Cscope.find.places\ where\ this\ symbol\ is\ assigned\ a\ value
\<tab>a
\ :cscope find a <cword><:cR>
1001menu &Cscope.-Sep1-
\ :
1001menu &Cscope.create\ and\ add\ database
\ :cscope kill -1<CR>:execute '!find -type f -regex ".*\.\(c\\|h\\|cpp\\|cxx\\|hh\\|hpp\\|hxx\)$" <bar> cscope -i- -b -q -v'<CR>:cscope add .<CR>
1001menu &Cscope.-Sep2-
\ :
1001menu &Cscope.add\ \.
\ :cscope add .<CR>
1001menu &Cscope.show
\ :cscope show<CR>
1001menu &Cscope.reset
\ :cscope reset<CR>
endif
endif
" ======================================================================================================================
" GUI_VERSION
" ======================================================================================================================
if has("gui_running")
set guicursor=a:block-blinkon100
set browsedir=buffer
set toolbar+=text
set guiheadroom=0
set guioptions+=eig
set guioptions-=T | " toolbar
set guioptions+=c | " use console dialogues instead of popups
set guioptions+=a | " auto select: copy&paste using middle click
set guioptions+=m | " remove menu
set guioptions-=e | " do not display tabs
set guioptions-=L | " do not show left scrollbar
set guioptions-=r | " do not show right scrollbar
set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped)
" set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END
" set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text
" its possible to define alternative fonts (order matters)
set guifont=Hasklug\ Nerd\ Font\ Mono\ Semi-Bold\ 10
set guifont+=Hasklig\ Semi-Bold\ 10
set guifont+=Bitstream\ Vera\ Sans\ Mono\ 10
set guifont+=Monospace\ 10
set guifont+=FuraMono\ Nerd\ Font\ Mono\ Medium\ 11
set guifont+=Source\ Code\ Pro\ for\ Powerline\ SemiBold\ 10
set guifont+=LiterationMono\ Nerd\ Font\ Mono\ 10
set guifont+=RobotoMono\ Nerd\ Font\ Medium\ 10
set guifont+=Source\ Code\ Pro\ Semi-Bold\ 10
set guifont+=Dejavu\ Sans\ Mono\ for\ Powerline\ Semibold
set guifont+=Droid\ Sans\ Mono\ for\ Powerline\ 10
set guifont+=Meslo\ LG\ M\ for\ Powerline\ 10
" like in the terminal: use Ctrl-shift-v for paste in vim's command editor
cnoremap <c-s-v> <c-r>*
endif
" ======================================================================================================================
" SETTINGS:
" ======================================================================================================================
set breakindent | " Every wrapped line will continue visually indented
set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well)
set concealcursor=nc | " limits the display of concealed text to normal and command mode
set conceallevel=2 | " replace escaped chars by their UTF-8 representation (useful for LaTeX)
set confirm | " asks 'do you want to save?'
set cpoptions+=P | " makes :w filename set the current buffer to filename
set hidden | " allows switching buffers even if the current buffer contains changes (displays +)
set linebreak | " wrap long lines at char 'breakat', not inside words
set mousemodel=popup | " only in gvim: right click opens a pop-up-menu
set mouse=n | " allow mouse in normal mode only, so one can use the terminals c&p feature in insert mode
set noautochdir | " When on, Vim will change the current working directory
set nostartofline | " when scrolling: do not move the cursor to column 1
set nowrap | " but do not (by default) wrap long lines around
set nrformats+=alpha | " allows CTRL-A & CTRL-X to increment and decrement letters, not just numbers
set incsearch | " highlight pattern while entering it (performance wise this isn't that good)
if has('nvim') " Neovim?
set inccommand=nosplit | " preview substitute and such things in real time
endif
set pumheight=8 | " Determines the maximum number of items to show in the pop-up menu for
set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge
set scrolloff=0 | " keeps cursor centered
set shiftround | " indent/un-indent snaps to multiple of shiftwidths
set writedelay=0
" display and performance
set lazyredraw | " disables redraw during macro execution (improves performance)
set cmdheight=2 | " sets the command line's height
set signcolumn=auto | " auto=auto hide, yes=always, no=never show the column with error indicators
set nocursorcolumn | " turn visual cursor column off (improves performance)
set updatetime=80 | " updates the screen more often
set redrawtime=1500 | " Timeout in milliseconds for redrawing the screen (switches syntax off when ssh too slow) / CTRL+L to retry
set notimeout | " improves performance but is known to cause problems on slow terminals
set ttimeout ttimeoutlen=150 | " set Esc key timeout in ms-
set showcmd | " essential: show keys of combined commands in the lower right corner (BUT SLOW, makes cursor flickering)
set showtabline=2 | " 0: never, 1: only if there are at least two tabs, 2:always
set shortmess+=I | " don't give the intro message when starting Vim |:intro|.
set wildmenu | " use a menu in the command line
set wildmode=longest:full | " do not preselect any entry and show all possible
" code completion
" set dictionary=/usr/share/dict/cracklib-small
" set complete+=k " make default completer <C-N> respect the dictionary
set complete-=u " scan current and included files
set complete+=i " scan current and included files
set complete+=d " scan current and included files for defined name or macro
set complete+=d | " scan current and included files for defined name or macro
set complete+=i | " scan current and included files for completions
set tagcase=match | " tagcase match, because we mostly use ^] to jump around and that variant respects the upper/lower case [followscs, followic, match, ignore]
set tags+=../tags
" code folding...
set nofoldenable | " disable folding, because we have zi to toggle foldenable :)
set foldclose=all | " automatically fold, when the cursor leaves the folded area
set foldcolumn=1 | " I think I don't need this second indicator
set numberwidth=5
" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow
set foldnestmax=1 | " top level folding only
set foldopen=block,hor,search | " when do we unfold?
" set foldtext=Foldtext() | "
" set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g')
" set foldtext='⊞\ '.substitute(getline(v:foldstart),'^[\ '.printf(&cms,'').']*','','').'↵'.getline(v:foldstart+1).'↵'.getline(v:foldstart+2)
set foldtext='⊞\ '.substitute(join(getline(v:foldstart,v:foldend),'↵'),'\[*\/\]','','g')
" vim window behaviour
set splitbelow | " open new windows below the current one (i find that more intuitive)
set winminwidth=0 | " (and all other windows, so TODO: watch out)
set winwidth=30 | " keep NERDTreeWindow at least this size
" vim session handling and restore behaviour
set viminfo+=% | " restore buffer list
set sessionoptions=
set sessionoptions+=buffers
set sessionoptions+=curdir
set sessionoptions+=folds
set sessionoptions+=resize
set sessionoptions+=slash
set sessionoptions+=tabpages
set sessionoptions+=unix
set sessionoptions+=winpos
set sessionoptions+=winsize
" set nocindent smartindent | " use smart indent rather then cindent
set noautoindent
set nosmartindent
set noshiftround | " indent/un-indent sna=ps to multiple of shiftwidths
set noequalalways | " do not evenly size windows when opening new or closing old
set nocursorline | " turn visual cursor line off (improves performance)
"=======================================================================================================================
" Vim 8 has a terminal command...
if has('terminal')
" use default ESC key to leave insert mode in the internal terminal emulator
tnoremap <Esc> <C-W>N
" make terminal windows hidden by default (copied from :help terminal)
autocmd BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
endif
" NEOVIM_incompatible:
"
if has('nvim') " Neovim?
autocmd TermOpen term://* set nobuflisted
" use default ESC key to leave insert mode in the internal terminal emulator
tnoremap <Esc> <C-\><C-n>
" set shada+=n~/.vim/shada | " shada file to use
"
menu &UI.&Open\ in\ Serversession
\ :execute ':!nvr --servername /tmp/nvimsocket --remote % +'.line('.')<CR>:stopinsert<CR>:set readonly<CR>
else " default Vim?
autocmd VimLeave * call system("echo -n $'" . escape(getreg(), "'") . "' | xsel -ib")
set ttymouse=xterm2
set ttyscroll=100 | " improves speed for terminal vim, incompatible with nvim
set ttyfast | " improves speed for terminal vim (incompatible with nvim)
set nottybuiltin | " use external termcaps
set restorescreen | " restores the console after exiting vim (intentionally not in nvim)
"
let g:loaded_ruby_provider = 1 " disable ruby support
let g:loaded_python_provider = 1 " disable python 3
if version >= 702 " clean up (see: http://vim.wikia.com/wiki/VimTip396)
autocmd BufWinLeave * call clearmatches()
endif
" scripts from the default vim installation, which do not get loaded by default, but are useful.
if filereadable($VIMRUNTIME.'/macros/editexisting.vim')
packadd! editexisting
endif
" load default plugin 'matchit' to allow % to jump between tags
if filereadable($VIMRUNTIME.'/macros/matchit.vim')
packadd! matchit
endif
endif
if has("autocmd")
set modeline | " set variables specific to a file, like indentation by adding a comment
" set default completion function in case YouCompleteMe cannot help
" set omnifunc=syntaxcomplete#Complete
augroup set_window_title " {
" autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]"
autocmd CursorHold * let &titlestring = "%t %y ".$USER."@".hostname().":%{expand(\"%:~:.:h\")}"
set title
" autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")"
" set window title for screen(3)
if &term == "screen"
set t_ts=k
set t_fs=\
endif
if &term == "screen" || &term == "xterm"
set titlelen=40
set title
endif
augroup END
augroup ChangeIcon
"if filereadable("/usr/bin/xseticon")
"if filereadable("~/.vim/nvim.png")
" autocmd VimEnter * silent :execute "!xseticon -id $WINDOWID ~/.vim/nvim.png"
" autocmd VimLeave * silent :execute "!xseticon -id $WINDOWID /usr/share/icons/gnome/32x32/apps/xfce-terminal.png"
"endif
"endif
augroup END
" Fix terminal title =================================================================================================
" autocmd VimEnter * let &t_EI .= "\<Esc>[0 q"
" autocmd VimEnter * let &t_SI = "\<Esc>]12;green\x7"
autocmd VimLeave * silent !echo -ne "\033]112\007"
" highlight word under the cursor ====================================================================================
let w:m1 = 0
function! HighlightWordUnderCursor()
if(exists('w:m1') && w:m1 > 0)
silent! call matchdelete(w:m1)
let w:m1 = 0
endif
let l:currentword = escape(expand('<cword>'), '.')
if(strlen(l:currentword) > 0)
let w:m1=100
silent! call matchadd('BoldUnderline', '\<'.l:currentword.'\>', -1, w:m1)
endif
endfunction
autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor()
" hitting K over a keyword shows a help in a buffer.
" Here we define the commands used to look those keywords up
" as per file type...
augroup filetype_specific
autocmd FileType python setlocal keywordprg=pydoc
autocmd FileType vim setlocal keywordprg=:help |.
autocmd FileType c,cpp setlocal equalprg=clang-format
autocmd FileType c,cpp setlocal breakat-=-
if filereadable("/usr/bin/vendor_perl/ack")
autocmd FileType c,cpp set grepprg=/usr/bin/vendor_perl/ack\ --type=cc\ --nogroup\ --column\ $*
autocmd FileType c,cpp set grepformat=%f:%l:%c:%m
endif
autocmd BufWinEnter * if &previewwindow | setlocal nonumber signcolumn=no filetype=c nobuflisted | endif
" autocmd FileType c,cpp setlocal iskeyword-=_
" the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them
autocmd FileType conf setlocal isfname-==
autocmd Filetype css command! CSSsort :g/{/+1;/}/-1 sort
" keyboard mapping for xml alike languages
" Alt-Up : Move cursor up one tag
" Alt-Down: Move cursor down one tag
" leader-=: tidies currently selected tag and subtags and sorts attributes by name (alphabetically)
autocmd Filetype html,markdown,xml iabbrev </ </<C-X><C-O>
autocmd Filetype html,htmldjango,xml
\ :nnoremap
\ <M-Down>
\ :call search('^ *<', 'e')<CR>:nohlsearch<CR>|
\ :nnoremap
\ <M-Up>
\ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>|
\ :nnoremap
\ <leader>=
\ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat=
augroup END
" autocmd BufNewFile set nobuflisted
" use the shada/viminfo file to return the cursor to where it was...
autocmd BufReadPost * call setpos(".", getpos("'\""))
augroup CurrentFileName
" highlight the current files name inside the document...
let @g = ":exe ':match SpellBad /'.escape(expand('%:t'), '.').'/'"
" put the current files name after the cursor...
let @f = ":exe ':normal a'.expand('%:t')"
" grep all buffers for a given string and return result in a quickfix window
let @q = ":cex [] | bufdo vimgrepadd /foo/g % | cw"
let @l = ":let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}|:SignifyRefresh"
if has('menu')
source $VIMRUNTIME/menu.vim
set wildmenu
set cpo-=<
set wcm=<C-Z>
01menu &Functions.toggle\ file\ browser
\<Tab><leader><leader>
\ <leader><leader>
01menu &Functions.-Sep0- :
01menu &Functions.help
\<Tab><F1>
\ <F1>
01menu &Functions.bp:\ previous\ buffer
\<Tab><F2>
\ <F2>
01menu &Functions.bn:\ next\ buffer
\<Tab><F3>
\ <F3>
01menu &Functions.^wc\:\ close\ window
\<Tab><F4>
\ <F4>
01menu &Functions.-Sep1- :
01menu &Functions.make
\<Tab><F5>
\ <F5>
01menu &Functions.clear\ matches,\ update\ viewport
\<Tab><F6>
\ <F6>
01menu &Functions.copen\:\ show\ quickfix\ list
\<Tab><F7>
\ <F7>
01menu &Functions.lopen\:\ show\ location\ list
\<Tab><F8>
\ <F8>
01menu &Functions.-Sep2- :
01menu &Functions.toggle\ tagbar
\<Tab><F9>
\ <F9>
if has("gui_running") == 0
" in the gui F10 already triggers the menu, not in a terminal vim, so upgrade that...
map <F10> :emenu <C-Z>
endif
01menu &Functions.activate\ menu\ (:emenu)
\<Tab><F10>
\ <F10>
01menu &Functions.undef11
\<Tab><F11>
\ <F11>
01menu &Functions.undef12
\<Tab><F12>
\ <F12>
01menu &Functions.-Sep2- :
09menu &Directory.print\ current\ directory
\<Tab>:pwd
\ :pwd<CR>
09menu &Directory.-Sep- :
09menu &Directory.Change\ to\ GIT\ root
\<Tab>:Gcd
\ :Gcd<CR>:pwd<CR>
09menu &Directory.Change\ to\ current\ buffers\ directory\ (global)
\<tab>:cd\ %:p:h
\ :cd %:h<CR>:pwd<CR>
09menu &Directory.Change\ to\ current\ buffers\ directory\ (local\ window)<tab>:lcd\ %:p:h
\ :lcd %:p:h<CR>:pwd<CR>
menu &Git.&Display\ recently\ changed\ files\ in\ location\ list
\ :call setloclist(0, map(systemlist("git show --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR>
menu &Git.&Display\ last\ changes
\ :let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}<CR>:SignifyRefresh<CR>
menu &Git.&Display\ significance\ of\ changes
\ :!git diff --stat HEAD~1..HEAD
menu &Git.&Display\ Changed\ files\ compared\ to\ master
\ :!git diff --name-status ..master
menu &Match.Clear\ All\ Matches
\<Tab><F6>
\ :call clearmatches()<CR>
menu &Match.-Sep- :
menu &Match.&dispensable\ white\ spaces
\ :call matchadd("Convention", '\s\+$', 0)<CR>
menu &Match.&long\ lines\ (exeeding\ textwidth)
\ :call matchadd("Convention", '\%>'.&textwidth.'v.', 0)<CR>
menu &Match.Highlight\ current\ file\ name
\ :call matchadd("Search", escape(expand('%:t'), '.'))<CR>
" :execute ':match SpellBad /'.escape(expand('%:t'), '.').'/'<CR>
menu &Window.-Sep- :
menu &Window.Scratch
\ :Scratch<CR>
menu &Find.file\ under\ the\ cursor
\<Tab>gf
\ gf
menu &Find.Open\ search\ results\ in\ location\ list
\<Tab>:gf
\ :execute ':vimgrep /'.escape(getreg('/'), '.').'/g %'<CR>
\ :copen<CR>
menu &Changes.list
\<Tab>:changes
\ :changes<CR>
menu &Changes.-Sep- :
menu &Changes.previous
\<Tab>g;
\ g;
menu &Changes.next
\<Tab>g,
\ g,
menu &List.location.signs\ to\ list
\<Tab>CMD
\ :execute ":call setloclist(0, map(get(getbufinfo('%')[0], 'signs'), {_, p->extend(p, {'bufnr':buffer_number('.'), 'text':get(p, 'name')})}))"<CR>
menu &List.location.list\ to\ signs
\<Tab>CMD
\ :call execute(extend(['sign define LocationListEntry text=L', 'sign unplace *'], map(getloclist('%'), {key, val->'sign place '.(key+100).' name=LocationListEntry line='.val['lnum'].' buffer='.buffer_number('%')})))<CR>
menu &Jump.list
\<Tab>:jumps
\ :jumps<CR>
menu &Jump.-Sep1- :
menu &Jump.previous\ position
\<Tab>CTRL-O
\ <C-O>
menu &Jump.next\ position
\<Tab>CTRL-I
\ <C-I>
menu &Jump.-Sep2- :
menu &Jump.clear\ list
\<Tab>:clearjumps
\ :clearjumps
1000menu &Tag.list
\<Tab>:tags
\ :tags<CR>
1000menu &Tag.selection\ list
\<Tab>:ts
\ :ts<CR>
1000menu &Tag.-Sep1- :
1000menu &Tag.stack.jump\ older
\<Tab><C-T>
\ :po
1000menu &Tag.stack.jump\
\<Tab>:ta
\ :ta
endif
" autocmd BufEnter * @f
augroup END
" autocmd VimEnter * set nobuflisted
endif
" ======================================================================================================================
" SHORTCUTS: custom shortcuts
" inoremap <C-Space> <C-x><C-o>
" inoremap <C-@> <C-Space>
" Bind CTRL+Backspace to vim's version (CTRL+W) in " <CR> insert mode (only works with gvim)
inoremap
\ <C-Backspace>
\ <C-W>
" INDENTATION: allows un-indenting a selected block and keeps selection
vnoremap < <gv
vnoremap > >gv
" make shift-home select to the beginning of the line
nnoremap <s-home> v^
nnoremap <s-end> v$
nnoremap <s-down> vj
vnoremap <s-down> j
nnoremap <s-up> vk
vnoremap <s-up> k
" close current buffer with <leader>q...
nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>.
" google the word under the cursor
nnoremap <leader>G :execute ":!xdg-open https://google.de/search?q=".expand("<cword>")
nnoremap <silent> <F5> :make!<CR>
nnoremap <silent> <F6> :silent syntax sync fromstart<CR>:nohlsearch<CR>:silent match<CR>:silent 2match<CR>:silent 3match<CR>
nnoremap <leader>r :syntax sync fromstart
nnoremap <silent> <A-Up> :wincmd k<CR>
nnoremap <silent> <A-Down> :wincmd j<CR>
nnoremap <silent> <A-Left> :wincmd h<CR>
nnoremap <silent> <A-Right> :wincmd l<CR>
" INSERT_MODE_MAPPINGS:
" default copy&paste insert key binding (just in insert mode, so it doesn't conflict
" with visual block mode)- would have been nice, but collides with c-w for digraphs
" inoremap <C-V> <C-R>+
"
inoremap <C-S> <C-O>:w<CR>
" NEOVIM_SPECIFIC:
if has('nvim') " only neovim...
" shortcut \t opens a terminal in a horizontal split
nnoremap <leader>t :new +terminal<CR>
endif
" ======================================================================================================================
" START: LOADING PLUGINS
" ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
call plug#begin()
" Colorschemes:
Plug 'coderonline/vim-remote-menu'
" Plug 'bbchung/clighter8'
" Plug 'octol/vim-cpp-enhanced-highlight'
" Plug 'vim-scripts/TagHighlight'
" if ! exists('g:TagHighlightSettings')
" let g:TagHighlightSettings = {}
" endif
" let g:TagHighlightSettings['TagFileName'] = 'tags'
" let g:TagHighlightSettings['CtagsExecutable'] = 'ctags'
Plug 'chriskempson/base16-vim' | " not just one high quality color scheme (all named base16-*)
Plug 'NLKNguyen/papercolor-theme' | " the one I like the most
Plug 'mhinz/vim-signify' | " uses the sign column to indicate added, modified and removed lines
Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin
Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/=
Plug 'severin-lemaignan/vim-minimap'
Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with '
let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify)
let g:signify_cursorhold_insert = 0
let g:signify_cursorhold_normal = 0
let g:signify_update_on_bufenter = 0
let g:signify_update_on_focusgained = 0
let g:signify_sign_show_count = 1
" NERDTree: replaces NetRW, as long as it has so many bugs
Plug 'scrooloose/nerdtree' | "
let NERDTreeIgnore = ['\.aux$', '\.o$']
let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use <m> to create files in that included directory
let NERDTreeChDirMode = 0
let NERDTreeHiddenFirst = 1
let NERDTreeMinimalUI = 1
let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time)
let NERDTreeWinSize = 40
let NERDTreeQuitOnOpen = 1
" depending on if NERDTree has the focus:
nnoremap <expr>
\ <leader><leader>
\ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose<CR>' : ':NERDTreeFind<CR>'
nnoremap <expr>
\ <F2>
\ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':N<CR>'
nnoremap <expr>
\ <F3>
\ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':n<CR>'
nnoremap <F4>
\ :wincmd c<CR>
" close NERDTree if it is the last remaining window (taken from the official documentation)
" autocmd bufenter *
" \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"
" map CTRL-PageUp/Down to next/previous buffer
" and Shift-PageUp/Down to next/previous arglist file
nnoremap <C-PageUp> :bn<CR>
nnoremap <C-PageDown> :bp<CR>
nnoremap <S-PageUp> :N<CR>
nnoremap <S-PageDown> :n<CR>
" Additional: ========================================.
Plug 'sheerun/vim-polyglot' " better syntax highlighting/indentation for multiple languages
let g:javascript_conceal_function = "ƒ"
let g:javascript_conceal_null = "ø"
let g:javascript_conceal_this = "@"
let g:javascript_conceal_return = "⇚"
let g:javascript_conceal_undefined = "¿"
let g:javascript_conceal_NaN = "ℕ"
let g:javascript_conceal_prototype = "¶"
let g:javascript_conceal_static = "•"
let g:javascript_conceal_super = "Ω"
let g:javascript_conceal_arrow_function = "⇒"
Plug 'majutsushi/tagbar' " superseeds taglist-plus, which isn't maintained any more
let g:tagbar_autoclose = 0
let g:tagbar_autofocus = 1
let g:tagbar_autoshowtag = 0
let g:tagbar_compact = 1
let g:tagbar_indent = 0
let g:tagbar_foldlevel = 99
nnoremap <F9> :TagbarToggle<CR>| " bind TagBar to hotkey F9
" Autocompleter: =====================================
if has("python")
" ULTISNIPS: code snippet ============================================================================================
Plug 'honza/vim-snippets' " dependency of ultisnips (see below)
Plug 'SirVer/ultisnips' " replaces loremipsum (and many more)
" let g:UltiSnipsExpandTrigger = '<Tab>'| " expands the snippet, be careful not to use <tab> elsewhere (ycm uses it by default, but it has been deactivated by g:ycm_key_list_select_completion)
let g:UltiSnipsExpandTrigger = '<Tab>'| " expands the snippet, be careful not to use <tab> elsewhere (ycm uses it by default, but it has been deactivated by g:ycm_key_list_select_completion)
let g:UltiSnipsJumpForwardTrigger = '<Tab>'|
let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'|
"d let g:UltiSnipsJumpForwardTrigger = '<PageDown>'
" let g:UltiSnipsJumpBackwardTrigger = '<PageUp>'
"let g:UltiSnipsExpandTrigger = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
"let g:UltiSnipsJumpForwardTrigger = '<C-j>'| " \
"let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \
"let g:UltiSnipsListSnippets = '<C-`>'| " YouCompleteMe includes those, so this isn't necessary
"let g:UltiSnipsListSnippets = '<leader><leader>'| " YouCompleteMe includes those, so this isn't necessary
""" Ultisnips
" let g:UltiSnipsExpandTrigger="<c-tab>"
" let g:UltiSnipsListSnippets="<c-s-tab>"
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" Use deoplete.
let g:deoplete#enable_at_startup = 1
inoremap <silent><expr> <C-Space> deoplete#mappings#manual_complete()
Plug 'Shougo/echodoc.vim'
let g:echodoc#enable_at_startup = 1
" Plug 'Rip-Rip/clang_complete'
" Plug 'tweekmonster/deoplete-clang2'
" Plug 'zchee/deoplete-clang'
" let g:deoplete#sources#clang#libclang_path = "/usr/lib/libclang.so"
" let g:deoplete#sources#clang#clang_header = "/usr/lib/clang/6.0.0"
" let g:deoplete#sources#clang#std#cpp = 'c++1z'
" let g:deoplete#sources#clang#clang_complete_database = "/home/max/src"
" Plug 'Shougo/neoinclude.vim' " makes vim slow - unfortunatelly
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
let g:LanguageClient_serverCommands = {
\ 'cpp': ['clangd']
\ }
" Plug 'roxma/nvim-completion-manager' unmaintained python version
else
Plug 'idanarye/vim-vebugger'
" YouCompleteMe: =====================================================================================================
" Plug 'Valloric/MatchTagAlways' " highlights the closing tag/brace/...
Plug 'Valloric/YouCompleteMe', {
\ 'do' : 'python install.py --clang-completer --system-libclang --quiet',
\ }
let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar/sign column
let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar/sign coloumn
let g:ycm_autoclose_preview_window_after_insertion = 0
let g:ycm_auto_trigger = 1
let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file
let g:ycm_confirm_extra_conf = 0 " security is overrated ;)
let g:ycm_key_list_previous_completion = ['Up']
let g:ycm_key_list_select_completion = ['Down']
" Plug 'vim-scripts/dbext.vim' " dependency to allow db related completions
" let g:ycm_server_python_interpreter = 'python3'
" let g:ycm_python_binary_path = '/usr/bin/python3' " the python interpreter of choice (for code checking)
" let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window
" let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword
" let g:ycm_complete_in_comments = 1 " Completion in comments
" let g:ycm_complete_in_strings = 1 " Completion in string
" let g:ycm_min_num_of_chars_for_completion = 6 " we normally avoid identifier based completion, it just helps with long words. Use semantic completions with <C-Space> instead (terrible idea, html snippets not working!)
" let g:ycm_min_num_identifier_candidate_chars = 4
" let g:ycm_max_num_identifier_candidates = 10
" let g:ycm_max_num_candidates = 50
" let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure
" let g:ycm_key_list_select_completion = ['<Down>']
" let g:ycm_key_list_previous_completion = ['<Up>']
" let g:ycm_global_ycm_extra_conf = '.ycm_extra_conf.py'
" let g:ycm_semantic_triggers = { 'c': [ 're!.' ] }
" " let g:ycm_disable_for_files_larger_than_kb = 16384 " we have faaast computers, don't we?
" let g:ycm_show_diagnostics_ui = 0
" " disable <tab>-key for YCM so that it can be used with ultisnips
" let g:ycm_key_list_select_completion=[]
" let g:ycm_key_list_previous_completion=[]
endif
" SYNTASTIC: =========================================================================================================
if has('nvim')
Plug 'w0rp/ale'
let g:ale_set_highlights = 0
highlight! link ALEWarningSign FoldColumn
let g:ale_sign_error = ''
let g:ale_sign_style_error = ''
let g:ale_sign_info = ''
let g:ale_sign_warning = ''
else
Plug 'scrooloose/syntastic'
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
let g:LatexBox_latexmk_preview_continuously = 1
let g:LatexBox_viewer = "evince"
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" let g:syntastic_quiet_messages = {"type":"style"}
"
" E221: multiple spaces before Operator
let g:syntastic_python_flake8_args = '--max-complexity=10 --max-line-length=120 --exclude venv --doctests --exit-zero --ignore=E221'
" filter ( = do not display) style/formatting errors and warnings
let g:syntastic_error_symbol = '✖'
let g:syntastic_style_error_symbol = '✗'
let g:syntastic_warning_symbol = '➔'
let g:syntastic_style_warning_symbol = '≈'
endif
" JEDI: ==============================================================================================================
Plug 'davidhalter/jedi-vim' " jedi gets used to display python function signatures
let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe
let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi
let g:jedi#show_call_signatures_delay = 0
let g:jedi#auto_vim_configure = 0
let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163
" autocmd FileType python jedi.preload_module('os', 'sys', 'math')
" let g:pymode_options_max_line_length = 120
" let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301'
endif " has("python")
"=======================================================================================================================
" TESTING: | " plugins which I am currently trying...
"=======================================================================================================================
" Plug 'rhysd/vim-clang-format' | unnecessary, because we can just :pyf /usr/share/clang/clang-format.py
Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation
" TODO: check if this is unrequired, when set equalprog is set to that py file
autocmd FileType c,cpp,objc map <buffer> = :pyf /usr/share/clang/clang-format.py<CR>
" let g:clang_format#detect_style_file = 1
" autocmd FileType c,cpp,objc map <buffer> = <Plug>(operator-clang-format)
" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values)
" Plug 'rkitover/vimpager'
" found this command instead (use as PAGER):
" man -P 'nvim -R -u NORC -c":%!col -b" -c":set buftype=nowrite filetype=man" -' ls
command BuffersToArg :exec ':args '.join(map(range(0, bufnr('$')), 'fnameescape(fnamemodify(bufname(v:val), ":."))'))
command BufToArg :argadd %:.
"=======================================================================================================================
call plug#end() | " all plugins are getting loaded on this line, don't remove!
" ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
" END: LOADING PLUGINS
" ======================================================================================================================
" Deprecated with this configuration, but still useful when deactivating some Plugins
" NETRW: obsolete with NERDTree
let g:netrw_alto = 0 | " open files on the right
let g:netrw_altv = 1 | " open files on the right
let g:netrw_banner = 0 | " display help messages?
let g:netrw_browse_split = 4 | " 4=open in previous window
let g:netrw_fastbrowse = 2 | " manually refresh direcory list (avoids display errors)
let g:netrw_hide = 1 | " show not-hidden files only
let g:netrw_keepdir = 0
let g:netrw_list_hide = '^\..*' | " Explore mode: hide files starting with dot
let g:netrw_liststyle = 3 | " 3=tree
let g:netrw_preview = 0 | "
let g:netrw_winsize = 20 | " window size in percent
" ======================================================================================================================
" COLORSCHEME:
" ======================================================================================================================
function! ExtendColorTheme()
" let g:status_fg=synIDattr(hlID('Cursor'), 'fg#')
" let g:status_bg=synIDattr(hlID('Cursor'), 'bg#')
" let g:status_sel=synIDattr(hlID('Text'), 'fg#')
" let g:status_sel='#ffffff'
let g:status_fg='#00aa00'
let g:status_bg='#000000'
let g:status_sel='#ffff00'
" execute 'highlight! StatusLine'
" \ .' guibg=NONE'
" \ .' guifg='.g:status_bg
" \ .' gui=inverse'
" " execute 'highlight! User1 gui=NONE'
" execute 'highlight! User1 guibg='.g:status_sel
" execute 'highlight! User1 guifg='.g:status_fg
" execute 'highlight! User2 gui=NONE'
" execute 'highlight! User2 guibg='.g:status_sel
" execute 'highlight! User2 guifg=NONE'
filetype on
filetype plugin on
filetype indent on
syntax on | " enable syntax highlighting
syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact)
" use the default terminal background color as background (allows transparency)
" highlight! Normal guibg=NONE ctermbg=NONE
" highlight! NonText guibg=NONE guifg=black ctermbg=NONE ctermfg=black
" make the ~ (tilde) indicator invisible, which usually marks the EOF
highlight! link EndOfBuffer Ignore
highlight! CursorLineNr cterm=inverse | " ctermbg=black ctermfg=NONE
highlight! Pmenu ctermbg=LightYellow ctermfg=DarkGrey
highlight! PmenuSel ctermbg=blue ctermfg=LightYellow cterm=bold
highlight! link PmenuSbar Pmenu
highlight! PmenuThumb cterm=inverse
highlight! MoreMsg cterm=inverse
highlight! link Folded LineNr
" highlight! Cursor guibg=#729fcf ctermbg=yellow
highlight! link VertSplit LineNr
" highlight! SpellBad ctermbg=none
highlight! SpecialKey ctermfg=19
highlight! WhiteSpace ctermfg=19
" highlight! link TabLine LineNr
" highlight! TabLineSel ctermbg=blue ctermfg=black
" highlight! link TabLineFill LineNr
highlight! Search ctermbg=LightYellow ctermfg=black guibg=#fefd86 guifg=#222222
highlight! link WildMenu Search
" generic, which should exist but don't
highlight! Bold cterm=bold gui=bold
highlight! Italic cterm=italic gui=italic
highlight! Underline cterm=underline gui=underline
highlight! BoldUnderline cterm=bold,underline gui=bold,underline
highlight! BoldItalic cterm=Bold,Italic gui=Bold,Italic
" make tab stop (see listchars) less disturbing...
highlight! link SpecialKey NonText
" highlight! link LightlineMiddle_tabline ColorColumn
" highlight! link LightlineLeft_tabline_1 ColorColumn
" highlight! link LightlineLeft_tabline_0_1 ColorColumn
highlight! Todo guibg=#ffffaa guifg=#000000 gui=bold term=bold
highlight! cStatement guifg=red gui=bold term=bold
highlight! link Convention Error
" autocmd InsertLeave * call matchadd('Conceal', ' \+$', -1, 101, { 'conceal': '⟶' })
autocmd InsertEnter * silent! call matchdelete(101)
autocmd InsertLeave * silent! call matchadd('Convention', ' \+$', -1, 101, { 'conceal': '⟶' })
" Show trailing whitepace and spaces before a tab as part of the syntax highlighting
" autocmd BufEnter,InsertLeave * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
" autocmd Syntax * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
" autocmd BufEnter,BufWritePost * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL
" autocmd InsertEnter * syntax clear Convention
" autocmd BufEnter,InsertLeave * execute ':syntax match Convention /\%>'.&textwidth.'v./ containedin=ALL'
autocmd InsertEnter * set colorcolumn=80,120
autocmd InsertLeave * set colorcolumn&
" set colorcolumn= | " not used, because we have a :match directive for textwidth
"
" if argc() == 0
" rv
" autocmd VimEnter * split +bro\ ol
" endif
endfunction
autocmd! ColorScheme * call ExtendColorTheme()
set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim
" set t_ut=
" ======================================================================================================================
" CONVENIENCE:
" ======================================================================================================================
if empty(argv())
" autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val}))
" from the list of recent files: make absolute paths, filter out files not
" contained in cwd and finally filter out directories and non-files...
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if !exists("s:std_in") | call setqflist(map(filter(filter(
\ map(copy(v:oldfiles), {_, p->expand(p)}), 'v:val =~ "'.getcwd().'"'),
\ 'filereadable(v:val)'), {_, p->{'filename': fnamemodify(p, ':.')}})) | copen | only
endif
command Vimls
\ call setloclist(0, map(getbufinfo({'buflisted':1}),
\ "{'bufnr': v:val.bufnr,
\ 'lnum': v:val.lnum,
\ 'text': '='.printf('%*s, % 3d: %s [%s]', winwidth(0) / 2, '', v:val.bufnr, v:val.name, getbufvar(v:val.bufnr, '&buftype')),
\ 'pattern': 'not loaded'}
\ "))
command Ctoggle
\ if(get(getqflist({'winid':1}), 'winid') == win_getid())|cclose|else|botright copen|endif
command Ltoggle
\ if(get(getloclist(0, {'winid':1}), 'winid') == win_getid())|lclose|else|lopen|endif
" nnoremap <silent> <ESC> :lclose<CR> " brings vim into REPLACE mode (R)
nnoremap <silent> <F7> :Ltoggle<CR>
nnoremap <silent> <F8> :Ctoggle<CR>
nnoremap <silent> <F12> :Vimls<CR>:Ltoggle<CR>
" exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s)
nnoremap Q !!$SHELL<CR>
" ======================================================================================================================
" TESTING:
" ======================================================================================================================
" avoids openin an empty buffer when restoring bufferlist from viminfo...
" if argc() == 0
" silent autocmd VimEnter * nested :silent bun
" endif
autocmd VimEnter,WinEnter * exec ':set scrolljump='.winheight(0)/2
" display highlight group under the cursor
map <leader>h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<CR>
if filereadable(expand("~/.vimrc_background")) && filereadable(expand("~/.config/base16-shell/colortest"))
let g:base16_shell_path="~/.config/base16-shell/scripts"
let base16colorspace=256
" let syntax_cmd="skip" " vim internal, use base16 and no default colors
set background=dark
source ~/.vimrc_background
else
let g:PaperColor_Theme_Options = {
\ 'theme': {
\ 'default': {
\ 'transparent_background': 0
\ }
\ }
\ }
set background=light
colorscheme PaperColor
endif
augroup status
set noshowmode | " mode will be shown twice, in lightline and below, so we want to deactivate one
set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split
function! CreateInvertGroup(highlight_group)
if(synIDattr(hlID(a:highlight_group), "reverse")==1)
let w:color=synIDattr(hlID(a:highlight_group), "fg#")
else
let w:color=synIDattr(hlID(a:highlight_group), "bg#")
endif
let l:retval=a:highlight_group.'_invert'
if(exists('w:color') && w:color == '')
let w:color = 'NONE'
endif
exec 'highlight '.retval.' gui=NONE guifg='.w:color
return l:retval
endfunction
function ModeString()
return get({
\ 'n' : 'normal',
\ 'i' : 'insert',
\ 'R' : 'replace',
\ 'v' : 'visual',
\ "V" : 'visual line',
\ "\<C-V>" : 'visual block',
\ 'c' : 'command',
\ 's' : 'select',
\ 'S' : 'select line',
\ "\<C-s>" : 'select block',
\ 't' : 'terminal'
\ }, mode(), mode())
endfunction
function! UpdateStatus(highlight_group)
let l:invert_group = CreateInvertGroup(a:highlight_group)
return ''
\ ."%#StatusLineHighlight#"
\ ."%#".a:highlight_group."#"
\ ."%(%w%h%q\ %{ModeString()}%)"
\ ."%-2{nr2char(0xe621)}"
\ ."%{(&readonly\ ?\ '\ \ \ '\ :\ '')}"
\ ."%{(&modified\ ?\ nr2char(0xF0C7).'\ '\ :\ '')\ }"
\ ."%{(&buftype\ ==\ \"terminal\"\ ?\ ''\ :\ fnamemodify(getcwd(),\ ':~').nr2char(0xf44a))}\ "
\ ."%{(&buftype\ ==\ \"terminal\"\ ?\ b:term_title\ :\ bufname('%'))\ }"
\ ."%#".l:invert_group."#"
\ ."%{nr2char(0xE0B4)\ }"
\ .''
\ ."%="
\ .''
\ ."%#".l:invert_group."#"
\ ."%{nr2char(0xE0B6)}"
\ ."%#".a:highlight_group."#"
\ ."%1(%)"
\ ."%{(&filetype\ !=\ ''\ ?\ &filetype\ :\ &buftype)}"
\ ."%(\ %{nr2char(0xe621)}\ %)"
\ ."%{(&spell\ ?\ &spelllang.' '.nr2char(0xe621)\ :\ '')}"
\ ."%{(&fileencoding\ !=\ ''\ ?\ &fileencoding.' '.nr2char(0xe621)\ :\ '')}"
\ ."%{(&fileformat\ !=\ ''\ ?\ &fileformat\ :\ '')}"
\ ."%(\ %{nr2char(0xe621)}\ %)"
\ ."%4l:%-4c"
\ ."%(\ %{nr2char(0xe621)}\ %)"
\ ."%-3p%%"
endfunction
function! UpdateTabline(highlight_group)
let l:invert_group = CreateInvertGroup(a:highlight_group)
return ''
\ ."%#".a:highlight_group."#"
\ ."%3(\ %)"
\ ."%{nr2char(0xe621)}"
\ ."%(%{v:servername}\ %{v:this_session}%)"
\ ."%#".l:invert_group."#"
\ ."%{nr2char(0xE0B4)\ }"
\ .''
\ ."%="
\ .''
\ ."%#".l:invert_group."#"
\ ."%{nr2char(0xE0B6)}"
\ ."%#".a:highlight_group."#"
\ ."%(\ \ %{fugitive#head()}\ %)"
\ ."%{nr2char(0xe621)}"
\ ."%(\ \ %{tabpagenr()}/%{tabpagenr('$')}\ %)"
\ ."%##"
\ ."" " end
endfunction
let g:group_active = "StatusLine"
let g:group_inactive = "StatusLineNC"
let g:group_tabline = "TabLine"
function ApplyColorScheme()
" set up statusline, global and current window individually
set statusline=%!UpdateStatus(g:group_inactive)
setlocal statusline=%!UpdateStatus(g:group_active)
" set up the tabline (match colors)
set tabline=%!UpdateTabline(g:group_tabline)
endfunction
" apply colors from the loaded colorscheme...
call ApplyColorScheme()
" when changing the colorscheme also apply new colors to the statusbar...
autocmd ColorScheme * call ApplyColorScheme()
autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active)
autocmd WinLeave * setlocal statusline<
augroup END
|