-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
1171 lines (964 loc) · 37 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
"{{{ MAPPINGS
let mapleader = "ä"
let maplocalleader = "´"
nmap , ä
nmap ö <localleader>
nnoremap ,, ,
" Ugly hack since OS X is terrible at not breaking this...
if has("macunix")
map § <
map ° >
map f§ f<
map f° f>
map F§ F<
map F° F>
map t§ t<
map t° t>
map T§ T<
map T° T>
imap § <
vmap § <
endif
nmap cså cs[
nmap cs¨ cs]
nmap cs¨^ cs]}
omap iå i[
omap i¨ i]
omap aå a[
omap a¨ a]
nmap å [
nmap ¨ ]
nnoremap di_ f_dF_
nnoremap vi_ t_vF_
vnoremap i_ F_
"Helper for spell check: press <tab> on a word, <esc> to choose word
nmap <s-tab> viw<esc>a<c-x>s<tab>
"nmap <s-tab> viw<esc>a<c-x>s
nnoremap gsus :set spell spelllang=en_us<cr>
nnoremap gsgb :set spell spelllang=en_gb<cr>
nnoremap gss :set nospell<cr>
"Buffer shortcuts: open new, next, prev, delete
nnoremap <b :b <c-d>
nnoremap <l :lnext<cr>
nnoremap >L :lprevious<cr>
nnoremap <n :cn<cr>
nnoremap <p :cp<cr>
nnoremap <d :bd<cr>
" Adds characters around word
nnoremap <leader>" viw<ESC>a"<ESC>hbi"<ESC>lel
nnoremap <leader>' viw<ESC>a'<ESC>hbi'<ESC>lel
vnoremap <leader>" <ESC>`>a"<ESC>`<i"<ESC>
vnoremap <leader>' <ESC>`>a'<ESC>`<i'<ESC>
nnoremap <leader>[ viw<ESC>a]<ESC>hbi[<ESC>%
nnoremap <leader>] viw<ESC>a]<ESC>hbi[<ESC>%
nnoremap <leader>( viw<ESC>a)<ESC>hbi(<ESC>%
nnoremap <leader>) viw<ESC>a)<ESC>hbi(<ESC>%
nnoremap <leader>< viw<ESC>a><ESC>hbi<<ESC>%
nnoremap <leader>> viw<ESC>a><ESC>hbi<<ESC>%
nnoremap <leader>n :bn<cr>
nnoremap <leader>N :bp<cr>
" Quickly edit vimrc
nnoremap <leader>ev :vert split $MYVIMRC<CR>
nnoremap <leader>Ev :split $MYVIMRC<CR>
nnoremap <leader>EV :split $MYVIMRC<CR>
"yank current line and enter it into command mode without pressing enter
nnoremap <leader>: 0"xy$:<c-r>x
nnoremap <leader>ei :vert split ~/.i3/config<CR>
nnoremap <leader><leader>n :set number!<CR>
nnoremap <leader><leader>p :set paste<cr>"+p:set nopaste<cr>
inoremap <c-r>+ :set paste<cr>a<c-r>+:set nopaste<cr>a
inoremap <c-r>* :set paste<cr>a<c-r>*:set nopaste<cr>a
" Prepends # to line and goes down, Q removes then
nnoremap <leader>q I#<esc>j
nnoremap <leader>Q kx
"add space around character, e.g. '*' -> ' * '
nnoremap <leader><space> i<space><esc>2li<space><esc>h
vnoremap <space> <esc>`<i<space><esc>`>la<space><esc>`<l
" Search for something first (e.g. using *), then press S to substitute
nnoremap S :%s///g<left><left>
"Resize window
"nnoremap <leader>r :vert resize 84<CR>
"nnoremap <leader>R :vert resize 80<CR>
nnoremap <silent> <Leader><Leader>+ :exe "resize " . (winheight(0) * 3/2)<cr>
nnoremap <silent> <Leader><Leader>- :exe "resize " . (winheight(0) * 2/3)<cr>
nnoremap <silent> <Leader>+ :exe "vert resize " . (winwidth(0) * 3/2)<cr>
nnoremap <silent> <Leader>- :exe "vert resize " . (winwidth(0) * 2/3)<cr>
":update will save but only if there's a change
"nnoremap <space> :w<CR>
nnoremap <space> :update<CR>
" press <backspace> to switch to the "alternate file"
nnoremap <bs> <C-^>
" <cr> does za, but only in regular buffers
" (found at https://www.reddit.com/r/vim/comments/4m678o/best_way_to_remap_cr_in_normal_mode/ )
"" nnoremap <silent> <expr> <CR> empty(&buftype) \|\| &bt ==# 'help' \|\| &ft ==# 'man' ?
"" \ 'za' : '<CR>'
"nnoremap <silent> <expr> <CR> empty(&buftype) \|\| &bt ==# 'help' \|\| &ft ==# 'man' ?
" \ '<Plug>(easymotion-s)' : '<CR>'
nnoremap <silent> <expr> <CR> empty(&buftype) \|\| &bt ==# 'help' \|\| &ft ==# 'man' ?
\ (&ft ==# 'fsharp' ? ':<C-u>call fsharpbinding#python#FsiSendLine()<CR>' : '<Plug>(easymotion-s)') : '<CR>'
" nnoremap <buffer> <CR> :<C-u>call fsharpbinding#python#FsiSendLine()<CR>
nnoremap + <c-a>
nnoremap - <c-x>
" :help map-which-keys " is helpful to find new mappings
imap jk <esc>
imap Jk <esc>
"nnoremap ö /
"nnoremap dö d/
"cnoremap ö /
"vnoremap ö /
"nnoremap E $
"noremap L $
"nnoremap H ^
" We're more often interested in completing previous command rather than
" seeing the previous one
cnoremap <c-a> <home>
cnoremap <c-p> <up>
cnoremap <c-n> <down>
cnoremap <up> <c-p>
cnoremap <down> <c-n>
"An equivalent of <c-r><c-w>/<c-r><c-f> for the current line:
cnoremap <C-r><C-l> <C-r>=getline('.')<CR>
"Don't wait as long in insert mode (to enable us to quickly type j and k)
if has("autocmd")
augroup FastEscape
autocmd!
autocmd InsertEnter * set timeoutlen=450
autocmd InsertLeave * set timeoutlen=2500
augroup END
endif
"Fix accidentally holding shift while trying to quit vim, e.g. :Q -> :q
command Q q
command Qa qa
command QA qa
cmap Q! q!
cmap Qa! qa!
cmap QA! qa!
"helper
cmap FTP ~/.vim/ftplugin/<c-d>
cmap BUN ~/.vim/bundle/<c-d>
cmap US ~/.vim/bundle/vim-snippets.git/snippets/<c-d>
nnoremap - /
"0 is much easier to reach than ^ on many non-US layouts
nnoremap 0 ^
nnoremap ´ ^
nnoremap ^ 0
nnoremap d0 d^
nnoremap c0 c^
nnoremap y0 y^
" More reasonable use of Y (as opposed to being identical to yy)
nnoremap Y y$
" Jump directly to a spot instead of just to that line
nnoremap ` '
nnoremap ' `
vnoremap ` '
vnoremap ' `
nnoremap Q :q
nnoremap QQ Q
" Quickly replay a record
"nnoremap Q @q
"Quickly move between windows with ctrl+hjkl
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
if has('nvim')
""" Disabled to get c-s to work with fzf.vim's Ag command
""" "Terminal mappings, since <C-\><C-n> is annoying to prepend
""" tnoremap <c-s> <C-\><C-n>
""" tnoremap <c-s><c-s> <C-\><C-n><c-w><c-c>
""" tnoremap <c-s><c-h> <C-\><C-n><c-w>h
""" tnoremap <c-s><c-j> <C-\><C-n><c-w>j
""" tnoremap <c-s><c-k> <C-\><C-n><c-w>k
""" tnoremap <c-s><c-l> <C-\><C-n><c-w>l
""" tnoremap <c-s>h <C-\><C-n><c-w>h
""" tnoremap <c-s>j <C-\><C-n><c-w>j
""" tnoremap <c-s>k <C-\><C-n><c-w>k
""" tnoremap <c-s>l <C-\><C-n><c-w>l
"""
"""
""" " Recreating some tmux-like stuff
""" tnoremap <c-s>c <C-\><C-n>:tabe<cr>:term<cr>
""" "In case we're not releasing ctrl quickly enough:
""" tnoremap <c-s><c-c> <C-\><C-n>:tabe<cr>:term<cr>
""" tnoremap <c-s>n <C-\><C-n>gt
""" tnoremap <c-s><c-n> <C-\><C-n>gt
""" tnoremap <c-s>p <C-\><C-n>gT
""" tnoremap <c-s><c-p> <C-\><C-n>gT
""" tnoremap <c-s>s <C-\><C-n>:new<cr>:term<cr>
""" tnoremap <c-s><c-s> <C-\><C-n>:new<cr>:term<cr>
""" tnoremap <c-s>v <C-\><C-n>:vnew<cr>:term<cr>
""" tnoremap <c-s><c-v> <C-\><C-n>:vnew<cr>:term<cr>
""" tnoremap <c-s>x <C-\><C-n><c-w>c
""" tnoremap <c-s><c-x> <C-\><C-n><c-w>c
""" tnoremap <c-s>T <C-\><C-n><c-w>T
"""
""" nnoremap <c-s>c :tabe<cr>:term<cr>
""" "In case we're not releasing ctrl quickly enough:
""" nnoremap <c-s><c-c> :tabe<cr>:term<cr>
""" nnoremap <c-s>n gt
""" nnoremap <c-s><c-n> gt
""" nnoremap <c-s>p gT
""" nnoremap <c-s><c-p> gT
""" nnoremap <c-s>s :new<cr>:term<cr>
""" nnoremap <c-s><c-s> :new<cr>:term<cr>
""" nnoremap <c-s>v :vnew<cr>:term<cr>
""" nnoremap <c-s><c-v> :vnew<cr>:term<cr>
""" nnoremap <c-s>x <c-w>c
""" nnoremap <c-s><c-x> <c-w>c
""" nnoremap <c-s>T <c-w>T
"""
"""
"""
""" "tnoremap <c-h> <c-\><c-n><c-w>h
""" "tnoremap <c-j> <c-\><c-n><c-w>j
""" "tnoremap <c-k> <c-\><c-n><c-w>k "used for kill to eol
""" "tnoremap <c-l> <c-\><c-n><c-w>l "used for clear...
"""
"""
""" "Open a new vertical term
""" nnoremap <c-t> :vnew<cr>:term<cr>
"""
""" nnoremap <c-s><c-h> <c-w>h
""" nnoremap <c-s><c-j> <c-w>j
""" nnoremap <c-s><c-k> <c-w>k
""" nnoremap <c-s><c-l> <c-w>l
""" nnoremap <c-s>h <c-w>h
""" nnoremap <c-s>j <c-w>j
""" nnoremap <c-s>k <c-w>k
""" nnoremap <c-s>l <c-w>l
"""
""" "Automatically enter terminal if we go into term window
""" autocmd BufEnter term://* startinsert
endif
" o and O doesn't go into insert mode
nnoremap o o.<Esc>"_x<Esc>
nnoremap O O.<Esc>"_x<Esc>
" Characters to use with ¨ and shift+¨
" ẅëẗÿüï¨ḧ̈́̈́ẍ^f
" âĉêĝĥîĵôŝûŵŷẑ
nnoremap ü i<CR><Esc>k$
nnoremap ë :vert resize 80<CR>
nnoremap Ω :vert resize 80<CR>
"Key that is right of + on Swedish keyboards plus key gives these
nnoremap ẃ :mksession! .vimsession<cr>
nnoremap ŕ :source .vimsession<cr>
" Move top/bottom but leave 4 lines above/below
nnoremap zT zt4<C-y>
nnoremap zB zb4<C-e>
vnoremap zT zt4<C-y>
vnoremap zB zb4<C-e>
"inoremap zT <esc>zt4<C-y>i
"inoremap zB <esc>zb4<C-e>i
" Move vertically by visual line
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
" Inverse of join (J)
"function! BreakHere()
" s/^\(\s*\)\(.\{-}\)\(\s*\)\(\%#\)\(\s*\)\(.*\)/\1\2\r\1\4\6
" call histdel("/", -1)
"endfunction
"nnoremap K :call BreakHere()<CR>
" Easier indentation in visual mode (don't leave visual mode after < or >)
vnoremap < <gv
vnoremap > >gv
"}}}
"{{{ SET OPTIONS
filetype plugin indent on
if has('nvim')
let $LANG = 'en'
set langmenu=none
"Show :substitute substitutions in new split
set inccommand=split
endif
"set completeopt=menu,preview,noinsert
set completeopt=menu,preview,longest
set number "show line numbers
"set relativenumber
set shiftwidth=4
set softtabstop=4 "Number of spaces in tab when editing
" Use the same symbols as TextMate for tabstops and EOLs
set list
"set listchars=tab:▸▸,eol:¬
"set listchars=tab:▸▸
set listchars=tab:>>,trail:·
set fillchars=
set expandtab "Expands tabs into spaces
highlight SpellBad ctermbg=5
"set sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize
set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize
set bs=2 "Enable backspace to go past indent,eol,start
set foldmethod=marker
set splitbelow
set splitright
"Reload a file if it has been modified outside of vim
set autoread
"Read local .vimrc files
set exrc
" F bindings
" Disable help with f1 (mac touchbars are no fun...)
map <f1> <nop>
" <F10> identifies the syntax highlighting group used at the cursor
" See http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
"Toggles paste mode
set pastetoggle=<leader>t
"Fixes slow responsiveness when scrolling in terms like iTerm(?)
"set lazyredraw
set incsearch "search as characters are entered
set ignorecase "ignore case when searching
set smartcase "ignore case when searching, except if we start with a capital
set hlsearch
if has("gui_running")
set mouse=a "use mouse in all modes
set guioptions-=T "removes toolbar
set guioptions-=m "removes menu
set guioptions-=l "removes always-on left-hand scrollbar
set guioptions-=L "removes left-hand scrollbar when there's a vertically split window
set guioptions-=r "removes always-on right-hand scrollbar
set guioptions-=e "removes GUI tab pages
"Visual bell causes the entire screen to flash in an annoying fashion
set novisualbell
set t_vb=
if has("gui_macvim")
set guifont=Menlo\ Regular:h13
else
" set guifont=Monospace\ Regular\ 10
set guifont=Inconsolata\ 11
endif
"set guifont=
set antialias
nnoremap <leader><leader>1 :set guifont=Terminus\ 9<cr>
nnoremap <leader><leader>2 :set guifont=Terminus\ 10<cr>
nnoremap <leader><leader>3 :set guifont=Terminus\ 11<cr>
nnoremap <leader><leader>4 :set guifont=Terminus\ 13<cr>
nnoremap <leader><leader>5 :set guifont=Terminus\ 14<cr>
nnoremap <leader><leader>6 :set guifont=Terminus\ 16<cr>
"Quickly write and quit from insert mode.
"Good with the itsalltext Firefox plugin
"inoremap <s-cr> <esc>ZZ
else
"set mouse=n "only use mouse in visual mode
set mouse=
if !has('nvim')
set ttymouse=xterm2 "xterm2 to support resizing with mouse
endif
" workaround: enables mouse resize but helps with accidental clicks moving
" the cursor
"nnoremap <LeftMouse> m'<LeftMouse>
"nnoremap <LeftRelease> <LeftRelease>g``set guifont=Menlo\ Regular:h14
endif
set timeout
set timeoutlen=2500 " used with e.g. leader
set ttimeoutlen=10
set wildmode=longest,list,full
set history=1000
set laststatus=2 "always show statusbar. 1 means 'only when 2+ windows open'
"always keep at a few lines at the top/bottom shown when moving around
set scrolloff=4
"Show this char when wrapping text
set showbreak=↪
"Disable Bram's start message
set shortmess+=I
" python3_host_prog must be set before vim-plug initialization below
" since otherwise black-nvim won't work
"Neovim-specific:
if has('nvim')
if has("macunix")
let g:python_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
let g:ycm_server_python_interpreter="/usr/local/bin/python3"
else
let g:python_host_prog = '/usr/bin/python'
" let g:python3_host_prog = '/usr/bin/python3'
let g:python3_host_prog = $HOME . '/.local/venv/nvim/bin/python'
endif
endif
"}}}
"{{{ COLORS AND HIGHLIGHTING
set t_Co=256
" mkdir -p ~/.vim/colors
" cd ~/.vim/colors
" wget -O ~/.vim/colors/wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400
" notermguicolors is needed in newer neovim to make most colorschemes look good...
set notermguicolors
"color wombat256mod
color wombat256mod-darker
"au FileType elm colorscheme predawn
"au FileType elm colorscheme github
" set background=dark
" colorscheme luna
" colorscheme wintersday
" colorscheme breeze_ranmod
" colorscheme obsidian
" colorscheme solarized
" colorscheme harlequin
syntax enable
" highlight trailing spaces. <leader>h to start highlight, <leader>H to stop.
nmap <leader>h :highlight ExtraWhitespace ctermbg=red<CR>:match ExtraWhiteSpace /\S\(\s\+\)$/<CR>
nmap <leader>H :highlight clear ExtraWhitespace<cr>
"highlight current line in insert mode
if has("autocmd")
augroup whitespace
autocmd!
"autocmd InsertEnter * set cursorline! | match ExtraWhitespace //
"autocmd InsertLeave * set cursorline! | call HighlightExtraWhitespace()
autocmd InsertEnter * set cursorline
autocmd InsertLeave * set nocursorline
augroup END
endif
function! HighlightExtraWhitespace()
"highlight ExtraWhitespace ctermbg=red
"6 is a blue color?
highlight ExtraWhitespace ctermbg=6
match ExtraWhiteSpace /\S\(\s\+\)$/
endfunction
if exists('+colorcolumn')
"Set a default colorcolumn
set colorcolumn=110
" Show remaining text as red when over colorcolumn columns:
" au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
"highlight Search term=none ctermfg=0 ctermbg=180
highlight Search ctermfg=0 ctermbg=180
"Left side statusline:
set statusline= "First clear statusline
"set statusline+=%t " file name (tail) of the file in the buffer
set statusline+=%f " full file name of the file in the buffer
set statusline+=\ %m%r "Modified [+]/[-], readonly [RO]
set statusline+=%w "Preview window flag [Preview]
set statusline+=%= "Start of right side statusline
"Right side statusline:
" set statusline+=%{fugitive#head()}
set statusline+=\ %y "Filetype e.g. [elm]
set statusline+=\ [col\ %02c] "Column number
set statusline+=\ %02p%% "Percent through file
set statusline+=\ %03l/%03L "Cursor line/total lines
"}}}
"{{{ FUNCTIONS
nnoremap di( :call New_dib()<CR>
nnoremap di) :call New_dib()<CR>
nnoremap dib :call New_dib()<CR>
"di(, di), dib that will move inside first instance of () first if needed
function! New_dib()
if search("(","bn") == line(".")
sil exe "normal! f)di("
"sil exe "normal! l"
else
sil exe "normal! f(di("
"sil exe "normal! l"
endif
endfunction
nnoremap di{ :call New_diB()<CR>
nnoremap di} :call New_diB()<CR>
nnoremap diB :call New_diB()<CR>
"Like dib but } instead of )
function! New_diB()
if search("{","bn") == line(".")
sil exe "normal! f}di{"
"sil exe "normal! l"
else
sil exe "normal! f{di{"
"sil exe "normal! l"
endif
endfunction
nnoremap ci( :call New_cip()<CR>
nnoremap ci) :call New_cip()<CR>
nnoremap cib :call New_cip()<CR>
" Change in paranthesis function, since ci( initially doesn't work
function! New_cip()
if search("(","bn") == line(".")
sil exe "normal! f)ci("
sil exe "normal! l"
startinsert
else
sil exe "normal! f(ci("
sil exe "normal! l"
startinsert
endif
endfunction
nnoremap ci( :call New_cip()<CR>
nnoremap ci) :call New_cip()<CR>
nnoremap cib :call New_cip()<CR>
" Change in square brackets function, since ci[ initially doesn't work
function! New_cisb()
if search("[","bn") == line(".")
sil exe "normal! f]ci["
sil exe "normal! l"
startinsert
else
sil exe "normal! f[ci]"
sil exe "normal! l"
startinsert
endif
endfunction
nnoremap ci[ :call New_cisb()<CR>
nnoremap ci] :call New_cisb()<CR>
" Change in squigly brackets function, since ci{ initially doesn't work
function! New_cisqb()
if search("{","bn") == line(".")
sil exe "normal! f}ci{"
sil exe "normal! l"
startinsert
else
sil exe "normal! f{ci}"
sil exe "normal! l"
startinsert
endif
endfunction
nnoremap ci{ :call New_cisqb()<CR>
nnoremap ciB :call New_cisqb()<CR>
nnoremap ci} :call New_cisqb()<CR>
nnoremap cis :call New_cisqb()<CR>
" Removes trailing spaces
function! TrimWhiteSpace()
%s/\s*$//
''
endfunction
nnoremap <leader>w :call TrimWhiteSpace()<CR>
"}}}
"{{{ AUTOCMDS
if has("autocmd")
augroup bufstuff
autocmd!
autocmd BufRead,BufNewFile .bash_aliases,bash_aliases set filetype=sh
autocmd BufRead,BufNewFile .pyre_configuration set ft=json
autocmd BufRead,BufNewFile *.jinja2 set ft=htmldjango
autocmd BufRead,BufNewFile *.arff set filetype=arff
autocmd BufRead,BufNewFile *.ct set filetype=cleantype
"autocmd BufRead,BufNewFile * call HighlightExtraWhitespace()
"Prevent auto-comments
"c: Auto-wrap comments using textwidth, autoinserting the current comment leader
"r: Autoinsert the current comment leader after hitting <CR> in Insert mode.
"o: Autoinsert the current comment leader after hitting o/O in Normal mode.
autocmd BufNewFile,BufWinEnter * setlocal formatoptions-=cro
"set formatoptions-=cro "this won't work, will be owerwritten, see this link:
"http://stackoverflow.com/questions/6076592/vim-set-formatoptions-being-lost
augroup END
" Resize splits when the window is resized
au VimResized * exe "normal! \<c-w>="
endif
"}}}
"{{{ PLUGINS
call plug#begin()
Plug 'averms/black-nvim', {'do': ':UpdateRemotePlugins'}
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
"cd ~/.vim/bundle
"""{{{ abcdef
"abnf - Agumented BNF syntax script
"!git clone https://github.com/vim-scripts/abnf ~/.vim/bundle/abnf
"vim-abolish, a plugin that does many things
"!git clone https://github.com/tpope/tpope-vim-abolish ~/.vim/bundle/tpope-vim-abolish
"Ack plugin for vim, usagE: :Ack [options] {pattern} [{directories}]
"!git clone https://github.com/mileszs/ack.vim.git ~/.vim/bundle/ack.vim
"Ale, Asynchronous Lint Engine for Neovim
"!git clone https://github.com/w0rp/ale.git ~/.vim/bundle/ale.git
"""commentary.vim - comment things out with gc+{motion} and more
"!git clone https://github.com/tpope/vim-commentary ~/.vim/bundle/vim-commentary
"""vim-css3-syntax - better syntax highlighting (also see ~/.vim/after/ftplugin/css.vim)
"!git clone https://github.com/hail2u/vim-css3-syntax ~/.vim/bundle/vim-css3-syntax
"""dracula-theme, a colortheme
"!git clone https://github.com/dracula/vim.git ~/.vim/bundle/dracula-theme
"""editorconfig-vim
"!git clone https://github.com/editorconfig/editorconfig-vim ~/.vim/bundle/editorconfig-vim
"""elm-vim - Elm support for Vim
"!git clone https://github.com/elmcast/elm-vim.git ~/.vim/bundle/elm-vim
"""eunuch.vim - vim sugar for multiple UNIX shell commands like :Move, :Rename
"!git clone https://github.com/tpope/vim-eunuch ~/.vim/bundle/vim-eunuch
" vim-python-pep8-indent automatically indents python code correctly
"!git clone https://github.com/Vimjas/vim-python-pep8-indent.git
""{{{ Clojure plugins
"""Clojure runtime files, extracted from the VimClojure project, required for vim-clojure-highlight
""!git clone https://github.com/guns/vim-clojure-static ~/.vim/bundle/vim-clojure-highlight
"""Quasi-REPL for clojure
""!git clone https://github.com/tpope/vim-fireplace ~/.vim/bundle/vim-fireplace
""clojure-highlight gives extended syntax highlightinging for clojure
""!git clone https://github.com/guns/vim-clojure-highlight ~/.vim/bundle/vim-clojure-highlight
""}}}
"""ctrl-p is a fuzzy file finder
"!git clone https://github.com/ctrlpvim/ctrlp.vim ~/.vim/bundle/ctrlp.vim
"""easy-motion
"!git clone https://github.com/easymotion/vim-easymotion ~/.vim/bundle/vim-easymotion
""exchange: add the cx operator. I.e. cxe on one word, then cxe to exchange
"!git clone git://github.com/tommcdo/vim-exchange.git
""fzf.vim enables some fzf commands such as :Ag or :Files
"!git clone https://github.com/junegunn/fzf.vim ~/.vim/bundle/fzf.vim
""vim-fsharp includes syntax + indent + pathogen/synastic autocompletion for F#
"!git clone https://github.com/fsharp/vim-fsharp ~/.vim/bundle/vim-fsharp
"""}}}
"""{{{ ghijk
"""gitgutter shows a git diff in the 'gutter' (sign column)
"!git clone git://github.com/airblade/vim-gitgutter.git ~/.vim/bundle/vim-gitgutter
"""haskell-vim, a bunch of scripts for Haskell and Cabal
"!git clone https://github.com/neovimhaskell/haskell-vim.git ~/.vim/bundle/haskell-vim
"""purescript-vim, syntax highlighting and indentation for Purescript
"!git clone https://github.com/raichoo/purescript-vim.git ~/.vim/bundle/purescript-vim
"""incsearch incrementally highlights all pattern being matched.
"!git clone https://github.com/haya14busa/incsearch.vim ~/.vim/bundle/incsearch.vim
"""vim-indent-object, e.g. vii to visually select at same indentation (also vai)
"!git clone https://github.com/michaeljsmith/vim-indent-object ~/.vim/bundle/vim-indent-object
"""vim-javascript, improved syntax highlighting and improved indentation
"!git clone https://github.com/pangloss/vim-javascript.git ~/.vim/bundle/vim-javascript
"""jspc - JavaScript Parameter Complete
"!git clone https://github.com/othree/jspc.vim ~/.vim/bundle/jspc.vim
"""jedi-vim is a vim-binding to the autocompletion library Jedi
"!git clone --recursive https://github.com/davidhalter/jedi-vim.git ~/.vim/bundle/jedi-vim
"""}}}
"""{{{ lmnop
"""LanguageClient-neovim - Language Server Protcol (LSP) support for vim and neovim
"!git clone --depth 1 https://github.com/autozimu/LanguageClient-neovim.git ~/.vim/bundle/LanguageClient-neovim
"""vim-mark, clone of the 'Mark.vim' plugin, allows highlighting of words
"!git clone https://github.com/Yggdroot/vim-mark ~/.vim/bundle/vim-mark
"""matchit increases support for %. For example, jump between <tags> </tags>
"!git clone https://github.com/tmhedberg/matchit ~/.vim/bundle/matchit
"""vim-printf, turn lines into printf statements
"!git clone git://github.com/mptre/vim-printf ~/.vim/bundle/vim-printf
"""vim-python-pep8-indent, fixes vim indentation behaviour for python
"!git clone https://github.com/Vimjas/vim-python-pep8-indent.git ~/.vim/bundle/vim-python-pep8-indent
"""}}}
"""{{{ qrstu
""repeat - helper plugin that enables repetition with dot in plugins such as vim-surround
"!git clone git://github.com/tpope/vim-repeat.git ~/.vim/bundle/vim-repeat
""vim-markdown, Markdown runtime files
"!git clone https://github.com/tpope/vim-markdown ~/.vim/bundle/vim-markdown
""" notational-fzf-vim adds the :NV command to search in markdown (requires fzf and configured fzf.vim)
""!git clone https://github.com/Alok/notational-fzf-vim ~/.vim/bundle/notational-fzf-vim
"rsi, adds 'readline-style-insertions' to command and insert mode
"!git clone https://github.com/tpope/vim-rsi.git ~/.vim/bundle/vim-rsi
""rust.vim
"!git clone --depth=1 https://github.com/rust-lang/rust.vim.git ~/.vim/bundle/rust.vim
""speeddating.vim, make <c-a> <c-x> support dates
"!git clone https://github.com/tpope/vim-speeddating ~/.vim/bundle/vim-speeddating
""supertab, adds <Tab> for tab completion
"!git clone git://github.com/ervandew/supertab ~/.vim/bundle/supertab
""syntastic, inline syntax checking for vim
"!git clone https://github.com/scrooloose/syntastic.git ~/.vim/bundle/syntastic
""surround: use e.g. ds( to delete surrounding (
"!git clone git://github.com/tpope/vim-surround.git
""swift.vim, syntax+indent files for Swift
"!git clone git://github.com/keith/swift.vim ~/.vim/bundle/swift.vim
""targets.vim allows movements like cin" (change in next ") and da,
"!git clone git://github.com/wellle/targets.vim.git ~/.vim/bundle/targets.vim
""tbone allows tmux commands
"!git clone git://github.com/tpope/vim-tbone.git
""tern_for_vim
"!git clone https://github.com/ternjs/tern_for_vim ~/.vim/bundle/tern_for_vim
""vim-toml, adds syntax support for TOML files
"!git clone https://github.com/cespare/vim-toml ~/.vim/bundle/vim-toml
""typescript-vim
"!git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/bundle/typescript-vim
"" vim-jsx-typescript (needed alongside typescript-vim)
"!git clone https://github.com/peitalin/vim-jsx-typescript ~/.vim/bundle/vim-jsx-typescript
""unimpaired - add a bunch of handy bracket mappings
"!git clone https://github.com/tpope/vim-unimpaired ~/.vim/bundle/vim-unimpaired
"""}}}
"""{{{ vwxyz
""vertical move, adds a vertical move motion to move without changing the cursor column
"!git clone git://github.com/bruno-/vim-vertical-move.git ~/.vim/bundle/vim-vertical-move
""visual-star-search, allows * operator on visual words (and <leader>* to vimgrep)
"!git clone https://github.com/bronson/vim-visual-star-search ~/.vim/bundle/vim-visual-star-search
""vim-vue, syntax highlighting for Vue.js components
"!git clone https://github.com/posva/vim-vue.git ~/.vim/bundle/vim-vue
""fugitive is a git plugin
"!git clone git://github.com/tpope/vim-fugitive.git ~/.vim/bundle/vim-fugitive
"!git clone https://github.com/bronson/vim-trailing-whitespace ~/.vim/bundle/vim-trailing-whitespace
"""}}}
"Rebuild help tags (comes with pathogen): should be done after any new install
"tag: update docs update documentation
":Helptags
"PLUGIN CONFIGURATION {{{
"ALE configuration
let g:ale_lint_on_save = 1
let g:ale_lint_on_enter = 0
let g:ale_fix_on_save = 0
let g:ale_linters = {
\ 'python': [
\ 'flake8',
\ ],
\}
" \ 'mypy',
" \ 'pylint'
let g:ale_virtualenv_dir_names = ['.env', 'env', 've-py3', 've', 'virtualenv', '.venv']
let g:ale_python_pylint_executable = 'pylint'
" let g:ale_python_pylint_options="--rcfile=~/.pylintrc"
let g:ale_python_pylint_options="--load-plugins pylint_django"
" E2 - Fix missing whitespace around X
" E27 - Fix missing whitespace around X
" E3x - Line-related. Like add missing blank line, remove extra blank line...
" E7x - multiple spaces/tabs before/after keyword
let g:ale_python_autopep8_options = '--select E2,E251,E3,E27'
let g:ale_fixers = {
\ 'python': [
\ 'trim_whitespace',
\ 'remove_trailing_lines',
\ 'autopep8',
\ ],
\ 'javascript': [
\ 'remove_trailing_lines',
\ 'eslint',
\ ],
\ }
"\ 'isort',
" coc configuration
let g:coc_global_extensions = ['coc-tsserver']
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')
xmap <leader>f <Plug>(coc-format-selected)
nnoremap <leader>f :call CocAction('format')<cr>
nmap <leader>rn <Plug>(coc-rename)
" c as in "correct" something
nmap <leader>c <Plug>(coc-codeaction-selected)<cr>
"ack-vim configuration
"Change default size of copen window in ag from 10 to 7
"let g:ag_qhandler="copen 7"
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" The dir one means /__pycache__ OR /.git OR /.hg OR /.svn
" TODO: migrate to fzf
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](__pycache__|node_modules|target|target/release|target/debug|target/doc|\.(git|hg|svn)|htmlcov|TAGS|tags)$',
\ 'file': '\v\.(exe|so|dll|pyc)$',
\ }
" Add <c-o> to AcceptSelection("h") and don't use it for OpenMulti()
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>', '<c-o>'],
\ 'OpenMulti()': [],
\ }
""Deoplete configuration
if has("macunix")
if !empty(glob("/Users/rasmus.ansin")) " Valtech laptop
let g:deoplete#sources#rust#racer_binary='/Users/rasmus.ansin/.cargo/bin/racer'
let g:deoplete#sources#rust#rust_source_path='/Users/rasmus.ansin/src/rust/src/src'
else
let g:deoplete#sources#rust#racer_binary='/Users/ran/.cargo/bin/racer'
let g:deoplete#sources#rust#rust_source_path='/Users/ran/rust/src/src'
endif
else
let g:deoplete#sources#rust#racer_binary='/home/ran/.cargo/bin/racer'
let g:deoplete#sources#rust#rust_source_path='/home/ran/src/rust/src/src'
endif
let g:deoplete#sources#rust#documentation_max_height=40
""incsearch configuration
"map / <Plug>(incsearch-forward)
map ? ?
map g/ <Plug>(incsearch-stay)
let g:incsearch#auto_nohlsearch = 1
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#)
""EasyMotion configuration
"if exists('g:EasyMotion_loaded')
"Without this, bundle/vim-easymotion/plugin/EasyMotion.vim:237 will set
"the easymotion-prefix to <leader><leader>, which is not wanted
map <Leader><Leader><Leader> <Plug>(easymotion-prefix)
map S <Plug>(easymotion-s)
let g:EasyMotion_keys = 'asdghklqwertuiopzxcvbnmfj1234890'
"use smartcase, e.g. case-insensitive search unless search starts with a capital
let g:EasyMotion_smartcase = 1
"'Type Enter or Space key and jump to first match.'
let g:EasyMotion_enter_jump_first = 1
"endif
" fzf.vim configuration
set rtp+=/usr/local/opt/fzf
set rtp+=~/.fzf
nnoremap <c-p> :Files<cr>
if executable('rg')
nnoremap <leader>a :Rg<cr>
else
nnoremap <leader>a :Ag<cr>
endif
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
let g:fzf_layout = { 'down': '50%' }
" Hide the status bar while the :Ag window is open, then re-add it when done
autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
""Gitgutter configuration
"Starts disabled:
let g:gitgutter_enabled = 0
nnoremap <leader>gg :let g:gitgutter_enabled = 1<cr>:GitGutterEnable<cr>
nnoremap <leader>gG :let g:gitgutter_enabled = 0<cr>:GitGutterDisable<cr>
nnoremap <leader>gn :GitGutterEnable<cr>:GitGutter<cr>:GitGutterNextHunk<cr>
nnoremap <leader>gN :GitGutterEnable<cr>:GitGutter<cr>:GitGutterPrevHunk<cr>
"nnoremap <leader>gs :Gstatus<cr>30<c-w>+
nnoremap <leader>gs :GitGutterStageHunk<cr>
nnoremap <leader>gd :Gdiff<cr>
nnoremap <leader>gb :Gblame<cr>
nnoremap <leader>gc :Gcommit<cr>
""vim-jedi configuration
"let g:jedi#auto_initialization = 0
let g:jedi#smart_auto_mappings = 0
let g:jedi#popup_on_dot = 0
let g:jedi#show_call_signatures_delay = 0
" Change this to use Python3 Python 3
" let g:jedi#force_py_version = 3
""LanguageClient-neovim configuration
" set rtp+=~/.vim/bundle/LanguageClient-neovim
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['rust-analyzer', 'rustup', 'run', 'stable', 'rls'],
" \ }
"