-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
1071 lines (907 loc) · 28.5 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
"""""""""""
" VIMRC "
"""""""""""
if !filereadable($HOME . '/.vim/autoload/plug.vim')
silent !mkdir -p ~/.vim/autoload >/dev/null 2>&1
silent !mkdir -p ~/.vim/plugged >/dev/null 2>&1
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
\ >/dev/null 2>&1
autocmd VimEnter * PlugInstall
endif
"""""""""""""
" PLUGINS "
"""""""""""""
call plug#begin('~/.vim/plugged')
" If fzf is not available in the package manager
"Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" If fzf is installed through the package manager
Plug '/usr/bin/fzf'
" General
"Plug 'junegunn/fzf.vim'
Plug 'alfunx/fzf.vim' " fork
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
"Plug 'tpope/vim-sensible'
Plug 'tpope/vim-git'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-endwise'
"Plug 'tpope/vim-commentary'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/vim-peekaboo'
Plug 'easymotion/vim-easymotion'
Plug 'haya14busa/incsearch.vim'
Plug 'haya14busa/incsearch-easymotion.vim'
Plug 'mhinz/vim-grepper'
Plug 'terryma/vim-multiple-cursors'
"Plug 'terryma/vim-expand-region'
Plug 'jiangmiao/auto-pairs'
"Plug 'Raimondi/delimitMate'
Plug 'mbbill/undotree'
"Plug 'christoomey/vim-titlecase'
Plug 'tomtom/tcomment_vim'
Plug 'ap/vim-css-color'
"Plug 'jceb/vim-orgmode'
Plug 'xtal8/traces.vim'
Plug 'chrisbra/NrrwRgn'
"Plug 'kopischke/vim-fetch'
Plug 'w0rp/ale'
"Plug 'ludovicchabant/vim-gutentags'
" Text objects
Plug 'wellle/targets.vim'
Plug 'junegunn/vim-after-object'
"Plug 'michaeljsmith/vim-indent-object'
Plug 'alfunx/vim-indent-object' " fork
Plug 'kana/vim-textobj-user'
"Plug 'kana/vim-textobj-entire'
Plug 'Julian/vim-textobj-variable-segment'
" Completion
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
" Tmux
Plug 'benmills/vimux'
Plug 'christoomey/vim-tmux-navigator'
Plug 'wellle/tmux-complete.vim'
" Snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" " Language server
" Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
" Language specific
Plug 'editorconfig/editorconfig-vim'
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'lervag/vimtex', { 'for': ['latex', 'tex'] }
Plug 'racer-rust/vim-racer', { 'for': 'rust' }
Plug 'zchee/deoplete-clang'
" Themes
"Plug 'morhetz/gruvbox'
Plug 'alfunx/gruvbox' " fork
" Don't load in console
if &term !=? 'linux' || has('gui_running')
Plug 'vim-airline/vim-airline'
endif
call plug#end()
runtime ftplugin/man.vim
runtime ftplugin/vim.vim
runtime ftplugin/help.vim
runtime macros/matchit.vim
""""""""""""""""""
" KEY MAPPINGS "
""""""""""""""""""
"" Leader key
nnoremap <Space> <Nop>
nnoremap <CR> <Nop>
let mapleader=' '
let maplocalleader=''
"" Split navigation
"nnoremap <C-h> <C-w><C-h>
"nnoremap <C-j> <C-w><C-j>
"nnoremap <C-k> <C-w><C-k>
"nnoremap <C-l> <C-w><C-l>
"" Split navigation (vim-tmux-navigator)
let g:tmux_navigator_no_mappings=1
nnoremap <silent> <C-h> :TmuxNavigateLeft<CR>
nnoremap <silent> <C-j> :TmuxNavigateDown<CR>
nnoremap <silent> <C-k> :TmuxNavigateUp<CR>
nnoremap <silent> <C-l> :TmuxNavigateRight<CR>
nnoremap <silent> <C-BS> :TmuxNavigatePrevious<CR>
"" Split resize
nnoremap <silent> <C-w>h 5<C-w><
nnoremap <silent> <C-w>j 5<C-w>-
nnoremap <silent> <C-w>k 5<C-w>+
nnoremap <silent> <C-w>l 5<C-w>>
"" New tab
nnoremap <silent> <C-w>t :tabedit<CR>
nnoremap <silent> <C-w><C-t> :tabedit<CR>
"" Tab navigation
nnoremap <silent> <C-w><C-h> :tabprevious<CR>
nnoremap <silent> <C-w><C-l> :tabnext<CR>
"" Fullscreen
nnoremap <silent> <C-w>F <C-w>_<C-w><Bar>
"nnoremap <silent> <Home> <C-w><
"nnoremap <silent> <PageDown> <C-w>-
"nnoremap <silent> <PageUp> <C-w>+
"nnoremap <silent> <End> <C-w>>
"augroup Quickfix
" autocmd!
" autocmd QuickFixCmdPost [^l]* cwindow
" autocmd QuickFixCmdPost l* lwindow
"augroup END
" German keyboard mappings
nmap ä ^
xmap ä ^
omap ä ^
nmap ö "
xmap ö "
omap ö "
nmap ü [
xmap ü [
omap ü [
nmap ¨ ]
xmap ¨ ]
omap ¨ ]
nnoremap è <C-]>
xnoremap è <C-]>
execute "set <M-h>=\<Esc>h"
execute "set <M-j>=\<Esc>j"
execute "set <M-k>=\<Esc>k"
execute "set <M-l>=\<Esc>l"
nnoremap <M-j> }
xnoremap <M-j> }
onoremap <M-j> }
nnoremap <M-k> {
xnoremap <M-k> {
onoremap <M-k> {
" Make Y behave like other commands
nnoremap Y y$
" Copy to system clipboard
nnoremap gy "+y
nnoremap gp "+p
xnoremap gy "+y
xnoremap gp "+p
" Keep selection after indenting
xnoremap < <gv
xnoremap > >gv
" Swap lines
xnoremap <leader>j :m '>+1<CR>gv=gv
xnoremap <leader>k :m '<-2<CR>gv=gv
nnoremap <leader>j :m .+1<CR>
nnoremap <leader>k :m .-2<CR>
" Use CTRL-S for saving, also in Insert mode
nnoremap <silent> <C-s> :write<CR>
xnoremap <silent> <C-s> <Esc>:write<CR>
inoremap <silent> <C-s> <C-o>:write<CR><Esc>
"" Quickfix & Loclist
nnoremap <silent> <leader>q :copen<CR>
nnoremap <silent> <leader>l :lopen<CR>
"" Insert mode mappings
inoremap <C-u> <C-g>u<C-u>
inoremap àà <C-o>O
inoremap éé <C-o>o
" Select last inserted text
nnoremap gV `[v`]
" Move cursor by dipslay lines when wrapping
nnoremap <expr> j v:count ? 'j' : 'gj'
nnoremap <expr> k v:count ? 'k' : 'gk'
xnoremap <expr> j v:count ? 'j' : 'gj'
xnoremap <expr> k v:count ? 'k' : 'gk'
" Go to tab
execute "set <M-1>=\<Esc>1"
execute "set <M-2>=\<Esc>2"
execute "set <M-3>=\<Esc>3"
execute "set <M-4>=\<Esc>4"
execute "set <M-5>=\<Esc>5"
execute "set <M-6>=\<Esc>6"
execute "set <M-7>=\<Esc>7"
execute "set <M-8>=\<Esc>8"
execute "set <M-9>=\<Esc>9"
nnoremap <M-1> 1gt
nnoremap <M-2> 2gt
nnoremap <M-3> 3gt
nnoremap <M-4> 4gt
nnoremap <M-5> 5gt
nnoremap <M-6> 6gt
nnoremap <M-7> 7gt
nnoremap <M-8> 8gt
nnoremap <M-9> :tablast<CR>
" Magic regex search
noremap <leader>/ /\v
noremap <leader>? ?\v
set wildchar=<Tab>
set wildcharm=<Tab>
cnoremap <expr> <Tab> getcmdtype() =~ '[?/]' ? '<C-g>' : '<Tab>'
cnoremap <expr> <S-Tab> getcmdtype() =~ '[?/]' ? '<C-t>' : feedkeys('<S-Tab>', 'int')[1]
" Remove trailing whitespaces
nnoremap <silent> <F3> mz:keepp %s/\\\@1<!\s\+$//e<CR>`z
" Make
nnoremap <F5> :make!<CR>
" Allow saving of files as sudo
command! W execute 'silent! w !sudo /usr/bin/tee % >/dev/null' <bar> edit!
" Set path to current file
command! -bang -nargs=* Cd cd %:p:h
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
" Run macro on visual selection
function! ExecuteMacroOverVisualRange()
echo "@".getcmdline()
execute ":'<,'>normal @".nr2char(getchar())
endfunction
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
" Run last macro
nnoremap Q @@
" No highlight
execute "set <M-b>=\<Esc>b"
nnoremap <silent> <M-b> :<C-u>nohlsearch<CR>
" Change register
function! ChangeReg() abort
let x = nr2char(getchar())
call feedkeys("q:ilet @" . x . " = \<c-r>\<c-r>=string(@" . x . ")\<CR>\<esc>$", 'n')
endfunction
nnoremap cr :call ChangeReg()<CR>
" Diff update
nnoremap <silent> du :windo diffupdate<CR>
"""""""""""""""""""""
" PLUGIN SETTINGS "
"""""""""""""""""""""
" Default key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
let g:fzf_layout = { 'down': '~30%' }
" Customize the options used by 'git log'
let g:fzf_commits_log_options='--graph --color=always --format="%c(auto)%h%d %s %c(black)%c(bold)%cr"'
" Command to generate tags file
let g:fzf_tags_command = 'ctags -R'
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
"imap <leader><tab> <plug>(fzf-maps-i)
"" FZF
nnoremap <leader>f :Files<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>w :Windows<CR>
nnoremap <leader>t :Tags<CR>
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
" Use custom dictionary
inoremap <expr> <c-x><c-k> fzf#complete('cat /usr/share/dict/words-insane')
"" RG
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --hidden --line-number --column --no-heading --smart-case --follow --color=always --colors="match:none" --colors="path:fg:white" --colors="line:fg:white" '.shellescape(<q-args>), 1,
\ <bang>0)
"" AG
command! -bang -nargs=* Ag
\ call fzf#vim#ag(
\ <q-args>, '--color-path "0;37" --color-line-number "0;37" --color-match "" --hidden --smart-case --follow',
\ <bang>0)
if executable('rg')
augroup Rg
autocmd!
autocmd VimEnter * nnoremap <Leader>r :Rg<CR>
augroup End
elseif executable('ag')
augroup Ag
autocmd!
autocmd VimEnter * nnoremap <Leader>r :Ag<CR>
augroup End
endif
if executable('rg')
set grepprg=rg\ --smart-case\ --vimgrep
set grepformat^=%f:%l:%c:%m
elseif executable('ag')
set grepprg=ag\ --smart-case\ --vimgrep
set grepformat^=%f:%l:%c:%m
endif
"" Grepper
let g:grepper={}
let g:grepper.tools=[]
if executable('rg')
let g:grepper.tools+=['rg']
elseif executable('ag')
let g:grepper.tools+=['ag']
endif
let g:grepper.tools+=['git', 'grep']
let g:grepper.rg = {
\ 'grepprg': 'rg --vimgrep',
\ 'grepformat': '%f:%l:%c:%m',
\ 'escape': '\^$.*+?()[]{}|'
\ }
let g:grepper.next_tool='<C-g>'
let g:grepper.jump=0
let g:grepper.quickfix=1
let g:grepper.dir='repo,cwd'
let g:grepper.stop=5000
nnoremap <leader>s :Grepper -tool rg<CR>
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
command! Todo :Grepper -tool rg -query '(TODO|FIXME|BUG)'
command! Note :Grepper -tool rg -query '(NOTE)'
"" Airline
if !exists('g:airline_symbols')
let g:airline_symbols={}
endif
""" Unicode symbols
let g:airline_left_alt_sep='»'
let g:airline_left_sep='▶'
let g:airline_right_alt_sep='«'
let g:airline_right_sep='◀'
let g:airline_symbols.crypt='🔒'
let g:airline_symbols.linenr='☰'
let g:airline_symbols.linenr='␊'
let g:airline_symbols.linenr=''
let g:airline_symbols.linenr='¶'
let g:airline_symbols.maxlinenr=''
let g:airline_symbols.branch='⎇'
let g:airline_symbols.paste='ρ'
let g:airline_symbols.paste='Þ'
let g:airline_symbols.paste='∥'
let g:airline_symbols.spell='Ꞩ'
let g:airline_symbols.notexists='∄'
let g:airline_symbols.whitespace='Ξ'
""" Powerline
let g:airline_left_sep=''
let g:airline_left_alt_sep=''
let g:airline_right_sep=''
let g:airline_right_alt_sep=''
" """ Straight ▌ │ ▐ │ or ▌ ▏ ▐ ▕
" let g:airline_left_sep='▌'
" let g:airline_left_alt_sep='│'
" let g:airline_right_sep='▐'
" let g:airline_right_alt_sep='│'
""" Powerline symbols
let g:airline_symbols.branch=''
let g:airline_symbols.readonly=''
let g:airline_symbols.linenr='☰'
let g:airline_symbols.maxlinenr=''
""" Airline settings
let g:airline_theme='gruvbox'
let g:airline#extensions#whitespace#mixed_indent_algo=1
let g:airline_powerline_fonts=1
let g:airline_skip_empty_sections=0
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#buffer_idx_mode=1
let g:airline#extensions#tabline#tab_nr_type=1
let g:airline#extensions#tabline#show_tab_nr=0
let g:airline#extensions#tabline#show_close_button=0
let g:airline#extensions#tabline#exclude_preview=1
let g:airline#extensions#tabline#fnamecollapse=1
let g:airline#extensions#tabline#fnamemod=':~:.'
let g:airline#extensions#tabline#buffers_label='buffers'
let g:airline#extensions#tabline#tabs_label='tabs'
let g:airline#extensions#tabline#overflow_marker='…'
let g:airline_section_z='%3p%% %3l:%-2v'
" let g:airline_mode_map = {
" \ '__' : ' - ',
" \ 'n' : ' N ',
" \ 'i' : ' I ',
" \ 'R' : ' R ',
" \ 'c' : ' C ',
" \ 'v' : ' V ',
" \ 'V' : 'V-L',
" \ '' : 'V-B',
" \ 's' : ' S ',
" \ 'S' : ' S ',
" \ '' : ' S ',
" \ }
""" Airline extensions
let g:airline#extensions#ale#error_symbol=''
let g:airline#extensions#ale#warning_symbol=''
let g:airline#extensions#ale#show_line_numbers=0
let g:airline#extensions#whitespace#show_message=1
let g:airline#extensions#hunks#enabled=0
"" GitGutter
nmap <Leader>ha <Plug>GitGutterStageHunk
nmap <Leader>hu <Plug>GitGutterUndoHunk
nmap ]c <Plug>GitGutterNextHunk
nmap [c <Plug>GitGutterPrevHunk
let g:gitgutter_sign_added='┃'
let g:gitgutter_sign_modified='┃'
let g:gitgutter_sign_removed='◢'
let g:gitgutter_sign_removed_first_line='◥'
let g:gitgutter_sign_modified_removed='◢'
"" EasyMotion
"let g:EasyMotion_do_mapping=0 " Disable default mappings
let g:EasyMotion_smartcase=1 " Turn on case insensitive feature
let g:EasyMotion_keys='asdghklqwertyuiopzxcvbnmfj,'
"nmap s <Plug>(easymotion-overwin-f)
nmap s <Plug>(easymotion-overwin-f2)
"map <Leader>j <Plug>(easymotion-j)
"map <Leader>k <Plug>(easymotion-k)
"" Incsearch
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
let g:incsearch#magic='\v'
let g:incsearch#smart_backward_word=1
let g:incsearch#consistent_n_direction=1
let g:incsearch#auto_nohlsearch=0
let g:incsearch#no_inc_hlsearch=1
let g:incsearch#highlight={
\ 'match' : {
\ 'priority' : '10'
\ },
\ 'on_cursor' : {
\ 'priority' : '100'
\ },
\ 'cursor' : {
\ 'group' : 'ErrorMsg',
\ 'priority' : '1000'
\ }
\ }
"" Incsearch-EasyMotion
map z/ <Plug>(incsearch-easymotion-/)
map z? <Plug>(incsearch-easymotion-?)
"map zg/ <Plug>(incsearch-easymotion-stay)
"" Netrw
let g:netrw_liststyle=0
let g:netrw_preview=1
"" EasyAlign
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
"" Undotree
nnoremap <F4> :UndotreeToggle<CR>
" "" Titlecase
" let g:titlecase_map_keys=0
" nmap gwt <Plug>Titlecase
" xmap gwt <Plug>Titlecase
" nmap gwT <Plug>TitlecaseLine
"" After text object
augroup AfterTextObject
autocmd!
autocmd VimEnter * call after_object#enable(['n', 'nn'], '=', ':', '+', '-', '*', '/', '#', ' ')
augroup End
"" Vimtex
let g:vimtex_view_method='zathura'
"" UltiSnips
let g:UltiSnipsExpandTrigger='<tab>'
let g:UltiSnipsJumpForwardTrigger='<c-b>'
let g:UltiSnipsJumpBackwardTrigger='<c-z>'
"" Multiple-Cursors
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
let g:multi_cursor_start_key='<C-n>'
let g:multi_cursor_start_word_key='g<C-n>'
let g:multi_cursor_exit_from_visual_mode=0
let g:multi_cursor_exit_from_insert_mode=0
"" Goyo + Limelight
let g:goyo_width=83
function! s:goyo_enter()
set nolist
set noshowmode
set noshowcmd
set scrolloff=999
set sidescrolloff=0
"Limelight
endfunction
function! s:goyo_leave()
set list
set noshowmode
set showcmd
set scrolloff=3
set sidescrolloff=5
"Limelight!
endfunction
augroup Goyo
autocmd!
autocmd User GoyoEnter nested call <SID>goyo_enter()
autocmd User GoyoLeave nested call <SID>goyo_leave()
augroup END
"" Vimux
let g:VimuxUseNearest=1
function! VimuxSlime()
call VimuxOpenRunner()
call VimuxSendText(@v)
endfunction
function! SendToTmuxSplit(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
if a:0 " Invoked from Visual mode, use gv command.
silent exe "normal! gv\"vy"
elseif a:type == 'line'
silent exe "normal! '[V']\"vy"
else
silent exe "normal! `[v`]\"vy"
endif
call VimuxSlime()
silent exe "normal! `v"
let &selection = sel_save
let @@ = reg_save
endfunction
nnoremap <silent> _ mv:set opfunc=SendToTmuxSplit<CR>g@
vnoremap <silent> _ mv:<C-U>call SendToTmuxSplit(visualmode(), 1)<CR>
"" Ale
" Using special space: U+2000 (EN QUAD)
let g:ale_set_loclist=1
let g:ale_sign_error=' ●'
let g:ale_sign_warning=' ●'
let g:ale_lint_on_text_changed='never'
let g:ale_lint_on_enter=1
let g:ale_lint_on_save=1
let g:ale_lint_on_filetype_changed=1
let g:ale_set_highlights=1
let g:ale_set_signs=1
nmap [w <plug>(ale_previous_wrap)
nmap ]w <plug>(ale_next_wrap)
nnoremap <leader>a :ALEEnable<CR>
augroup Ale
autocmd!
autocmd VimEnter * ALEDisable
augroup END
"" AutoPairs
execute "set <M-p>=\<Esc>p"
execute "set <M-b>=\<Esc>b"
"let g:AutoPairsMapSpace=0
"" RustRacer
let g:racer_cmd="/usr/bin/racer"
let g:racer_experimental_completer=1
"" Deoplete
let g:deoplete#enable_at_startup=1
let g:deoplete#sources#clang#libclang_path='/usr/lib/rstudio/bin/rsclang/libclang.so'
let g:deoplete#sources#clang#clang_header='/usr/lib/rstudio/resources/libclang'
" "" LanguageClient
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['rustup', 'run', 'nightly', 'rls'],
" \ 'c': ['cquery'],
" \ 'javascript': ['/opt/javascript-typescript-langserver/lib/language-server-stdio.js'],
" \ }
"
" " Automatically start language servers.
" let g:LanguageClient_autoStart=1
"
"nnoremap <silent> K :call LanguageClient_textDocument_hover()<CR>
"nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>
"nnoremap <silent> <F6> :call LanguageClient_textDocument_rename()<CR>
"" Unimpaired
let g:nremap={"[": "ü", "]": "¨"}
let g:xremap={"[": "ü", "]": "¨"}
let g:oremap={"[": "ü", "]": "¨"}
"" Vim RSI
let g:rsi_no_meta=1
""""""""""""""""
" APPEARANCE "
""""""""""""""""
"" UI config
"syntax enable
set synmaxcol=800
set number
set showcmd
set hidden
set wildmenu " shows autocomplete in commandline
set wildmode=longest:full,full
set completeopt=menuone,longest,preview
set lazyredraw
set mouse=a
set cursorline " horizontal line
"set colorcolumn=81 " vertical line
set textwidth=80
set wrapmargin=0 " turns off automatic newlines
set nowrap " line wrapping off
set showmatch " show matching brackets
set mat=5 " bracket blinking
set list
augroup TransparentBackground
autocmd!
autocmd ColorScheme * highlight Normal guibg=NONE ctermbg=NONE
augroup END
augroup LighterCursorLine
autocmd!
"autocmd ColorScheme * highlight clear CursorLine
"autocmd ColorScheme * highlight CursorLine guibg=#32302f
autocmd ColorScheme * if &background == "dark" | highlight CursorLine guibg=#32302f | else | highlight CursorLine guibg=#f2e5bc | endif
augroup END
augroup BoldCursorLineNr
autocmd!
"autocmd ColorScheme * highlight CursorLineNR cterm=bold guibg=#282828
autocmd ColorScheme * if &background == "dark" | highlight CursorLineNR cterm=bold guibg=#32302f | else | highlight CursorLineNR cterm=bold guibg=#f2e5bc | endif
augroup END
augroup LighterQuickFixLine
autocmd!
"autocmd ColorScheme * highlight QuickFixLine ctermbg=Yellow guibg=#504945
"autocmd ColorScheme * highlight qfFileName guifg=#fe8019
autocmd ColorScheme * if &background == "dark" | highlight QuickFixLine ctermbg=Yellow guibg=#504945 | else | highlight QuickFixLine ctermbg=Yellow guibg=#d5c4a1 | endif
autocmd ColorScheme * if &background == "dark" | highlight qfFileName guifg=#fe8019 | else | highlight qfFileName guifg=#af3a03 | endif
augroup END
augroup SearchHighlightColor
autocmd!
"autocmd ColorScheme * highlight Search guibg=#282828 guifg=#fe8019
autocmd ColorScheme * if &background == "dark" | highlight Search guibg=#282828 guifg=#fe8019 | else | highlight Search guibg=#fbf1c7 guifg=#af3a03 | endif
augroup END
""" Color VCS conflict markers
augroup VCSConflictMarker
autocmd!
"autocmd ColorScheme * highlight VCSConflict guibg=#cc241d guifg=#282828
autocmd ColorScheme * if &background == "dark" | highlight VCSConflict guibg=#cc241d guifg=#282828 | else | highlight VCSConflict guibg=#cc241d guifg=#fbf1c7 | endif
autocmd BufEnter,WinEnter * match VCSConflict '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
augroup END
" """ Color overlength
" augroup OverLength
" autocmd!
" "autocmd ColorScheme * highlight OverLength guibg=#cc241d guifg=#282828
" autocmd ColorScheme * if &background == "dark" | highlight OverLength guibg=#cc241d guifg=#282828 | else | highlight OverLength guibg=#cc241d guifg=#fbf1c7 | endif
" "autocmd BufEnter,WinEnter * match OverLength /\%81v./
" "autocmd BufEnter,WinEnter * match OverLength /\%>80v.\+/
" let collumnLimit=80
" let pattern='\%' . (collumnLimit+1) . 'v.'
" autocmd BufEnter,WinEnter *
" \ let w:m1=matchadd('OverLength', pattern, -1)
" augroup END
augroup RefreshAirline
autocmd!
autocmd ColorScheme * if exists(':AirlineRefresh') | :AirlineRefresh | endif
augroup END
augroup SpellBadUnderline
autocmd!
autocmd BufEnter,WinEnter * highlight SpellBad gui=underline term=underline cterm=underline
augroup END
if &term !=? 'linux' || has('gui_running')
set listchars=tab:▸\ ,extends:>,precedes:<,nbsp:˷,eol:⤶,trail:~
set fillchars=vert:│,fold:─,diff:-
augroup TrailingSpaces
autocmd!
autocmd InsertEnter * set listchars-=eol:⤶,trail:~
autocmd InsertLeave * set listchars+=eol:⤶,trail:~
augroup END
else
set listchars=tab:>\ ,extends:>,precedes:<,nbsp:+,eol:$,trail:~
set fillchars=vert:\|,fold:-,diff:-
augroup TrailingSpaces
autocmd!
autocmd InsertEnter * set listchars-=eol:$,trail:~
autocmd InsertLeave * set listchars+=eol:$,trail:~
augroup END
endif
set novisualbell " no blinking
set noerrorbells " no noise
set display=lastline
set laststatus=2 " always show status line
set showtabline=2 " always show tab line
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
"" Tabs
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" function! ExpandSpaces()
" set tabstop=2
" set noexpandtab
" '<,'>retab!
" set tabstop=4
" set expandtab
" '<,'>retab
" endfunction
" nnoremap <leader>i :call ExpandSpaces()<CR>
"" Spaces, indents
set encoding=utf-8
set smarttab
set autoindent
"filetype plugin indent on
set linespace=0
set scrolloff=3
set sidescrolloff=5
set backspace=indent,eol,start " backspace over everything in insert mode
set formatoptions+=roj
set nrformats-=octal
set pastetoggle=<F2>
set notimeout
set ttimeout
set ttimeoutlen=100
set updatetime=100
if filereadable('/bin/zsh')
set shell=/bin/zsh\ --login
endif
"" Searching
set incsearch
set hlsearch
set ignorecase
set smartcase
"" Folding
set foldenable
set foldmethod=indent
set foldnestmax=100
augroup CustomFolding
autocmd!
autocmd BufWinEnter * let &foldlevel=max(add(map(range(1, line('$')), 'foldlevel(v:val)'), 10)) " with this, everything is unfolded at start
augroup End
"set clipboard+=unnamed " yanks go on clipboard instead.
set history=10000 " Number of things to remember in history.
set tabpagemax=50
set autoread
set autowrite
set ruler
set nostartofline
set nohidden
set nojoinspaces
set sessionoptions-=options
function! NeatFoldText()
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '┤ ' . printf("%10s", lines_count . ' lines') . ' ├'
let foldchar = matchstr(&fillchars, 'fold:\zs.')
let foldtextstart = strpart('+ ' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
let foldtextend = lines_count_text . repeat(foldchar, 8)
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
endfunction
set foldtext=NeatFoldText()
"" Last position
set viminfo='10,\"100,:20,%,n~/.viminfo
augroup SavePosition
autocmd!
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | execute 'normal! g`"zvzz' | endif
augroup END
"" Dictionary
set dictionary+=/usr/share/dict/words-insane
"" Theme and colors
set termguicolors
set background=dark
let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
"set t_Co=256
let g:gruvbox_bold=1
let g:gruvbox_italic=1
let g:gruvbox_underline=1
let g:gruvbox_undercurl=1
"" Use environment variable
if !empty($VIM_COLOR)
silent! colorscheme $VIM_COLOR
else
silent! colorscheme gruvbox
endif
"" GUI options
set guifont=Iosevka\ Custom
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
"" Switch cursor according to mode
if &term !=? 'linux' || has('gui_running')
let &t_SI="\<Esc>[6 q"
let &t_SR="\<Esc>[4 q"
let &t_EI="\<Esc>[2 q"
" let &t_ue="\<Esc>[4:0m"
" let &t_us="\<Esc>[4:1m"
" let &t_Ce="\<Esc>[4:0m"
" let &t_Cs="\<Esc>[4:3m"
endif
""" TODO Disable highlighting on re-source (bug)
nohlsearch
""""""""""""""
" FILETYPE "
""""""""""""""
augroup QFAdjustWindowHeight
autocmd FileType qf call AdjustWindowHeight(3, 10)
augroup END
function! AdjustWindowHeight(minheight, maxheight)
let l = 1
let n_lines = 0
let w_width = winwidth(0)
while l <= line('$')
" number to float for division
let l_len = strlen(getline(l)) + 0.0
let line_width = l_len/w_width
let n_lines += float2nr(ceil(line_width))
let l += 1
endw
exe max([min([n_lines, a:maxheight]), a:minheight]) . "wincmd _"
endfunction
""""""""""""""""""""""""""
" BACKUP / SWAP / UNDO "
""""""""""""""""""""""""""
if !isdirectory($HOME . '/.vim/.backup')
silent !mkdir -p ~/.vim/.backup >/dev/null 2>&1
endif
set backupdir-=.
set backupdir+=.
set backupdir-=~/
set backupdir^=~/.vim/.backup/
set backupdir^=./.vim-backup/
set backup
if !isdirectory($HOME . '/.vim/.swap')
silent !mkdir -p ~/.vim/.swap >/dev/null 2>&1
endif
set directory=./.vim-swap//
set directory+=~/.vim/.swap//
set directory+=~/.tmp//
set directory+=.
if exists('+undofile')
if !isdirectory($HOME . '/.vim/.undo')
silent !mkdir -p ~/.vim/.undo >/dev/null 2>&1
endif
set undodir=./.vim-undo//
set undodir+=~/.vim/.undo//
set undofile
endif
"""""""""""""""""""
" VIMRC FOLDING "
"""""""""""""""""""