-
Notifications
You must be signed in to change notification settings - Fork 1
/
vim-vimrc
865 lines (707 loc) · 24.3 KB
/
vim-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
if !has('win32') && empty(glob('~/.vim/autoload/plug.vim'))"{{{
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
if !has('win32') && !has('nvim')
" set term=screen-256color
" set t_Co=256
set term=rxvt-unicode-256color
endif
let mapleader = " "
nmap <expr> <bslash> mapleader
let g:polyglot_disabled = ['markdown', 'bib']
call plug#begin('~/.vim/bundle')
Plug 'junegunn/vim-plug'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'junegunn/vim-peekaboo'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-easy-align'
" Plug 'tommcdo/vim-lion'
" From the pope.
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-capslock'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-repeat'
" Plug 'tpope/vim-scriptease'
Plug 'tpope/vim-ragtag', { 'for': ['html', 'htmldjango'] }
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-abolish'
" tbone? (tmux stuff)
Plug 'romainl/vim-cool'
Plug 'jiangmiao/auto-pairs'
" Visual
Plug 'luochen1990/rainbow'
" , { 'on': 'LoadRainbow' }
" Plug 'Yggdroot/indentLine'
" Plug 'nathanaelkane/vim-indent-guides'
Plug 'NLKNguyen/papercolor-theme'
Plug 'machakann/vim-highlightedyank'
" Plug 'vim-scripts/guifontpp.vim'
" Plug 'RyanMcG/vim-guifontzoom'
" Plug 'schmich/vim-guifont'
" Text objects:
Plug 'wellle/targets.vim'
Plug 'aldantas/vim-custom-surround'
Plug 'chaoren/vim-wordmotion'
Plug 'michaeljsmith/vim-indent-object'
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-entire'
Plug 'saaguero/vim-textobj-pastedtext'
Plug 'christoomey/vim-titlecase'
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'tommcdo/vim-express'
" Other stuff
Plug 'rhysd/vim-grammarous'
" Snips
" Plug 'SirVer/ultisnips'
" Plug 'honza/vim-snippets'
Plug 'rhysd/clever-f.vim'
Plug 'vim-scripts/ReplaceWithRegister'
Plug 'tmux-plugins/vim-tmux'
Plug 'mhinz/vim-grepper'
" flygrep?
Plug 'Houl/repmo-vim'
Plug 'machakann/vim-swap'
" Language specific stuff.
Plug 'sheerun/vim-polyglot'
" General (linters)
Plug 'w0rp/ale'
" WEBSTACK
Plug 'mattn/emmet-vim', { 'for': ['html', 'htmldjango'] }
Plug 'ap/vim-css-color'
Plug 'adelarsq/vim-matchit'
Plug 'mustache/vim-mustache-handlebars'
" Markdown
" Plug 'vimwiki/vimwiki'
" Simple syntax highlighting:
" Plug 'drmingdrmer/vim-syntax-markdown'
" Plug 'plasticboy/vim-markdown', { 'for': ['markdown'] }
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-rmarkdown'
Plug 'vim-pandoc/vim-pandoc-syntax'
" LATEX
" Plug 'vim-latex/vim-latex'
" A better latex alternative ??
Plug 'lervag/vimtex'
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
" Others
" Plug 'derekwyatt/vim-scala', { 'for': ['scala'] }
" Plug 'Vimjas/vim-python-pep8-indent', { 'for': ['python'] }
" Plugins that depend on language servers.
if !has('win32') && has('python3')
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ncm2/float-preview.nvim'
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
" Python
Plug 'deoplete-plugins/deoplete-jedi', { 'for': ['python'] }
" TODO: Why is slow => pandas
Plug 'davidhalter/jedi-vim', { 'for': ['python'] }
" Javascript
Plug 'carlitux/deoplete-ternjs', { 'for': ['javascript', 'javascript.jsx'], 'do': 'npm install -g tern' }
Plug 'ternjs/tern_for_vim', { 'for': ['javascript', 'javascript.jsx'], 'do': 'npm install' }
Plug 'othree/jspc.vim', { 'for': ['javascript', 'javascript.jsx'] }
endif
" Only load in Vim (Not NeoVim).
Plug 'drmikehenry/vim-fixkey', { 'for': [] }
call plug#end()
if !has('win32') && !has('nvim')
call plug#load('vim-fixkey')
endif
" Latex
" Not yet fully writing any Latex.
" let g:tex_flavor='latex'
let g:vim_markdown_math = 1
let g:vim_markdown_folding_disabled = 1
" let g:vim_markdown_math = 1
let g:vim_markdown_conceal = 0
" This is vim config, not vim_markdown
let g:tex_conceal = "amgs"
let g:tex_flavor = 'latex'
let g:grammarous#languagetool_cmd = 'languagetool'
nmap <buffer><leader>t <Plug>(grammarous-move-to-next-error)
let g:vimtex_view_method = "zathura"
let g:livepreview_previewer = 'zathura'
let g:vimtex_quickfix_ignore_filters = [
\ 'Underfull',
\ 'Overfull',
\ 'Missing',
\]
" https://tex.stackexchange.com/questions/416030/how-do-i-make-vim-highlight-math-properly-in-the-align-environment
" https://github.com/plasticboy/vim-markdown/issues/469
" amsmath.vim
" Author: Charles E. Campbell
" Date: Jun 29, 2018 - Apr 01, 2019
" Version: 1d ASTRO-ONLY
"
" Useful for \usepackage{amssymb,amsmath}
" ---------------------------------------------------------------------
" let b:loaded_amsmath = "v1d"
" let s:keepcpo = &cpo
" set cpo&vim
" ---------------------------------------------------------------------
" AMS-Math Package Support: {{{1
" call TexNewMathZone("E","align",1)
" call TexNewMathZone("F","alignat",1)
" call TexNewMathZone("G","equation",1)
" call TexNewMathZone("H","flalign",1)
" call TexNewMathZone("I","gather",1)
" call TexNewMathZone("J","multline",1)
" call TexNewMathZone("K","xalignat",1)
" call TexNewMathZone("L","xxalignat",0)
" syn match texBadMath "\\end\s*{\s*\(align\|alignat\|equation\|flalign\|gather\|multline\|xalignat\|xxalignat\)\*\=\s*}"
" syn region mkdMath start="\\\@<!\\begin" end="\\end" contains=@tex keepend
" Amsmath [lr][vV]ert (Holger Mitschke)
" let s:texMathDelimList=[
" \ ['\\lvert' , '|'] ,
" \ ['\\rvert' , '|'] ,
" \ ['\\lVert' , '‖'] ,
" \ ['\\rVert' , '‖'] ,
" \ ]
" for texmath in s:texMathDelimList
" execute "syntax match texMathDelim '\\\\[bB]igg\\=[lr]\\=".texmath[0]."' contained conceal cchar=".texmath[1]
" endfor
" ---------------------------------------------------------------------
" AMS-Math and AMS-Symb Package Support: {{{1
function! SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" let s:texMathList=[
" \ ['backepsilon' , '∍'] ,
" \ ['backsimeq' , '≃'] ,
" \ ['barwedge' , '⊼'] ,
" \ ['because' , '∵'] ,
" \ ['beth' , 'ܒ'] ,
" \ ['between' , '≬'] ,
" \ ['blacksquare' , '∎'] ,
" \ ['Box' , '☐'] ,
" \ ['boxdot' , '⊡'] ,
" \ ['boxminus' , '⊟'] ,
" \ ['boxplus' , '⊞'] ,
" \ ['boxtimes' , '⊠'] ,
" \ ['bumpeq' , '≏'] ,
" \ ['Bumpeq' , '≎'] ,
" \ ['Cap' , '⋒'] ,
" \ ['circeq' , '≗'] ,
" \ ['circlearrowleft' , '↺'] ,
" \ ['circlearrowright' , '↻'] ,
" \ ['circledast' , '⊛'] ,
" \ ['circledcirc' , '⊚'] ,
" \ ['colon' , ':'] ,
" \ ['complement' , '∁'] ,
" \ ['Cup' , '⋓'] ,
" \ ['curlyeqprec' , '⋞'] ,
" \ ['curlyeqsucc' , '⋟'] ,
" \ ['curlyvee' , '⋎'] ,
" \ ['curlywedge' , '⋏'] ,
" \ ['doteqdot' , '≑'] ,
" \ ['dotplus' , '∔'] ,
" \ ['dotsb' , '⋯'] ,
" \ ['dotsc' , '…'] ,
" \ ['dotsi' , '⋯'] ,
" \ ['dotso' , '…'] ,
" \ ['doublebarwedge' , '⩞'] ,
" \ ['eqcirc' , '≖'] ,
" \ ['eqsim' , '≂'] ,
" \ ['eqslantgtr' , '⪖'] ,
" \ ['eqslantless' , '⪕'] ,
" \ ['eth' , 'ð'] ,
" \ ['fallingdotseq' , '≒'] ,
" \ ['geqq' , '≧'] ,
" \ ['gimel' , 'ℷ'] ,
" \ ['gneqq' , '≩'] ,
" \ ['gtrdot' , '⋗'] ,
" \ ['gtreqless' , '⋛'] ,
" \ ['gtrless' , '≷'] ,
" \ ['gtrsim' , '≳'] ,
" \ ['iiint' , '∭'] ,
" \ ['iint' , '∬'] ,
" \ ['implies' , '⇒'] ,
" \ ['leadsto' , '↝'] ,
" \ ['leftarrowtail' , '↢'] ,
" \ ['leftrightsquigarrow', '↭'] ,
" \ ['leftthreetimes' , '⋋'] ,
" \ ['leqq' , '≦'] ,
" \ ['lessdot' , '⋖'] ,
" \ ['lesseqgtr' , '⋚'] ,
" \ ['lesssim' , '≲'] ,
" \ ['lneqq' , '≨'] ,
" \ ['ltimes' , '⋉'] ,
" \ ['measuredangle' , '∡'] ,
" \ ['ncong' , '≇'] ,
" \ ['nexists' , '∄'] ,
" \ ['ngeq' , '≱'] ,
" \ ['ngeqq' , '≱'] ,
" \ ['ngtr' , '≯'] ,
" \ ['nleftarrow' , '↚'] ,
" \ ['nLeftarrow' , '⇍'] ,
" \ ['nLeftrightarrow' , '⇎'] ,
" \ ['nleq' , '≰'] ,
" \ ['nleqq' , '≰'] ,
" \ ['nless' , '≮'] ,
" \ ['nmid' , '∤'] ,
" \ ['nparallel' , '∦'] ,
" \ ['nprec' , '⊀'] ,
" \ ['nrightarrow' , '↛'] ,
" \ ['nRightarrow' , '⇏'] ,
" \ ['nsim' , '≁'] ,
" \ ['nsucc' , '⊁'] ,
" \ ['ntriangleleft' , '⋪'] ,
" \ ['ntrianglelefteq' , '⋬'] ,
" \ ['ntriangleright' , '⋫'] ,
" \ ['ntrianglerighteq' , '⋭'] ,
" \ ['nvdash' , '⊬'] ,
" \ ['nvDash' , '⊭'] ,
" \ ['nVdash' , '⊮'] ,
" \ ['pitchfork' , '⋔'] ,
" \ ['precapprox' , '⪷'] ,
" \ ['preccurlyeq' , '≼'] ,
" \ ['precnapprox' , '⪹'] ,
" \ ['precneqq' , '⪵'] ,
" \ ['precsim' , '≾'] ,
" \ ['rightarrowtail' , '↣'] ,
" \ ['rightsquigarrow' , '↝'] ,
" \ ['rightthreetimes' , '⋌'] ,
" \ ['risingdotseq' , '≓'] ,
" \ ['rtimes' , '⋊'] ,
" \ ['sphericalangle' , '∢'] ,
" \ ['star' , '✫'] ,
" \ ['subset' , '⊂'] ,
" \ ['Subset' , '⋐'] ,
" \ ['subseteqq' , '⫅'] ,
" \ ['subsetneq' , '⊊'] ,
" \ ['subsetneqq' , '⫋'] ,
" \ ['succapprox' , '⪸'] ,
" \ ['succcurlyeq' , '≽'] ,
" \ ['succnapprox' , '⪺'] ,
" \ ['succneqq' , '⪶'] ,
" \ ['succsim' , '≿'] ,
" \ ['Supset' , '⋑'] ,
" \ ['supseteqq' , '⫆'] ,
" \ ['supsetneq' , '⊋'] ,
" \ ['supsetneqq' , '⫌'] ,
" \ ['therefore' , '∴'] ,
" \ ['trianglelefteq' , '⊴'] ,
" \ ['triangleq' , '≜'] ,
" \ ['trianglerighteq' , '⊵'] ,
" \ ['twoheadleftarrow' , '↞'] ,
" \ ['twoheadrightarrow' , '↠'] ,
" \ ['ulcorner' , '⌜'] ,
" \ ['urcorner' , '⌝'] ,
" \ ['varnothing' , '∅'] ,
" \ ['vartriangle' , '∆'] ,
" \ ['vDash' , '⊨'] ,
" \ ['Vdash' , '⊩'] ,
" \ ['veebar' , '⊻'] ,
" \ ['Vvdash' , '⊪']]
" for texmath in s:texMathList
" if texmath[0] =~# '\w$'
" exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1]
" else
" exe "syn match texMathSymbol '\\\\".texmath[0]."' contained conceal cchar=".texmath[1]
" endif
" endfor
" ---------------------------------------------------------------------
" Restore: {{{1
" let &cpo= s:keepcpo
" unlet s:keepcpo
" vim: ts=4 fdm=marker
" ########
" WEBSTACK {{{1
" ########
" HTML
" let g:html_indent_script1 = "inc"
" Map shift enter
" inoremap <CR><ESC>O
inoremap <M-Enter> <CR><ESC>O
let g:user_emmet_mode='a'
imap , <esc>$<Plug>(emmet-expand-abbr)
nmap , $<Plug>(emmet-expand-abbr)
au BufRead,StdinReadPost * if getline(1) =~ '<html>' | setlocal ft=html | endif
au StdinReadPost * if getline(1) =~ '[\|{' | setlocal ft=json | endif
au BufEnter * if &ft ==# 'html' | exec 'RainbowToggleOff' | endif
" #############
" VISUALIZATION {{{1
" #############
" THEME
set background=light
colorscheme PaperColor
set guicursor=
set nocompatible
let g:PaperColor_Theme_Options = {
\ 'language': {
\ 'python': { 'highlight_builtins' : 1 },
\ 'cpp': { 'highlight_standard_library': 1 },
\ 'c': { 'highlight_builtins' : 1 }
\ }
\}
" RAINBOW
let g:rainbow_active = 1
let g:rainbow_conf = {'ctermfgs': [238, 41, 170, 147]}
map <leader>r :RainbowToggle<enter>
au BufEnter * if &ft ==# 'html' | exec 'RainbowToggleOff' | endif
" View indents
" indentLine uses conceal, disable for markdown and json and tex
" let g:indentLine_fileTypeExclude = ['markdown', 'json', 'tex']
" nathanaelkane/vim-indent-guides
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level=2
let g:indent_guides_guide_size=1
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=white
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=lightgrey
let g:highlightedyank_highlight_duration = 250
autocmd FileType markdown set cole=0
autocmd FileType vim set foldmethod=marker
set scrolloff=5
" autocmd! User GoyoEnter Limelight
" autocmd! User GoyoLeave Limelight!
let g:goyo_width=150
" =========== UTILS {{{1
if !has('win32')
" file dirs
set dir=~/.vim/swapfiles
set backup
set backupdir=~/.vim/backupfiles
set undofile
set undodir=~/.vim/undodir
endif
" numbers and such
set history=1000
set colorcolumn=80
set linebreak
" set showbreak=..
set number! relativenumber!
set ruler
set cursorline
map <leader>h :noh<CR>
set showcmd
set signcolumn=yes
set lazyredraw
" TABS {{{1
set tabstop=8
set softtabstop=4
set shiftwidth=4
" set smarttab
set expandtab
let g:vim_indent_cont = 0
" no clue what would work best.
set autoindent
" set smartindent
" Disable python indent on : (because type hints)
autocmd FileType python setlocal indentkeys-=<:>
autocmd FileType python setlocal indentkeys-=:
set hidden
set ignorecase
set smartcase
" GENERAL {{{1
set encoding=utf8
set ffs=unix,dos,mac
set clipboard^=unnamed,unnamedplus
packloadall
silent! helptags ALL
set path+=**
set wildmenu
set wildmode=list:longest,full
set dictionary+=/usr/share/dict/words
set complete=.,w,b,u,t
set display=truncate
" MAPPINGS {{{1
" nvim behave like normal command line.
" for ch in map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)')
" execute printf('inoremap <M-%s> <Esc>%s', ch, ch)
" endfor
" map , <Plug>(clever-f-repeat-back)
map , <Plug>(clever-f-repeat-forward)
map ; :
noremap Y y$
let g:wordmotion_prefix = '<Leader>'
call customsurround#map('<leader>b', '\fB', '\fP')
call customsurround#map('<leader>i', '\fI', '\fP')
" fzf.vim
command F Files
" map a motion and its reverse motion:
noremap <expr> h repmo#SelfKey('h', 'l')|sunmap h
noremap <expr> l repmo#SelfKey('l', 'h')|sunmap l
noremap <expr> j repmo#SelfKey('j', 'k')|sunmap j
noremap <expr> k repmo#SelfKey('k', 'j')|sunmap k
noremap <expr> gj repmo#SelfKey('gj', 'gk')|sunmap gj
noremap <expr> gk repmo#SelfKey('gk', 'gj')|sunmap gk
" if you like `:noremap j gj', you can keep that:
" map <expr> j repmo#Key('gj', 'gk')|sunmap j
" map <expr> k repmo#Key('gk', 'gj')|sunmap k
" noremap j gj
" noremap k gk
" repeat the last [count]motion or the last zap-key:
map <expr> m repmo#LastKey('m')|sunmap ;
map <expr> , repmo#LastRevKey(',')|sunmap ,
" " add these mappings when repeating with `;' or `,':
" noremap <expr> f repmo#ZapKey('f')|sunmap f
" noremap <expr> F repmo#ZapKey('F')|sunmap F
" noremap <expr> t repmo#ZapKey('t')|sunmap t
" noremap <expr> T repmo#ZapKey('T')|sunmap T
imap <C-CR> <CR><C-o><S-o>
" imap <C-CR> <CR><CR><C-o>k<C-o>cc
" imap <C-CR> <ESC>:normal akcc
" imap <C-CR> <ESC>:exec "normal! a<C-V><CR><C-V><CR><C-V><C-O>k<C-V><C-F>"<CR>
inoremap <CR> <C-G>u<CR>
" Don't reindent #:
inoremap # X<BS>#
if !has('nvim')
" map End key to end of line in command mode
cm OF
set hlsearch
if has('reltime')
set incsearch
endif
else
set inccommand=nosplit
endif
set gdefault
" let g:easyescape_chars = { "j": 1, "k": 1 }
" let g:easyescape_timeout = 100
" cnoremap kj <ESC>
nnoremap <leader>i :exec "normal i".nr2char(getchar())."\e"<CR>
nnoremap <leader>I :exec "normal a".nr2char(getchar())."\e"<CR>
nnoremap <leader>x :wall<CR>
nnoremap <leader>m :w\|mak<CR>
inoremap <C-U> <C-G>u<C-U>
" R
inoremap <M--> <-<Space>
inoremap <NL> %>%<Space>
" AutoPairs
let g:AutoPairsCenterLine = 0
" let g:AutoPairsMapCR = 1
map <m-a> ggVG
vnoremap // y/<C-R>"<CR>
" Appending paragraphs
nnoremap <leader>o }ko<CR>
nnoremap <leader>O {ko<CR>
" Indenting recently pasted text.
nnoremap <leader>p `[V`]
nnoremap <leader>[ `[V`]<
nnoremap <leader>] `[V`]>
nnoremap <leader>f :% foldo!<CR>
nnoremap <Leader>yy ^yg_
nnoremap <Leader>dd ^dg_
" ======
" nnoremap <expr> <Leader>o line('.') == line('$') ? '}o<CR>' : '}O<CR>'
" nnoremap <expr> <Leader>O line('.') == 1 ? '{O<CR><Esc>ki' : '{O<CR>''}'}'
set splitright
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
nnoremap S :%s//g<Left><Left>
" map paste, yank and delete to named register so the content
" will not be overwritten (I know I should just remember...)
" nnoremap x "_x
" vnoremap x "_x
vnoremap <C-c> "+y
map <C-p> "+P
vnoremap <leader><leader> <Esc>/<++><Enter>"_c4l
map <leader><leader> <Esc>/<++><Enter>"_c4l
" EASYALIGN
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
nnoremap <buffer> H :<C-u>execute "!pydoc3 " . expand("<cword>")<CR>
if has('autocmd')
" Put these in an autocmd group, so that you can revert them with:
" ":augroup vimStartup | au! | augroup END"
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
endif
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
" Revert with: ":delcommand DiffOrig".
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" autocmd sets these preferences with force.
autocmd FileType * set formatoptions-=o
autocmd FileType * set formatoptions-=t
autocmd FileType * set formatoptions+=r
set backspace=indent,eol,start
set isfname-==
" Multiple byte characters (like alt)
set ttimeout
set ttimeoutlen=5
autocmd FileType javascript noremap <leader>r :TernRename<CR>
autocmd FileType javascript noremap <leader>g :TernDef<CR>
autocmd FileType javascript noremap <leader>n :TernRef<CR>
" ##############
" LINTING/FIXING {{{1
" ##############
let g:ale_cpp_gcc_options = '-std=c++17 -Wall'
let g:ale_virtualenv_dir_names = []
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'json': ['jsonlint'],
\ 'python': ['flake8']
\}
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'json': ['prettier'],
\ 'python': ['isort', 'autopep8'],
\ 'rust': ['rustfmt']
\}
" \ 'python': ['isort'],
" , 'prettier', 'standard', 'prettier_standard', 'prettier_eslint', 'importjs'],
let g:ale_fix_on_save = 1
let g:ale_completion_enabled = 1
let g:ale_python_pylint_options = '--load-plugins pylint_django'
let g:ale_lint_on_text_changed = 1
autocmd FileType matlab setl cms=%\ %s
autocmd FileType json setl cms=//\ %s
" Remove trailing space on safe.
autocmd BufWritePre * if &ft != 'markdown' | %s/\s\+$//e | endif
function TrimEndLines()
let save_cursor = getpos(".")
:silent! %s#\($\n\s*\)\+\%$##
call setpos('.', save_cursor)
endfunction
au BufWritePre *.py call TrimEndLines()
" File specific tab size
au FileType javascript set softtabstop=4
au FileType javascript set shiftwidth=4
au FileType bib set softtabstop=2
au FileType bib set shiftwidth=2
autocmd FileType bib set expandtab
au FileType r set softtabstop=2
au FileType r set shiftwidth=2
" autosave
" too distracting with autocompile.
au InsertLeave * if &ft != 'tex' | silent! write | endif
" ##############
" AUTOCOMPLETION {{{1
" ##############
" GENERAL
" Word boundaries.
set iskeyword+=-
" How the menu works
set shortmess+=c
set completeopt=menu,menuone
if has('nvim')
" We use float preview
" let g:float_preview#docked = 0
else
set completeopt+=preview
endif
" Doubly mapped at the moment.
" inoremap <expr> <CR> (!pumvisible() <Bar><Bar> get(complete_info(), 'selected', -1) < 0) ? "\<C-g>u\<CR>" : "\<C-y>"
" inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" au VimEnter * inoremap <expr> <C-e> pumvisible() ? "\<C-e>\<C-e>" : "\<C-e>"
au VimEnter * inoremap <expr> <C-e> "\<End>"
" inoremap <expr> <C-x> pumvisible() ? "\<C-e>" : "\<C-x>"
" JEDI
" Disable Jedi-vim autocompletion and enable call-signatures options
let g:jedi#auto_initialization = 1
let g:jedi#completions_enabled = 0
let g:jedi#auto_vim_configuration = 0
let g:jedi#smart_auto_mappings = 0
let g:jedi#popup_on_dot = 0
let g:jedi#completions_command = ""
let g:jedi#show_call_signatures = "1"
let g:jedi#show_call_signatures_modes = 'i' " ni = also in normal mode
let g:jedi#show_call_signatures_delay = 0
" DEOPLETE
" let g:python3_host_prog = '/home/hielke/.venv/py3/bin/python3'
" py3 sys.path.append('/home/hielke/.venv/py3/lib/python3.7/site-packages/')
let g:python3_host_prog = '/home/hielke/.venv/py3/bin/python3'
py3 from pathlib import Path
py3 sys.path.append(str(next(Path('~/.venv/py3/lib').expanduser().glob('python3*/site-packages/'))))
let g:deoplete#enable_at_startup = 0
let g:deoplete#sources#jedi#show_docstring = 1
let g:deoplete#sources#jedi#statement_length = 500
" let g:deoplete#buffer#require_same_filetype = 0
call deoplete#custom#var('buffer', 'require_same_filetype', v:false)
call deoplete#custom#option('auto_complete_delay', 200)
" https://github.com/carlitux/deoplete-ternjs/issues/88
call deoplete#custom#option('num_processes', 4)
autocmd BufNewFile,BufRead * if empty(&filetype) | call deoplete#custom#option('auto_complete', 0) | endif
" call deoplete#custom#source('jedi', 'max_info_width', 40)
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
" DEOPLETE FOR JAVASCRIPT
call deoplete#custom#source('omni', 'functions', {
\ 'javascript': ['tern#Complete', 'jspc#omni']
\})
" This is new style
call deoplete#custom#var('omni', 'input_patterns', {
\ 'tex': g:vimtex#re#deoplete
\})
" Use tern_for_vim.
let g:tern#command = ["tern"]
let g:tern#arguments = ["--persistent"]
" COC.NVIM
" autocmd FileType json syntax match Comment +\/\/.\+$+
" function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~ '\s'
" endfunction
" inoremap <silent><expr> <Tab>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<Tab>" :
" \ coc#refresh()
" " Remap keys for gotos
" nmap <silent> gd <Plug>(coc-definition)
" nmap <silent> gy <Plug>(coc-type-definition)
" nmap <silent> gi <Plug>(coc-implementation)
" nmap <silent> gr <Plug>(coc-references)
" " Use K to show documentation in preview window
" nnoremap <silent> K :call <SID>show_documentation()<CR>
" function! s:show_documentation()
" if (index(['vim','help'], &filetype) >= 0)
" execute 'h '.expand('<cword>')
" else
" call CocAction('doHover')
" endif
" endfunction
" " Highlight symbol under cursor on CursorHold
" autocmd CursorHold * silent call CocActionAsync('highlight')
" " Remap for rename current word
" nmap <leader>rn <Plug>(coc-rename)
" Restart conky on safe
" autocmd BufWritePost note.txt !bash -c 'pkill -f "conky -c /home/hielke/.conky/MX-Emays/MX-emays"; conky -c /home/hielke/.conky/MX-Emays/MX-emays & echo test23 > /home/hielke/tmp/echotest'
" EXECUTERS/COMPILERS {{{1
if !has('win32')
autocmd FileType python map <F5> :w<Bar>execute 'silent !tmux send-keys -t "$(cat $HOME/.tmux-panes/ipython3)" \%run\ %:p Enter'<Bar>redraw!<C-M>
autocmd FileType matlab map <F5> :w<Bar>execute 'silent !tmux send-keys -t "$(cat $HOME/.tmux-panes/matlab)" "$(basename % .m)" Enter'<Bar>redraw!<C-M>
autocmd BufNewFile *.py .!pystamp.bash
endif
autocmd BufWritePost ~/.Xresources,~/.Xdefaults !xrdb %
au BufReadPost bash-fc* :set filetype=sh | :execute "normal! i#!/bin/bash\<Esc>o\<Cr>"
"}}}