-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc2
3743 lines (3225 loc) · 110 KB
/
vimrc2
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
" Options ================================================================ {{{1
" enconding
set encoding=utf-8
scriptencoding utf-8
" forget being compatible with good old vi
set nocompatible
" disable some of the plugings, depending on OS and Vim features available
let g:pathogen_blacklist = []
if !has('python3')
let g:pathogen_blacklist += ['ultisnips']
endif
" this should be at the beginning to allow pathogen plugin to generate
" runtimepath before other plugings are loaded
if has('nvim')
runtime bundle2-nvim/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect('bundle2-nvim/{}')
else
runtime bundle2-vim/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect('bundle2-vim/{}')
endif
call pathogen#helptags()
" detect operating system
let s:os = substitute(system('uname'), "\n", '', '')
" detect terminal emulator
let s:term_prog = substitute(system('printenv TERM_PROGRAM'), "\n", '', '')
let s:term_color = substitute(system('printenv COLORTERM'), "\n", '', '')
let s:iterm_profile = substitute(system('printenv ITERM_PROFILE'), "\n", '', '')
" Filetype --------------------------------------------------------------- {{{2
"
if has('autocmd')
filetype plugin indent on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
runtime! ftplugin/man.vim
runtime macros/matchit.vim
runtime macros/justify.vim
" reduce timeout for matchit/matchpair
let g:matchparen_timeout = 5
let g:matchparen_insert_timeout = 5
" Colors ---------------------------------------------------------------- {{{2
"
" change light/dark theme depending on the time of day
function! MySetBG()
let hr = strftime('%H%M')
let time_dark = '1700'
let time_light = '0730'
let bgtime_file = glob('~/.vim/light-dark')
if filereadable(bgtime_file)
let bgtimes = split(readfile(bgtime_file)[0])
if !empty(bgtimes)
let time_light = bgtimes[0]
let time_dark = bgtimes[1]
endif
endif
if s:iterm_profile =~? '.*dark.*' && s:term_prog !=# 'tmux'
set background=dark
elseif s:iterm_profile =~? '.*light.*' && s:term_prog !=# 'tmux'
set background=light
elseif hr >= time_dark
set background=dark
elseif hr >= time_light
set background=light
elseif hr >= 0
set background=dark
endif
if has('nvim')
if &background == 'light'
lua require'toggleterm'.setup { shading_factor = 2 }
else
lua require'toggleterm'.setup { shading_factor = -30 }
endif
endif
endfunction
" enable 256 colors in terminal
if match($TERM, '256color') != -1
set t_Co=256
endif
let g:lualine_theme = 'dracula'
if s:term_color ==# 'truecolor'
if s:os ==? 'Linux' && !empty($TMUX)
set background=dark
endif
" enable undercurl in terminal
" https://github.com/vim/vim/issues/1306#issuecomment-350887565
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
" enable 24-bit color support in Vim8/Neovim
if has('termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
let g:neosolarized_bold = 1
let g:neosolarized_italic = 1
let g:neosolarized_underline = 1
let g:neosolarized_termBoldAsBright = 1
let g:neosolarized_vertSplitBgTrans = 1
if s:iterm_profile =~? '.*solarized.*'
if has('nvim')
let g:lualine_theme = 'solarized'
colorscheme solarized-normal
else
colorscheme NeoSolarized
endif
call MySetBG()
else
set background=dark
let g:airline_theme='onedark'
let g:lualine_theme = 'onedark'
let g:colors_name = 'onedark'
colorscheme onedark
endif
else
if s:term_prog ==# 'iTerm.app' && s:iterm_profile =~? '.*solarized.*'
colorscheme solarized
else
colorscheme chumakd-elflord
endif
endif
else
colorscheme chumakd-elflord
endif
" enable ToggleBG command from solarized plugin for light/dark bg switching
runtime autoload/togglebg.vim
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
set t_Co=16
endif
" disable Powerline plugin if we don't have full color terminal
" because it makes status line totally black in this mode
if &t_Co == 8
let g:Powerline_loaded = 1
endif
" Search ---------------------------------------------------------------- {{{2
"
set ignorecase
set smartcase
set hlsearch
set incsearch
set nowrapscan
" Folding ---------------------------------------------------------------- {{{2
"
set foldcolumn=4
set foldmethod=syntax
set foldopen+=insert,jump
" set 'foldmethod' to 'manual' when entering insert mode
" this improves completion speed in order of magnitude
" from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
augroup fold_completion_fix
autocmd!
autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif
autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif
augroup END
" Indent ----------------------------------------------------------------- {{{2
"
set autoindent
set nocindent
set nosmartindent
" Tabstop ---------------------------------------------------------------- {{{2
"
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround
set smarttab
set expandtab
" Diff ------------------------------------------------------------------- {{{2
"
if has('mac') && $VIM == '/usr/share/vim'
" do nothing
elseif has('patch-8.1.0360')
" most accurate but slowest
set diffopt+=algorithm:histogram
endif
" Spell ------------------------------------------------------------------ {{{2
"
set spelllang=en_us
set spelllang+=ru
"set spelllang+=ua
" Language --------------------------------------------------------------- {{{2
"
set dictionary=/usr/share/dict/words
" enable keymappings for russian win-like йцукен keyboards
set keymap=russian-jcukenwin
" force insert and search begin in english and non in keymap language
set iminsert=0
set imsearch=0
" enable language map for ru_RU.UTF-8 locale
set langmap=ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz,№#,х[,Х{,ъ],Ъ},Ж:,э',Б<,ю.,Ю>,Э\"
" Window ----------------------------------------------------------------- {{{2
"
set ruler
" show statusline even if there is only one window
set laststatus=2
if v:version >= 703
set statusline=%h%w%q\ %f\ \%m%r\ %=\ <\ ts:%{&ts}\ et:%{&et}\ <\ %{&ft}\ \ \ LN:%3l:%-2v/\ %-4L\ [%P]
else
set statusline=%h%w\ %f\ \%m%r\ %=\ <\ ts:%{&ts}\ et:%{&et}\ <\ %{&ft}\ \ \ LN:%3l:%-2v/\ %-4L\ [%P]
endif
set tabline=%!MyTabLine2()
set linebreak
let &showbreak='↪ '
set nowrap
set showcmd
set noshowmode
set winminheight=0
set wildmenu
" disable any fillchars for folds and vertical splits
" NOTE: the space after vert: is essential
"set fillchars=fold:\ ,vert:\ " empty space at the end intended
"set fillchars=fold:\ ,vert:┃,diff:╱
set fillchars=fold:\ ,vert:┃,diff:─
" Backup/Undo ------------------------------------------------------------ {{{2
"
set backup
set backupdir=~/.vim/backup,.,~/temp/tmp,~/
if v:version >= 703
set undofile
if has('nvim')
set undodir=~/.vim/undo-neovim,.,~/
else
set undodir=~/.vim/undo,.,~/
endif
endif
" where to place swap files
set directory=.,~/.vim/swap,/var/tmp,/tmp
" Display ---------------------------------------------------------------- {{{2
"
" classic
"set listchars=eol:$,tab:>-,trail:.,extends:>,precedes:<,nbsp:●
" modern (spacevim)
"set listchars=tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶,nbsp:●
" modern (spacevim + ruby tabs)
set listchars=tab:»·,eol:↵,trail:·,extends:↷,precedes:↶,nbsp:●
" don't update the display while executing macros
set lazyredraw
set novisualbell
" hide the mouse pointer while typing
set mousehide
" disable mouse integration
set mouse=
" when the page starts to scroll, keep the cursor 8 lines from the top and 8
" lines from the bottom
"set scrolloff=8
if v:version >= 703
" show line numbers relative to cursor position
set relativenumber
endif
set number
set numberwidth=3
" highlight textwidth column
let s:colorcolumn_default = '81,101,121'
"let &colorcolumn = s:colorcolumn_default
"set colorcolumn=+1
set colorcolumn=
" show as much as possible when last line doesn't fit on screen
set display+=lastline
" max tabs
set tabpagemax=50
" Tags ------------------------------------------------------------------- {{{2
"
" disable preview window
set completeopt-=preview
" when completing by tag, show the whole tag, not just the function name
set showfulltag
set tags=./tags,tags,~/.vim/tags/stl
",~/prg/tags/tags.libc
",~/prg/tags/tags.stl
",~/prg/tags/tags.boost
if has('cscope')
" search tags database before cscope database
set cscopetagorder=1
" show cscope search results in quickfix window
set cscopequickfix=s-,c-,d-,i-,t-,e-
endif
" Edit ------------------------------------------------------------------- {{{2
"
" ask to save/not/cancel if buffer is modified and going to be closed/unvisible
set confirm
set nohidden
" disable virtualedit by default
set virtualedit=
" allow backspace to delete everything
set backspace=indent,eol,start
" disable timeout for mappings
set notimeout
" set timeout for mappings (only used when ':set timeout')
set timeoutlen=500
" set timeout for keycodes
set ttimeoutlen=2 " ttimeoutlen=100
" speed up CursorHold autocommand (used to highlight current word)
set updatetime=500
" speed up completion significantly
" don't allow ^N completion to scan included files by default
" that can be requested directly with i_^x^i
set complete-=i
" don't allow ^N completion to scan tags by default
" that can be requested directly with i_^x^]
set complete-=t
" treat octal numbers as decimal for increment/decrement commands: CTRL-A CTRL-X
set nrformats-=octal
" text and comments formatting, see :help fo-table
set formatoptions=crqol
" delete comment character when joining commented lines
if v:version > 703 || v:version == 703 && has('patch541')
set formatoptions+=j
endif
" Cmdline ---------------------------------------------------------------- {{{2
"
set history=5000
" set key to invoke completion mode from inside mappings
set wildcharm=<C-X>
" for windoze set the forward slash to be used as path separator
if exists('+shellslash')
set shellslash
endif
" Extensions ------------------------------------------------------------- {{{2
"
" Python {{{3
let g:pymode_python = 'python3'
" disable python2
let g:loaded_python_provider = 0
if s:os ==? 'Darwin'
let s:python3_homebrew_default = '/opt/homebrew/bin/python3'
if filereadable(s:python3_homebrew_default)
let g:python3_host_prog = s:python3_homebrew_default
endif
elseif s:os ==? 'Linux'
let s:python3_linuxbrew_default = '/home/linuxbrew/.linuxbrew/bin/python3'
let s:python3_linuxbrew_local = $HOME . '/local_install/homebrew/bin/python3'
if filereadable(s:python3_linuxbrew_default)
let g:python3_host_prog = s:python3_linuxbrew_default
elseif filereadable(s:python3_linuxbrew_local)
let g:python3_host_prog = s:python3_linuxbrew_local
endif
let s:pyhome_linuxbrew_default = '/home/linuxbrew/.linuxbrew/opt/python'
let s:pyhome_linuxbrew_local = $HOME . '/local_install/homebrew/opt/python'
"if !empty(glob(s:pyhome_linuxbrew_default))
" let $PYTHONHOME=s:pyhome_linuxbrew_default
"elseif !empty(glob(s:pyhome_linuxbrew_local))
" let $PYTHONHOME=s:pyhome_linuxbrew_local
"else
" echoerr "Homebrew's PYTHONHOME location cannot be found"
"endif
let s:py3dynload_linuxbrew_default = '/home/linuxbrew/.linuxbrew/lib/python3.12/lib-dynload'
let s:py3dynload_linuxbrew_local = $HOME . '/local_install/homebrew/lib/python3.12/lib-dynload'
let s:py3dynload_system = '/usr/lib/python3.12/lib-dynload'
let s:py3dynload_system_old = '/usr/lib/python3.11/lib-dynload'
if has('python3')
if !empty(glob(s:py3dynload_linuxbrew_default))
python3 import sys; sys.path.append(vim.eval("expand(s:py3dynload_linuxbrew_default)"))
elseif !empty(glob(s:py3dynload_linuxbrew_local))
python3 import sys; sys.path.append(vim.eval("expand(s:py3dynload_linuxbrew_local)"))
elseif !empty(glob('/.dockerenv'))
" ignored inside docker container
elseif !empty(glob(s:py3dynload_system))
python3 import sys; sys.path.append(vim.eval("expand(s:py3dynload_system)"))
elseif !empty(glob(s:py3dynload_system_old)) " lowest priority
python3 import sys; sys.path.append(vim.eval("expand(s:py3dynload_system_old)"))
else
echoerr "Homebrew's lib/python3.12/lib-dynload cannot be found"
endif
endif
endif
" Ruby {{{3
if s:os ==? 'Linux'
let s:ruby_linuxbrew_default = '/home/linuxbrew/.linuxbrew/bin/ruby'
let s:ruby_linuxbrew_local = $HOME . '/local_install/homebrew/bin/ruby'
if filereadable(s:ruby_linuxbrew_default)
let g:ruby_host_prog = s:ruby_linuxbrew_default
elseif filereadable(s:ruby_linuxbrew_local)
let g:ruby_host_prog = s:ruby_linuxbrew_local
endif
endif
" Other ------------------------------------------------------------------ {{{2
"
" save only opened windows and tabs with :mksession without any
" mapping/options/buffers/etc...
set sessionoptions=tabpages
" search path for gf and ^wf file jump commands
set path+=/usr/local/include,/opt/homebrew/include
" automatically reload file if it has been changed outside of Vim and it
" wasn't modified in Vim
set autoread
" project specific vim config file .exrc
"if getcwd().'/' =~ '^'.$HOME.'/\(prj\|prg/proj\)/'
" \ || getcwd().'/' =~ '^/Volumes/Projects/prg/proj'
" \ || getcwd().'/' =~ '^/Volumes/Projects/prj'
" set secure exrc
"endif
" Plugin options ========================================================= {{{1
" Airline ---------------------------------------------------------------- {{{2
"
" use PowerLine-style unicode symbols for markers
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.colnr = '⇒'
let g:airline_symbols.maxlinenr = ''
" do not draw separators for empty sections
let g:airline_skip_empty_sections = 1
" disable separators, leads to straight section borders
let g:airline_right_sep=''
let g:airline_left_sep=''
" skip default file encoding/format display
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
" enable airline for vim tabs
"let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#keymap#enabled = 0
" disable tmux status line theme sync
let g:airline#extensions#tmuxline#enabled = 0
" truncate long branch names to a fixed length >
"let g:airline#extensions#branch#displayed_head_limit = 10
" to truncate all path sections but the last one, e.g. a branch
" 'foo/bar/baz' becomes 'f/b/baz', use
let g:airline#extensions#branch#format = 2
" truncate sha1 commits at this number of characters >
let g:airline#extensions#branch#sha1_len = 12
" nvim uses treesitter context for this
if has('nvim')
let g:airline#extensions#tagbar#enabled = 0
endif
let g:airline#extensions#obsession#enabled = 1
" do not analyze and display mixed indent and trailing spaces
let g:airline#extensions#whitespace#enabled = 0
"let g:airline_theme='onedark'
let g:airline_theme_patch_func = 'MyAirlineThemePatch'
function! MyAirlineThemePatch(palette)
if g:airline_theme ==# 'dark'
let a:palette.normal.airline_a = [ '#00005f' , '#8a8a8a' , 17 , 245 ]
let a:palette.normal.airline_z = [ '#00005f' , '#8a8a8a' , 17 , 245 ]
endif
endfunction
" Ale -------------------------------------------------------------------- {{{2
"
let g:ale_enabled = has('nvim') ? 0 : 1
let g:airline#extensions#ale#enabled = 1
let g:ale_completion_enabled = 1
let g:ale_lsp_suggestions = 1
let g:ale_detail_to_floating_preview = 1
let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰']
let g:ale_floating_preview = 1
" ✗ ⚠ › • ‣ 🐞 ❽ ➇ ➣ ➢ ‼︎
let g:ale_sign_error = "‼︎"
let g:ale_sign_warning = "!"
let g:ale_linters_explicit = 1
let g:ale_linters = {
\ 'c': ['clangd'],
\ 'cpp': ['clangd'],
\ 'go': ['gopls'],
\ 'rust': ['rls']
\}
" disable linting for certain file types
let g:ale_pattern_options = {'\.min\.js$': {'ale_enabled': 0}}
let g:ale_cpp_clang_options = '-std=gnu++17 -Wall'
" Alternate -------------------------------------------------------------- {{{2
"
let g:alternateNoDefaultAlternate=0
let g:alternateRelativeFiles=1
"let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'
" auto-highlight --------------------------------------------------------- {{{2
"
let g:auto_highlight#disabled_on_start = 1
" Bash syntax ------------------------------------------------------------ {{{2
"
let g:is_bash = 1
let g:sh_fold_enabled= 1
" Clang_complete --------------------------------------------------------- {{{2
"
" default clang completion mapping is i_<C-x><C-u>
"let g:clang_complete_auto = 0
let g:clang_omnicppcomplete_compliance = 1
if s:os ==? 'Darwin'
let s:libclang_homebrew = '/opt/homebrew/opt/llvm/lib/libclang.dylib'
let s:libclang_clitools = '/Library/Developer/CommandLineTools/usr/lib/libclang.dylib'
if filereadable(s:libclang_homebrew)
let g:clang_library_path = s:libclang_homebrew
elseif filereadable(s:libclang_clitools)
let g:clang_library_path = s:libclang_clitools
else
echoerr 'libclang.so cannot be found'
endif
elseif s:os ==? 'Linux'
let s:libclang_local = $HOME . '/local_install/llvm/current/lib/libclang.so'
let s:libclang_homebrew = '/home/linuxbrew/.linuxbrew/opt/llvm/lib/libclang.so'
let s:libclang_nixos = substitute(system('printenv NIX_LIBCLANG'), "\n", '', '')
let s:libclang_usr_lib = '/usr/lib/llvm-19/lib/libclang.so.1'
let s:libclang_usr_lib_stable = '/usr/lib/llvm-18/lib/libclang.so.1'
if filereadable(s:libclang_local)
let g:clang_library_path = s:libclang_local
elseif filereadable(s:libclang_homebrew)
let g:clang_library_path = s:libclang_homebrew
elseif filereadable(s:libclang_nixos)
let g:clang_library_path = s:libclang_nixos
elseif filereadable(s:libclang_usr_lib)
let g:clang_library_path = s:libclang_usr_lib
elseif filereadable(s:libclang_usr_lib_stable)
let g:clang_library_path = s:libclang_usr_lib_stable
else
echoerr 'libclang.so cannot be found'
endif
endif
" Clang-format ----------------------------------------------------------- {{{2
let g:clang_format#detect_style_file = 1
augroup clang_format
autocmd!
autocmd FileType c,cpp,objc map <buffer><Leader>= <Plug>(operator-clang-format)
augroup END
" Cscope_quickfix -------------------------------------------------------- {{{2
"
let g:Cscope_OpenQuickfixWindow = 1
let g:Cscope_JumpError = 0
let g:Cscope_PopupMenu = 0
let g:Cscope_ToolsMenu = 0
" DirDiff ---------------------------------------------------------------- {{{2
"
let g:DirDiffEnableMappings = 1
" ignore whitespaces
let g:DirDiffAddArgs = '--ignore-all-space'
"let g:DirDiffExcludes = '/.git/*,.*.swp'
" Dispatch --------------------------------------------------------------- {{{2
let g:dispatch_no_maps = 1
" EasyMotion ------------------------------------------------------------- {{{2
"
"hi EasyMotionTarget cterm=bold ctermbg=NONE ctermfg=red
"hi EasyMotionShade cterm=NONE ctermbg=NONE ctermfg=darkgray
let g:EasyMotion_leader_key = '<Space><Space>'
" Editorconfig ----------------------------------------------------------- {{{2
"
let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
" Emmet ------------------------------------------------------------------ {{{2
"
"let g:user_emmet_leader_key = '<C-y>'
" enable emmet only for input and visual modes
"let g:user_emmet_mode='iv'
" enable only for some file types (see after/plugin/emmet.vim)
let g:user_emmet_install_global = 0
" File explorer ---------------------------------------------------------- {{{2
"
let g:netrw_altv = 1
" FZF -------------------------------------------------------------------- {{{2
"
let g:fzf_layout = { 'window': { 'width': 1, 'height': 0.6, 'yoffset': 1 } }
" GitGutter -------------------------------------------------------------- {{{2
"
let g:gitgutter_set_sign_backgrounds = 1
if has('nvim')
let g:gitgutter_enabled = 0
endif
" Gitv ------------------------------------------------------------------- {{{2
"
let g:Gitv_OpenHorizontal = 0
let g:Gitv_OpenPreviewOnLaunch = 0
let g:Gitv_WipeAllOnClose = 0
" GetLatestVimScripts ---------------------------------------------------- {{{2
"
let g:GetLatestVimScripts_allowautoinstall= 0
" Gundo ------------------------------------------------------------------ {{{2
"
let g:gundo_width = 75
"let g:gundo_preview_bottom = 1
let g:gundo_prefer_python3 = 1
" Javascript ------------------------------------------------------------- {{{2
"
" enable JDoc syntax highlighting
let g:javascript_plugin_jsdoc = 1
" enable Flow syntax highliting
let g:javascript_plugin_flow = 1
" Json ------------------------------------------------------------------- {{{2
"
let g:vim_json_syntax_conceal = 1
" Indent guides ---------------------------------------------------------- {{{2
"
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
"if g:colors_name == 'solarized' && !has("gui_running")
" let g:indent_guides_auto_colors = 0
" augroup indent_guides
" au!
" au VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=white
" au VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=gray
" augroup end
"endif
" Latex suite ------------------------------------------------------------ {{{2
"
let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_MultipleCompileFormats = 'pdf,dvi'
"let g:Tex_ViewRule_dvi = 'okular'
"let g:Tex_ViewRule_ps = 'okular'
"let g:Tex_ViewRule_pdf = 'acroread'
"let g:Tex_ViewRule_pdf = 'okular'
let g:Tex_CompileRule_pdf = 'xelatex -interaction=nonstopmode $*'
" Linux coding style ----------------------------------------------------- {{{2
"
" disable because we load it manually, via Bash alias
let g:loaded_linuxsty = 1
" LazyGit ---------------------------------------------------------------- {{{2
"
let g:lazygit_use_neovim_remote = 0
" NERDTree --------------------------------------------------------------- {{{2
"
let g:NERDTreeWinPos = 'right'
let g:NERDTreeHijackNetrw = 0
" store the bookmarks file in ~/.vim
"let NERDTreeBookmarksFile='~/.vim/NERDTreeBookmarks'
" show the bookmarks table on startup
"let NERDTreeShowBookmarks=1
" don't display these kinds of files
let g:NERDTreeIgnore=['\.o$', '\.lo$', '\.ko$', '\.a$', '\.so$']
"let NERDTreeIgnore=[ '\.ncb$', '\.suo$', '\.vcproj\.RIMNET', '\.obj$',
" \ '\.ilk$', '^BuildLog.htm$', '\.pdb$', '\.idb$',
" \ '\.embed\.manifest$', '\.embed\.manifest.res$',
" \ '\.intermediate\.manifest$', '^mt.dep$' ]
" Neo Tree --------------------------------------------------------------- {{{2
"
let g:neo_tree_remove_legacy_commands = 1
" Perl syntax ------------------------------------------------------------ {{{2
"
let g:perl_fold = 1
"let perl_fold_blocks = 1
" enable syntax highlighting for perl POD documentation
let g:perl_include_pod = 1
" Perl-local-lib-path ---------------------------------------------------- {{{2
"
"let g:perl_local_lib_path = 'lib'
"let g:perl_inc_path = system('perl -e "print join qq(,), @INC"')
"if !empty(g:perl_inc_path)
" let g:perl_local_lib_path = g:perl_local_lib_path .',' . g:perl_inc_path
"endif
"augroup perl_local_lib
" autocmd!
" autocmd! FileType perl PerlLocalLibPath
"augroup end
" Perl-support ----------------------------------------------------------- {{{2
"
let g:Perl_Ctrl_j = 'off'
" Perl6 / Raku ----------------------------------------------------------- {{{2
"
"let g:raku_unicode_abbrevs = 1
" quick-scope ------------------------------------------------------------ {{{2
"
" disabled by default, see plugin mappings
let g:qs_enable = 0
" R ------------------------------------------------------------------ {{{2
"
let g:vimrplugin_r_args = '--no-save --quiet'
let g:vimrplugin_term = 'xterm'
let g:vimrplugin_vimpager = 'horizontal'
let g:vimrplugin_screenplugin = 0
let g:vimrplugin_conqueplugin = 1
" disable the underscore replacement with <-
let g:vimrplugin_underscore = 0
" open .Rout files in a split window
let g:vimrplugin_notab = 1
" show list elements in object browser
"let vimrplugin_open_list = 1
" rsi -------------------------------------------------------------------- {{{2
"
" alt/meta mappings messing up macros execution (<F33>, ESC-p, M-p)
let g:rsi_no_meta = 1
" scratch ---------------------------------------------------------------- {{{2
"
let g:scratch_no_mappings = 1
let g:scratch_persistence_file = $HOME . '/.vim/scratch.txt'
let g:scratch_persistence_always = 1
let g:scratch_autohide = 1
let g:scratch_insert_autohide = 0
" Securemodeline --------------------------------------------------------- {{{2
"
let g:secure_modelines_verbose=1
" Startify --------------------------------------------------------------- {{{2
"
let g:startify_session_dir = '~/.vim/session'
let g:startify_change_to_dir = 0
let g:startify_fortune_use_unicode = 1
let g:startify_custom_header = [
\ ' __ __ __ ___ __ __',
\ ' /_/\ /_/\ /__/\ /__//_//_/\',
\ ' \:\ \\ \ \ \.:\ \ \::\| \| \ \',
\ ' \:\ \\ \ \ \::\ \ \:. \ \',
\ ' \:\_/.:\ \ \__\/_ \:.\-/\ \ \',
\ ' \ ..::/ / /__/\ \. \ \ \ \',
\ ' \___/_( \__\/ \__\/ \__\/',
\ ]
" Tagbar ----------------------------------------------------------------- {{{2
"
let g:tagbar_left = 1
let g:tagbar_width = 33
let g:tagbar_sort = 0
let g:tagbar_show_data_type = 1
"let g:tagbar_no_autocmds = 1
" Visual-Multi ----------------------------------------------------------- {{{2
"
"let g:VM_maps['Select Cursor Down'] = '<M-C-Down>'
"let g:VM_maps['Select Cursor Up'] = '<M-C-Up>'
"let g:VM_maps['Add Cursor Down'] = '<M-C-Down>'
"let g:VM_maps['Add Cursor Up'] = '<M-C-Up>'
" Xml -------------------------------------------------------------------- {{{2
"
let g:xml_syntax_folding = 1
" Yankstack -------------------------------------------------------------- {{{2
"
let g:yankstack_yank_keys = ['y', 'Y']
" Mappings =============================================================== {{{1
" disable default space behavior as right arrow
"noremap <Space> <Nop>
" duplicate space as leader
map <Space> <Leader>
" use space as leader
"let g:mapleader = "\<Space>"
" duplicate \ as leader
"map \ <Leader>
" Shortened commands ----------------------------------------------------- {{{2
"
" let yankstack plugin to know that we remap default Y behavior
" (it has to be done *before* re-defining Y mapping)
if exists('g:yankstack_size')
call yankstack#setup()
endif
" make 'Y' to be more consistent with 'D','C','S'
nmap Y y$
" search of selected text in visual mode
vmap * y/<C-R>"<CR>
vmap # y?<C-R>"<CR>
" quit all windows (by analogy with ZZ and ZQ)
nmap ZA :qa<CR>
" don't jump to the next occurrence of the word, but just highlight it
nnoremap * *N
nnoremap g* g*N
nnoremap # #N
nnoremap g# g#N
" a better incremental search
"map g/ <Plug>(incsearch-forward)
"map g? <Plug>(incsearch-backward)
" Highlight all instances of the current word under the cursor
"nmap <silent> ^ :setl hls<CR>:let @/="<C-r><C-w>"<CR>
" Shift mappings --------------------------------------------------------- {{{2
"
" Ctrl mappings ---------------------------------------------------------- {{{2
"
" ALE
if g:ale_enabled
imap <C-Space> <Plug>(ale_complete)
endif
" Yankstack
if exists('g:yankstack_size')
" TODO: change P to p
nmap <C-P> <Plug>yankstack_substitute_older_paste
endif
" map CTRL-s to do what ',' used to do
nnoremap <C-s> ,
vnoremap <C-s> ,
" Tagselect
" open current file in new tab and do :Tselect on a word under cursor
"nmap <C-t>] :tab split<CR>:exec("Ts ".expand("<cword>"))<CR>
nnoremap <silent> <C-W>g<C-]> :tab split<CR>:exec("Ts ".expand("<cword>"))<CR>
" move current line up/down
"nmap <C-Up> :m-2
"nmap <C-Down> :m+
" switch <C-e> between original vim behavior and emacs-like EOL
" see after/plugin/rsi.vim for <C-e> mapping
inoremap <C-z> <C-o>:call MyToggle_i_Ctrl_e()<CR>
" Maps to make handling windows a bit easier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {{{3
"
" switch window with full expand
" TODO: change to lowercase
nnoremap <C-J> <C-W>j<C-W>_
nnoremap <C-K> <C-W>k<C-W>_
nnoremap <C-H> <C-W>h<C-W>\|
nnoremap <C-L> <C-W>l<C-W>\|
" adjust window size by one
nnoremap <silent> <C-Left> <C-W><
nnoremap <silent> <C-Up> <C-W>+
nnoremap <silent> <C-Down> <C-W>-
nnoremap <silent> <C-Right> <C-W>>
" Alt mappings ----------------------------------------------------------- {{{2
"
" intro to Alt keys mapping in vim :h :map-alt-keys
" map Alt-key combinations to escape codes (this is required because all major
" terminals use escape codes for Alt- combinations instead of setting 8th bit
" as vim expects by default)
" these M-hjkl mappings are disabled cause they cause problems with macros
" for some key combinations, like ESC-j, which turns into ê
" we need :exectue here to substitue \e with the actual escape code
"execute "set <M-h>=\eh"
"execute "set <M-j>=\ej"
"execute "set <M-k>=\ek"
"execute "set <M-l>=\el"
" adjust window size (MacOS)
"nnoremap <silent> <M-h> <C-W><
"nnoremap <silent> <M-j> <C-W>+
"nnoremap <silent> <M-k> <C-W>-
"nnoremap <silent> <M-l> <C-W>>
" adjust window size by five
"noremap <silent> <M-Left> :vertical resize -5<CR>
"noremap <silent> <M-Up> :resize +5<CR>
"noremap <silent> <M-Down> :resize -5<CR>
"noremap <silent> <M-Right> :vertical resize +5<CR>
" switch between tabs
noremap <silent> <M-Up> :tabprev<CR>
noremap <silent> <M-Down> :tabnext<CR>