-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
1290 lines (1266 loc) · 44.1 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
" vim: foldmethod=marker path=~/.vim/plugged isf-=/ foldcolumn=3 tw=0 ts=8
let mapleader = "\<Space>"
" Plugins {{{
" vim-plug {{{
set nocompatible
augroup vimrc
autocmd!
augroup END
if 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 vimrc VimEnter * PlugInstall --sync | source $MYVIMRC
endif
autocmd vimrc FileType vim-plug map <buffer> ; o
call plug#begin('~/.vim/plugged')
" }}}
Plug 'junegunn/fzf' "{{{
Plug 'junegunn/fzf.vim'
let g:fzf_prefer_tmux = 0
let g:fzf_command_prefix = 'Fzf'
" TODO
" -make edit of command default (not c-e)
" -add support for Redir
nmap <c-r> :FzfHistory:<cr>
nmap <c-e> :FzfHistory/<cr>
let g:fzf_tags_command = 'ctags -R'
command! Colors call fzf#vim#colors({'right': '15%', 'options': '--reverse --height=100%'})
" TODO: Make BLines/Lines support preview as well.
" command! -bang -nargs=* FzfLines
" \ call fzf#vim#lines(<q-args>,
" \ <bang>0 ? fzf#vim#with_preview('up:60%')
" \ : fzf#vim#with_preview('right:50%'),
" \ <bang>0)
command! -bang -nargs=* FzfAg
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%'),
\ <bang>0)
command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
let g:fzf_layout = { 'down': '~70:%' }
inoremap <expr> <c-x><c-l> fzf#complete('tmuxwords.rb --all-but-current --scroll 499 --min 5')
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
" imap <c-x><c-L> <plug>(fzf-complete-line)
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
map <leader>T :FzfTags<cr>
map <leader>M :FzfMarks<cr>
map <leader>h :tabnew<cr>:FzfHelptags<cr>:only<cr>
map <leader>la :FzfAg<cr>
map <leader>ll :FzfBLines<cr>
map <leader>lL :FzfLines<cr>
map <leader>CA :FzfCommands<cr>
nmap <leader>ca :FzfCommands<cr>
"
nnoremap <silent> <Leader>` :FzfMarks<CR>
function! GetSelected()
" save reg
let reg = '"'
let reg_save = getreg(reg)
let reg_type = getregtype(reg)
" yank visually selected text
silent exe 'norm! gv"'.reg.'y'
let value = getreg(reg)
" restore reg
call setreg(reg, reg_save, reg_type)
return value
endfunction
vnoremap <leader>ll :<c-u>execute("FzfBLines ") . GetSelected()<cr>
vnoremap <leader>lL :<c-u>execute("FzfLines ") . GetSelected()<cr>
vnoremap <leader>la :<c-u>execute("FzfAg ") . GetSelected()<cr>
" map <leader>b :FzfBuffers<cr>
map <leader>b :FzfHistory<cr>
map <leader>lc :FzfCommits<cr>
map <leader>lC :FzfBCommits<cr>
map <leader>CA :FzfCommands<cr>
map <leader>ff :FzfFiles<cr>
map <leader>lf :FzfFiles<cr>
map <leader>lt :FzfFiletypes<cr>
map <leader>w :FzfWindows<cr>
" }}}
Plug 'tpope/vim-fugitive' "{{{
"}}}
Plug 'tpope/vim-rhubarb'
" HELP: Find out why the screwed up map works and the other one NOT!
" nmap <leader>gd :Gvdiff<cr><c-w>l
nmap <silent> <leader>gd :TagbarClose<cr>:Gvdiff<cr>:ERROR<cr>:set nofoldendable<cr>:wincmd l<cr>
nmap <leader>gD :Gdelete<cr>:ERROR<cr>:wincmd L<cr>
nmap <leader>gc :tabnew<cr>:Gcommit --verbose<cr>:only<cr>
nmap <leader>gC :tabnew<cr>:Gcommit --verbose --amend<cr>:only<cr>
nmap <leader>gx dp:wincmd h<cr>:update<cr>:wincmd l<cr>
nmap <leader>gs :tabnew<cr>:Gstatus<cr>o
nmap <leader>gb :Gblame<cr>
nmap <leader>gp :Gpush<cr>
nmap <leader>gw :Gwrite<cr>
nmap <leader>gg :Git
nmap <leader>gl :silent! Glog --<cr>:bot copen<cr>
" TODO: Find out why this end up in the left window
autocmd vimrc FileType gitcommit,fugitive map <buffer> ; odvlzi
autocmd vimrc FileType gitcommit map <buffer> <leader>C :Gcommit\ --verbose<cr>
autocmd vimrc FileType gitrebase map <buffer> ; :execute("only\|bo Gvsplit " . substitute(getline('.'), '^\k\+\s\(\x\+\)\s.*$','\1','g'))<cr>
" autocmd vimrc FileType gitcommit map <buffer> ; :only<cr>dv
" Enable spell checking for commit messages
autocmd vimrc BufNewFile,BufReadPost *.git/COMMIT_EDITMSG setfiletype gitcommit | set spell | silent! nunmap ;
autocmd vimrc BufReadPost /tmp/cvs*,svn-commit.tmp*,*hg-editor* setlocal spell
" }}}
Plug 'gregsexton/gitv'
Plug 'junegunn/gv.vim' "{{{
nmap <leader>gv :GV<cr>
nmap <leader>gV :GV!<cr>
vmap Gv :GV!<cr>
vmap GV :GV?<cr>
autocmd vimrc FileType GV map <buffer> ; o
autocmd vimrc FileType GV map <buffer> l ;
autocmd vimrc FileType GV map <buffer> O
" }}}
Plug 'AndrewRadev/splitjoin.vim'"{{{
let g:splitjoin_quiet=0
"}}}
Plug 'inkarkat/vim-CompleteHelper' "{{{
Plug 'inkarkat/vim-ingo-library'
Plug 'vim-scripts/PrevInsertComplete'
Plug 'vim-scripts/MotionComplete'
Plug 'vim-scripts/BracketComplete'
Plug 'vim-scripts/MultiWordComplete'
Plug 'inkarkat/vim-WORDComplete'
Plug 'https://github.com/vim-scripts/AlphaComplete'
Plug 'https://github.com/inkarkat/vim-PatternComplete'
"}}}
" Plug 'inkarkat/vim-session'"{{{
" let g:session_autoload = 'yes'
" let g:session_default_to_last = 'yes'
" let g:session_autosave = 'yes'
" let g:session_autosave_to = 'yes'
" let g:session_autosave_periodic = 'yes'
" let g:session_autosave_periodic = 'yes'
" let g:session_persist_globals = ['&makeprg', '&makeef']
" -save session periodically
" -check vim-obsession
autocmd vimrc VimLeave * mksession! ~/.vim/lastsession
" TODO: Use fnamemodify() or fnameescape()
" let &viminfo="'50,<1000,s100,:9999,/9999,n~/.vim/viminfo/" . substitute($PWD, "/\| ", "_", "g")
let &viminfo="'50,<1000,s100,:9999,/9999,n~/.vim/viminfo/" . substitute(substitute($PWD, "/", "_", "g"), " ", "_", "g")
"}}}
Plug 'airblade/vim-gitgutter', {'on': 'GitGutterToggle'} "{{{
let g:gitgutter_highlight_lines = 0
let g:gitgutter_override_sign_column_highlight = 1
highlight clear SignColumn
highlight GitGutterAdd ctermbg=black
map <leader>gG :GitGutterToggle<cr>
" }}}
Plug 'junegunn/vim-github-dashboard', {'on': 'GHActivity'} "{{{
let g:github_dashboard = { 'username': 'dsh2', 'password': $GHD_GITHUB_TOKEN }
" }}}
" Plug 'zhaocai/GoldenView.Vim' "{{{
" let g:goldenview__enable_default_mapping = 0
" let g:goldenview__ignore_urule = { 'filetype': ['man'] }
" nmap <silent> <c-w>= <Plug>GoldenViewResize
" autocmd BufEnter * call s:ResizeSplit()
" command ResizeSplit call s:ResizeSplit()
"}}}
Plug 'Shougo/unite.vim', {'on': 'Unite'} "{{{
nnoremap <silent> <leader>lb :<C-u>Unite buffer file_mru<CR>
nnoremap <silent> <F3> :Unite buffer<cr>
autocmd vimrc FileType unite map <buffer> <F3> q
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'Shougo/neomru.vim'
let g:neomru#time_format='%F %T '
let g:neomru#update_interval=60
"}}}
Plug 'will133/vim-dirdiff', { 'on': 'DirDiff'} "{{{
" let g:DirDiffExcludes = "*.class,*.exe,.*.swp,*.so,*.img"
" Plug 'rickhowe/diffchar.vim'
" let g:DiffUnit = 'Word1'
" let g:DiffColors = 0 " fixed color
" " let g:DiffColors = 1 " 4 colors in fixed order
" Plug 'rickhowe/spotdiff.vim'
" noremap <leader>ldt :Diffthis<CR>
" noremap <leader>ldr :Diffoff!<CR>
" noremap <leader>ldo :Diffoff!<CR>
" " }}}
Plug 'Ilink/cscope-quickfix' "{{{
set cscopepathcomp=2
" set cscopeprg=/opt/local/bin/cscope
set cscopetag
set cscopequickfix=s-,c-,d-,i-,t-,e-
set cscoperelative
if filereadable("cscope.out")
silent! cscope add cscope.out
endif
set cscopeverbose
function! QfLlNext()
windo if &l:buftype == "quickfix" | silent! cnext | if &l:buftype == "location" | silent! lnext | endif | endif
endfunction
nnoremap <C-n> :call QfLlNext()<cr>
function! QfLlPrevious()
windo if &l:buftype == "quickfix" | silent! cprevious | if &l:buftype == "location" | silent! lprevious | endif | endif
endfunction
nnoremap <C-p> :call QfLlPrevious()<cr>
" FIXME: does not work :(
autocmd vimrc FileType qf set norelativenumber
autocmd vimrc FileType qf wincmd J
"}}}
Plug 'hari-rangarajan/CCTree' "{{{
" TODO:
" let g:CCTreeCscopeDb = ".cscope/out"
" autocmd vimrc BufNewFile,BufReadPost CCTree-View nnoremap q :echo q
let g:CCTreeCscopeDb = "cscope.out"
let g:CCTreeDisplayMode = 1
let g:CCTreeHilightCallTree=1
let g:CCTreeMinVisibleDepth = 3
let g:CCTreeOrientation = "topleft"
let g:CCTreeRecursiveDepth = 1
let g:CCTreeUseUTF8Symbols = 1
let g:CCTreeWindowWidth = -1
let g:CCTreeDbFileMaxSize = 40000000
let g:CCTreeKeyHilightTree = '<C-h>' " Static highlighting
let g:CCTreeKeyDepthPlus = '='
let g:CCTreeKeyDepthMinus = '-'
" -re-use tree control code for uftrace, etc
" map ; to preview
" -add command to load db to cscope load event
" -use async-run or similar for that
" }}}
" Plug 'text objects' {{{
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-indent'
Plug 'kana/vim-textobj-fold'
let g:textobj_function_no_default_key_mappings = 1
xmap aF <Plug>(textobj-function-a)
vmap aF <Plug>(textobj-function-a)
xmap iF <Plug>(textobj-function-i)
vmap iF <Plug>(textobj-function-i)
Plug 'kana/vim-textobj-function'
Plug 'kana/vim-textobj-line'
Plug 'kana/vim-textobj-entire'
Plug 'kana/vim-textobj-lastpat'
" Plug 'paulhybryant/vim-textobj-path'
Plug 'coderifous/textobj-word-column.vim'
Plug 'vim-scripts/argtextobj.vim'
Plug 'thinca/vim-textobj-between'
Plug 'adriaanzon/vim-textobj-matchit'
xmap a% <Plug>(textobj-matchit-a)
omap a% <Plug>(textobj-matchit-a)
xmap i% <Plug>(textobj-matchit-i)
omap i% <Plug>(textobj-matchit-i)
Plug 'beloglazov/vim-textobj-quotes'
xmap q iq
omap q iq
" Plug 'rhysd/vim-textobj-continuous-line'
Plug 'kana/vim-textobj-datetime'
Plug 'vim-utils/vim-space'
" Plug 'rsrchboy/vim-textobj-heredocs'
Plug 'Julian/vim-textobj-variable-segment'
Plug 'whatyouhide/vim-textobj-xmlattr'
" }}}
Plug 'gcmt/taboo.vim' "{{{
let g:taboo_tab_format = "[%N|%f(%W)%m] "
" let g:taboo_tab_format = "[%N|%a/%f(%W)%m] "
let g:taboo_renamed_tab_format ="[%N|%l%m(%W)] "
" TODO: Make this work
let g:taboo_unnamed_tab_label = '%a'
nmap <leader>tR :TabooReset<cr>
nmap <leader>tr :TabooRename
nmap <leader>tn :TabooOpen
nmap <leader>, gT
nmap <leader>. gt
map <c-1> gT
map <c-2> gt
" TODO: Make this indeed pwd, same for TabooOpen
nmap <leader>N :tabnew<cr>:pwd<cr>
nmap <leader>tn :$tabnew<cr>
nmap <leader>tc :tabclose<cr>
" }}}
Plug 'francoiscabrol/ranger.vim', {'on': 'Ranger'}"{{{
map <leader>F :Ranger<cr>
"}}}
Plug 'milkypostman/vim-togglelist' "{{{
nmap <leader><c-j> :colder<CR>
nmap <leader><c-k> :cnewer<CR>
" }}}
Plug 'mbbill/undotree', {'on': 'UndotreeToggle'} "{{{
let g:undotree_WindowLayout = 2
let g:undotree_SetFocusWhenToggle = 1
" let g:undotree_DiffCommand = "diff -y"
let g:undotree_DiffCommand = "diff -U 5"
let g:undotree_DiffpanelHeight = 25
let g:undotree_TreeNodeShape = "o"
nnoremap <F4> :UndotreeToggle<cr>
autocmd vimrc FileType undotree nmap <buffer> ; <cr>
" }}}
Plug 'vim-pandoc/vim-pandoc', {'for': ['pandoc', 'markdown']} "{{{
Plug 'vim-pandoc/vim-pandoc-syntax'
autocmd vimrc FileType markdown set wrap
let g:pandoc#folding#level = 9
" let g:pandoc#formatting#mode = 'hA' " hard wraps, auto smart
let g:pandoc#formatting#mode = 'h' " soft wraps
" let g:pandoc#formatting#mode = 's' " soft wraps
" let g:pandoc#formatting#mode = 'a' " autoformatting
" let g:pandoc#formatting#mode = 'A' " smart autoformatting (watch out for source code)
let g:pandoc#formatting#textwidth=79
let g:pandoc#modules#disabled = ["chdir"]
let g:pandoc#formatting#extra_equalprg="--atx-headers"
" let g:pandoc#formatting#equalprg= "pandoc -t markdown --atx-headers --columns " . g:pandoc#formatting#textwidth
let g:pandoc#formatting#smart_autoformat_on_cursormoved = 0
"}}}
Plug 'chrisbra/csv.vim', {'for': 'csv' } "{{{
" hi CSVColumnEven term=bold ctermbg=4 guibg=DarkBlue
" hi CSVColumnOdd term=bold ctermbg=5 guibg=DarkMagenta
" hi link CSVColumnOdd MoreMsg
" hi link CSVColumnEven Question
" autocmd vimrc Filetype csv hi CSVColumnEven ctermbg=4
" autocmd vimrc Filetype csv hi CSVColumnOdd ctermbg=5
let g:csv_no_column_highlight = 0
let b:csv_arrange_align = 'l*'
let g:csv_arrange_align = 'l*'
let g:csv_autocmd_arrange = 1
" TODO: If readonly set nofile?
map <leader>CT :setlocal modifiable<cr>:setlocal filetype=csv<cr>let g:csv_delim="\t"<cr>ggVG:ArrangeColumn!<cr>let b:csv_headerline = 0<cr>
map <leader>C; :setlocal modifiable<cr>:setlocal filetype=csv<cr>let g:csv_delim=";"<cr>ggVG:ArrangeColumn!<cr>let b:csv_headerline = 0<cr>
map <leader>C, :setlocal modifiable<cr>:setlocal filetype=csv<cr>let g:csv_delim=","<cr>ggVG:ArrangeColumn!<cr>let b:csv_headerline = 0<cr>
map <leader>CC :setlocal modifiable<cr>:setlocal filetype=csv<cr>ggVG:ArrangeColumn!<cr>let b:csv_headerline = 0<cr>
map <leader>CS :set noreadonly<cr>:setlocal modifiable<cr>:%s/\s\{1,\}/,/<cr>:let @/=""<cr>:setlocal filetype=csv<cr>ggVG:ArrangeColumn!<cr>let g:csv_headerline=0<cr>0
autocmd vimrc BufRead,BufNewFile *.csv set filetype=csv
" TODO: Add toggle reverse order support
autocmd vimrc FileType csv map <buffer> <leader>cs :Sort<cr>
autocmd vimrc FileType csv map <buffer> <leader>c/ :CSVSearchInColumn
autocmd vimrc FileType csv map <buffer> <leader>ca :Analyze<cr>
" TODO: Add maps for
" -Toggle aligns (left, right, etc.)
" -Number types (hex, etc.)
" }}}
" Plug 'hsanson/vim-android' "{{{
" let g:android_sdk_path = $ANDROID_SDK_ROOT
" let g:android_airline_android_glyph = 'U+f17b'
" " }}}
Plug 'kelwin/vim-smali', {'for': 'smali'} "{{{
"Plug 'alderz/smali-vim'
autocmd vimrc BufRead *.smali set filetype=smali
" }}}
Plug 'xolox/vim-lua-ftplugin', {'for': 'lua'} "{{{
Plug 'xolox/vim-misc'
" }}}
Plug 'davidhalter/jedi-vim', {'for': 'python'} "{{{
let g:jedi#completions_command = "<C-space>"
let g:jedi#goto_command = "<c-]>"
let g:jedi#auto_close_doc = 0
let g:jedi#show_call_signatures = 2
let g:jedi#show_call_signatures_delay = 0
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#use_splits_not_buffers = ""
let g:jedi#squelch_py_warning = 1
" let g:jedi#force_py_version = 3.4
" Plug 'nvie/vim-flake8'
" Plug 'xolox/vim-pyref'
" }}}
Plug 'elzr/vim-json', {'for': 'json'} "{{{
" autocmd vimrc FileType json set conceallevel=0
let g:vim_json_syntax_concealcursor = 0
" }}}
Plug 'scrooloose/nerdtree' "{{{
Plug 'Xuyuanp/nerdtree-git-plugin'
let g:NERDTreeGitStatusShowIgnored = 1
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ "Modified" : "M",
\ "Staged" : "+",
\ "Untracked" : "N",
\ "Renamed" : "R",
\ "Unmerged" : "<",
\ "Deleted" : "D",
\ "Dirty" : ">",
\ "Clean" : "C",
\ "Ignored" : 'I',
\ "Unknown" : "?"
\ }
let NERDTreeIgnore = ['\~$[[file]]', '\.pyc$[[file]]']
let NERDTreeShowHidden = 1
let NERDTreeWinSize = 46
let NERDTreeMinimalUI = 1
autocmd vimrc FileType nerdtree map <buffer> l oj^
"autocmd vimrc FileType nerdtree map <buffer> O mo
autocmd vimrc FileType nerdtree map <buffer> h x^
autocmd vimrc FileType nerdtree map <buffer> ; go
autocmd vimrc FileType nerdtree map <buffer> <F2> :NERDTreeClose<cr>
nnoremap <F2> :NERDTreeFind<cr>
" }}}
Plug 'tyru/open-browser.vim' "{{{
let g:netrw_nogx = 1 " disable netrw's gx mapping.
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
command! OpenBrowserCurrent execute "OpenBrowser" "file://" . expand('%:p:gs?\\?/?')
map gX OpenBrowserCurrent
" let g:openbrowser_browser_commands = [
" \ {'name': 'google-chome',
" \ 'args': ['start', '{browser}', '{uri}']}
" \]
"}}}
Plug 'rhysd/open-pdf.vim', {'for': 'pdf'} "{{{
let g:pdf_convert_on_edit = 1
let g:pdf_convert_on_read = 1
" }}}
" Plug 'vim-scripts/taglist.vim', {'on': 'TlistToggle'} {{{
" let Tlist_Use_Right_Window = 1
" let Tlist_WinWidth = 55
" let Tlist_Display_Prototype = 1
" let Tlist_Exit_OnlyWindow = 1
" let Tlist_GainFocus_On_ToggleOpen = 0
" let Tlist_Highlight_Tag_On_BufEnter = 1
" let Tlist_Auto_Open = 1
" let Tlist_Show_One_File = 1
" map <leader>t :TlistToggle<cr>
" }}}
Plug 'dsh2/tagbar' " ", {'on': 'TagbarToggle'} " {{{
Plug 'hushicai/tagbar-javascript.vim'
let g:tagbar_autoclose = 0
" TODO: Add support for percent instead of number of characters
let g:tagbar_width = 40
let g:tagbar_zoomwidth = 0
let g:tagbar_compact = 1
let g:tagbar_indent = 1
let g:tagbar_show_linenumbers = 0
let g:tagbar_autofocus = 0
let g:tagbar_hide_nonpublic = 0
let g:tagbar_autoshowtag = 1
let g:tagbar_autopreview = 0
map <leader>tt :silent! TagbarToggle<cr>
autocmd vimrc VimEnter * nested :silent! call tagbar#autoopen(1)
" autocmd vimrc VimEnter * nested :silent! TagbarToggle
autocmd vimrc FileType tagbar map <buffer> ; p
autocmd vimrc FileType tagbar map <buffer> A x
autocmd vimrc FileType tagbar map <buffer> l za
autocmd vimrc FileType tagbar map <buffer> h za
" }}}
Plug 'jeetsukumaran/vim-markology' "{{{
let g:markology_enable = 0
let g:markology_textlower = "\t>"
let g:markology_textupper = "\t}"
let g:markology_textother = "\t:"
let g:markology_hlline_lower = 0
let g:markology_hlline_upper = 0
let g:markology_hlline_other = 0
highlight MarkologyHLl ctermfg=Cyan ctermbg=black
highlight MarkologyHLu ctermfg=Cyan ctermbg=black
highlight MarkologyHLo ctermfg=Cyan ctermbg=black
" }}}
" Plug 'mileszs/ack.vim', {'on': 'Ack'} {{{
" let g:ackhighlight = 1
" let g:ack_autofold_results = 0
" let g:ackpreview = 0
" let g:ack_use_dispatch = 1
" map <leader>a :Ack! \\b<cword\\b><CR>
" }}}
Plug 'brookhong/ag.vim', {'on': 'Ag'} "{{{
" map <leader>a :Ag! \\b<cword\\b><CR>
map <leader>a :Ag! <cword><CR>
" }}}
Plug 'szw/vim-maximizer', {'on': 'MaximizerToggle'} "{{{
nnoremap <c-w>m :MaximizerToggle<cr>
nnoremap <c-w><c-m> :MaximizerToggle<cr>
"}}}
Plug 'bling/vim-airline' "{{{
Plug 'vim-airline/vim-airline-themes'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#syntastic#enabled = 1
let g:airline#extensions#whitespace#enabled = 0
let g:airline_detect_modified=1
let g:airline_detect_spelllang=1
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
" let g:airline_section_z = '%p%% %#__accent_bold#%{g:airline_symbols.linenr}:%l%#__restore__#%#__accent_bold#/%L%{g:airline_symbols.maxlinenr} %#__restore__#%#__accent_bold# %{g:airline_symbols.colnr}:%v%#__restore__#'
let g:airline_section_z = '%3p%% %l %v %o'
" }}}
Plug 'tpope/vim-dispatch' "{{{
" map <leader>M :update<cr>:Make<cr>:copen<cr>/error:<cr>n
map <leader>m :update<cr>:Make<cr>:checktime<cr>
" }}}
Plug 'sickill/vim-pasta' "{{{
let g:pasta_disabled_filetypes = ['python', 'coffee', 'yaml', 'tagbar']
"}}}
Plug 'vim-scripts/AnsiEsc.vim', {'on': 'AnsiEsc'} "{{{
map <leader>W :AnsiEsc<cr>
" Remove ansi escape sequence
if executable("strip-ansi")
function! StripAnsi()
:silent %!strip-ansi
echo "StripAnsi: called strip-ansi-cli"
endfunction
else
function! StripAnsi()
let @/='\v%x1b[(\d{0,3})(;\d{1,3}){0,5}(m|K)'
silent! execute "%s:::"
echo "StripAnsi: search-and-replace"
endfunction
endif
command! StripAnsi call StripAnsi()
map <leader>Q :StripAnsi<cr>
"}}}
Plug 'romgrk/winteract.vim', {'on': 'InteractiveWindow'} "{{{
nmap gw :InteractiveWindow<CR>
"}}}
Plug 'Shougo/vinarise.vim', {'on': 'Vinarise'} "{{{
map <leader>V :Vinarise<cr>
"}}}
Plug 'nathanaelkane/vim-indent-guides', {'on': 'IndentGuidesToggle'} "{{{
let g:indent_guides_guide_size = 1
let g:indent_guides_start_level = 2
"}}}
Plug 'junegunn/vim-peekaboo' "{{{
let g:peekaboo_window = 'vertical botright 51new'
let g:peekaboo_delay = 0
let g:peekaboo_compact = 0
"}}}
Plug 'Chiel92/vim-autoformat', {'on': 'Autoformat'} "{{{
let g:formatters_json = ['my_custom_json']
" let g:formatdef_my_custom_json = '"jq -s"'
let g:formatdef_my_custom_json = '"jq ."'
let g:autoformat_verbosemode=1
" TODO: try to understand why resetting syn is necessary
map <leader>A :Autoformat \| syn off \| syn on \" set foldlevel=1<cr>
"}}}
Plug 'tpope/vim-commentary' "{{{
autocmd vimrc BufNewFile,BufReadPost authorized_keys,known_hosts setlocal commentstring=#\ %s
autocmd vimrc FileType config,crontab,expect,exports,dosini,sshconfig,sshdconfig,sh,i3config,jq,resolv,gitconfig setlocal commentstring=#\ %s
autocmd vimrc FileType autohotkey setlocal commentstring=;\ %s
nmap gcC yygccp
"}}}
let g:go_version_warning = 0
Plug 'fatih/vim-go', {'for': 'go'} "{{{
map gD :GoDocBrowser<cr>
"}}}
Plug 'dsh2/diff-fold.vim', {'for': 'diff'} "{{{
autocmd vimrc FileType diff map <buffer> <leader>d <Plug>DiffFoldNav
"}}}
Plug 'idanarye/vim-merginal' "{{{
" Plug 'idanarye/vim-merginal', {'on': 'MerginalToggle'} "
" TODO: Find out why on-load tag does not work
map <leader>gm :MerginalToggle<cr>
map <leader>y :MerginalToggle<cr>
"}}}
Plug 'skywind3000/asyncrun.vim', {'on': 'AsyncRun'} "{{{
map <leader>B :AsyncRun binwalk %<cr>
autocmd vimrc User AsyncRunStart call asyncrun#quickfix_toggle(8, 1)
autocmd vimrc BufReadPost .\\\{0,1\}vimrc nnoremap <buffer> <silent> <cr> 0f/lgf
"}}}
Plug 'atimholt/spiffy_foldtext' "{{{
" TODO: Add more preview text, squece as much content as possible?
let g:SpiffyFoldtext_format='%c{-} %<%f{-}| %4n lines |-%l{--}'
"}}}
Plug 'dsh2/HiCursorWords' "{{{
let g:HiCursorWords_delay = 10
let g:HiCursorWords_hiGroupRegexp = ''
" let g:HiCursorWords_style='term=reverse cterm=reverse gui=reverse'
" let g:HiCursorWords_linkStyle='ErrorMsg'
" let g:HiCursorWords_linkStyle='IncSearch'
let g:HiCursorWords_linkStyle='MatchParen'
" let g:HiCursorWords_linkStyle='VisualNOS'
" let g:HiCursorWords_debugEchoHiName = 1
let g:HiCursorWords_debugEchoHiName = 0
" }}}
Plug 'flatcap/vim-keyword' "{{{
" TODO: Make this work
map <leader>k <plug>KeywordToggle
map <leader>K :call keyword#KeywordClear()<cr>
let g:keyword_group = 'keyword_group'
" let g:keyword_highlight = 'ctermbg=darkred cterm=underline'
let g:keyword_highlight = 'ctermbg=darkred'
"}}}
Plug 'vim-scripts/LargeFile'"{{{
let g:LargeFile = 50
set synmaxcol=2048"}}}
Plug 'w0rp/ale' "{{{
let g:airline#extensions#ale#enabled = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_open_list = 0
let g:ale_keep_list_window_open = 1
let g:ale_fix_on_save = 1
let g:ale_lint_on_enter = 1
let g:ale_lint_on_text_changed = "never"
let g:ale_open_list = "never"
" }}}
Plug 'machakann/vim-highlightedyank'"{{{
let g:highlightedyank_highlight_duration = 333
if !exists('##TextYankPost')
map y <Plug>(highlightedyank)
endif
"}}}
" Plug 'scrooloose/syntastic' "{{{
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 0
" let g:syntastic_check_on_open = 0
" let g:syntastic_check_on_wq = 0
" let g:syntastic_lua_checkers = ["luac", "luacheck"]
" let g:syntastic_lua_luacheck_args = "--no-unused-args"
" let g:syntastic_go_checkers = ['golint', 'govet', 'gometalinter']
" let g:syntastic_go_gometalinter_args = ['--disable-all', '--enable=errcheck']
" let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
" let g:go_list_type = "quickfix"
" }}}
" Plug YouCompleteMe {{{
" function! BuildYCM(info)
" if a:info.status == 'installed' || a:info.force
" !./install.py
" endif
" endfunction
" let g:loaded_youcompleteme = 0
" Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }
" let g:ycm_autoclose_preview_window_after_insertion = 1
" nnoremap <leader>jj :YcmCompleter GoTo<CR>
" nnoremap <leader>jd :YcmCompleter GoToDefinition<CR>
" nnoremap <leader>jD :YcmCompleter GoToDeclaration<CR>
" nnoremap <leader>jr :YcmCompleter GoToReferences<CR>
" nnoremap <leader>jt :YcmCompleter GetType<CR>
" nnoremap <leader>jk :YcmCompleter GetDoc<CR>
" let g:ycm_error_symbol="E>"
" let g:yvm_warning_symbol="W>"
" let g:ycm_enable_diagnostic_highlighting=1
" let g:ycm_collect_identifiers_from_comments_and_strings=1
" let g:ycm_collect_identifiers_from_tags_files=1
" }}}
Plug 'szw/vim-g'"{{{
map <leader>G :Google<cr>"}}}
" Plug tmux {{{
Plug 'tmux-plugins/vim-tmux', {'for': 'tmux'}
autocmd vimrc BufRead tmux.conf set filetype=tmux
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'wellle/tmux-complete.vim'
let g:tmuxcomplete#trigger = 'omnifunc'
"}}}
" Plug colorschemes {{{
Plug 'morhetz/gruvbox'
Plug 'rhysd/vim-color-spring-night'
Plug 'Lokaltog/vim-distinguished'
Plug 'altercation/vim-colors-solarized'
let g:solarized_termcolors=256
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
let g:solarized_diffmode="high"
Plug 'chriskempson/vim-tomorrow-theme'
Plug 'jnurmine/Zenburn'
Plug 'junegunn/seoul256.vim'
Plug 'nanotech/jellybeans.vim'
Plug 'pwntester/VimCobaltColourScheme'
Plug 'pwntester/cobalt2.vim'
Plug 'reedes/vim-colors-pencil'
Plug 'tomasr/molokai'
" Plug 'xolox/vim-colorscheme-switcher'
" Plug 'govindkrjoshi/CSApprox'
" Plug 'KevinGoodsell/vim-csexact'
" Plug 'AlessandroYorba/Monrovia'
" }}}
" Plug rest... {{{
Plug 'actionshrimp/vim-xpath'
Plug 'christianrondeau/vim-base64' "{{{
map [2 <leader>atob
map ]2 <leader>btoa
" }}}
Plug 'tpope/vim-abolish'
Plug 'jremmen/vim-ripgrep'
Plug 'mogelbrod/vim-jsonpath'" {{{
let g:jsonpath_register = '+'
"}}}
Plug 'pedrohdz/vim-yaml-folds'
Plug 'matze/vim-ini-fold'
autocmd vimrc BufNewFile,BufReadPost *.nmconnection setfiletype dosini
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-rails'
" Plug 'tpope/vim-sleuth'
Plug 'Shougo/echodoc.vim'
Plug 'Quramy/tsuquyomi'
Plug 'tommcdo/vim-exchange'
Plug 'szw/vim-dict'
Plug 'google/vim-searchindex'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'dsh2/vim-CtrlXA'
Plug 'Valloric/vim-operator-highlight'
Plug 'tmhedberg/matchit'
Plug 'chrisbra/Colorizer'
Plug 'chrisbra/Recover.vim'
Plug 'christoomey/vim-sort-motion'
Plug 'christoomey/vim-system-copy'
Plug 'dkprice/vim-easygrep'
" Plug 'dsh2/vim-man' " TODO: { 'dir': '~/.vim-man', 'do': 'git pull orig' }
Plug 'dsh2/vim-unimpaired'
Plug 'embear/vim-foldsearch'
Plug 'ervandew/matchem'
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'lzap/vim-selinux', {'for': 'te'}
Plug 'maksimr/vim-yate', {'for': 'yate'}
Plug 'mboughaba/i3config.vim', {'for': 'i3config'}
Plug 'nelstrom/vim-visual-star-search'
Plug 'tpope/vim-afterimage'
Plug 'tpope/vim-dadbod'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-tbone'
Plug 'vim-scripts/ReplaceWithRegister'
Plug 'vim-scripts/VCard-syntax', {'for': 'vcard'}
Plug 'vim-scripts/info.vim', {'on': 'Info'}
Plug 'vim-scripts/renamer.vim', {'on': 'Renamer'}
Plug 'wannesm/wmgraphviz.vim', {'for': 'dot'}
Plug 'z0mbix/vim-shfmt', { 'for': 'sh' }
Plug 'frioux/vim-regedit'
" }}}
call plug#end()
" }}}
" Global options {{{
set autoindent
set autowrite
set backspace=indent,eol,start
set backupdir=~/.vim/backup/
set cmdheight=1
set cmdwinheight=10
set complete+=kt
set concealcursor=n
set conceallevel=0
set clipboard=unnamedplus
set diffopt=
" set diffopt=filler,context:4
set dir=~/.vim/swo
set encoding=utf8
set exrc
let g:xml_syntax_folding=1
set foldmethod=syntax
set foldlevelstart=99
" set foldopen=hor,mark,percent,quickfix,search,tag,undo
set foldopen=hor,search,quickfix,tag
set gdefault
set grepprg=grep\ -nH\ $*
set hidden
set history=9999
set hlsearch
set ignorecase
set incsearch
set isfname-==
set laststatus=2
set mouse=a
set mousefocus
set nobackup
set relativenumber
set nospell
set nowrap
set linebreak
set nowrapscan
set number
set previewheight=14
set ruler
au BufEnter,BufNew,OptionSet * if &diff | set scrolloff=10 | else | set scrolloff=99 | endif
set shellslash
set shiftwidth=4
set shortmess=filnxtToOI
set showbreak=›
set showcmd
set showfulltag
set showmatch
set sidescroll=15
set sidescrolloff=8
set dictionary+=/usr/share/dict/american-english
set smartcase
set smartindent
set smarttab
set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P
" set tabstop=4
set tabstop=8
set tags+=$HOME/.usr.include.tags
set title
set titleold=''
set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}
set notimeout
set nottimeout
set ttimeoutlen=50
set undodir=~/.vim/undodir/
set undofile
set updatetime=500
set wildignore=*~,*.o,*.obj,*.aux
set wildmenu
set wildmode=list:longest,full
autocmd vimrc BufNewFile,BufReadPost Vagrantfile setfiletype ruby
autocmd vimrc BufNewFile,BufReadPost .clang-format setfiletype yaml
autocmd vimrc BufReadPost ~/.tmux-log/*,*-strace*,strace\.* setfiletype strace
" }}}
" Mappings {{{
" nmap Q :qall<cr>
nmap Q :cq<cr>
nmap <leader>J :StripAnsi<cr>:set ft=json<cr>:Autoformat<cr>:syn off \| syn on \| se foldenable foldlevel=2<cr>
nmap <leader>X :StripAnsi<cr>:set ft=xml<cr>:Autoformat<cr>
nmap <leader>Y :StripAnsi<cr>:set ft=yaml<cr>:Autoformat<cr>:syn off \| syn on \| se foldenable foldlevel=2<cr>
map
nnoremap <c-s> :update<cr>
inoremap <c-s> <c-o>:update<cr><esc>
map :bnext<cr>
map <c-.> :bprev<cr>
map <leader><c-l> :redraw!<cr>:echo "Redraw!"<cr>
nmap <leader>o :silent !open "%"<cr>
nmap <nowait> <leader>s :update<cr>
" TODO: PWD vs. CWD
map <silent><leader>R :source ~/.vimrc\| if filereadable("./.vimrc") \| source ./.vimrc \| endif<cr>
map <leader>S :syn off \| syn on \| se foldlevel=1<cr>
nnoremap <cr> :nohlsearch<CR>/<BS><CR>
imap <NUL> <space>h
" TODO: Filter ansi escape sequences from filename when file not found
nmap <leaer>gf vgf
nnoremap gf gF
" nnoremap gF :tabedit <cfile><cr>
nnoremap gF :split <cfile><cr>
map <c-w>v <c-w>v<c-w>l
vmap DP :diffput<cr>
vmap DG :diffget<cr>
nmap <leader>DD :diffthis<CR>
nmap <leader>DO :diffoff<CR>
nmap <leader>DS :vertical diffsplit<CR>
" TODO: Clean this up...
nnoremap <leader>cd :execute ":lcd " . substitute(expand("%:p:h"), ' ', '\\ ', 'g')<cr>:pwd<cr>"<cr>
nnoremap U <c-r>
nmap <c-q> :cq<cr>
nmap <leader>P :pwd<cr>
nmap zx za
nmap <leader>BD :bdelete!<cr>
" TODO: add toggle for this: coG?
function! ToggleLineBreakMode()
if maparg("j", "n") == "gj"
unmap j
unmap k
unmap gj
unmap gk
" unmap 0
" unmap g0
echo "NOT breaking lines on movement."
else
nnoremap gj j
nnoremap gk k
nnoremap j gj
nnoremap k gk
" nnoremap g0 0
" nnoremap 0 g0
echo "Breaking lines on movement."
endif
endfunction
nmap coG :call ToggleLineBreakMode()<cr>
noremap zz :set scrolloff=99<cr>zz
" Delete all matching lines
vmap <silent> <leader>D g*:%g//d<cr>
nmap <silent> <leader>D v$g*:%g//d<cr>
" TODO
" -Add convert to hex/bin/etc.
" -Parse as data-uri
" -Encode/decode as base64, uu, etc.
" -ROT13
" -Disassem ARM/Intel
map <leader>d :echo strftime('%F %T', expand("<cword>"))<cr>
" Split navigations
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>
function! YankUp(string)
let @"=a:string
if executable("clip.exe") | call system("clip.exe", a:string) | endif
if !empty($TMUX) && executable("tmux") | call system("tmux load-buffer -", a:string) | endif
if !empty($DISPLAY)
if executable("xclip") | call system("xclip -selection clipboard -in", a:string)
elseif executable("xsel") | call system("xsel -bi", a:string)
endif
endif
echo "YANK-UP: \"" . strtrans(a:string) . "\""
endfunction
" TODO: check if there is somethinkg like "register pending" mode
" command! YankUp :call YankUp(@")|echo "YankUp: " . strtrans(@")
command! YankUp :call YankUp(@")
nmap YY :YankUp<cr>
map Ypa :call YankUp(expand("%:p"))<cr>
map YP :call YankUp(expand("%:p"))<cr>
map Ypp :call YankUp(expand("%:p"))<cr>
map Ypl :call YankUp(expand("%:t") . ":" . line("."))<cr>
map Ypn :call YankUp(expand("%:t") . ":" . line("."))<cr>
map YpL :call YankUp(expand("%:p") . ":" . line("."))<cr>
map YpN :call YankUp(expand("%:p") . ":" . line("."))<cr>
map Ypf :call YankUp(expand("%:t") . ":" . tagbar#currenttag('%s', 'f'))<cr>
map YpF :call YankUp(expand("%:p") . ":" . tagbar#currenttag('%s', 'f'))<cr>
map Yps :call YankUp(expand("%:t") . ":" . tagbar#currenttag('%s:%l', 'f'))<cr>
map YpS :call YankUp(expand("%:p") . ":" . tagbar#currenttag('%s:%l', 'f'))<cr>
map Ypr :call YankUp(expand("%:."))<cr>
map Ypt :call YankUp(expand("%:t"))<cr>
map Yp. :call YankUp(expand("%:."))<cr>
" TODO: add current function (c, cpp, py, etc.)
" }}}
" Special operations {{{
" Setup colorschema{{{
" au BufEnter,BufNew,OptionSet * if &diff | let g:solarized_diffmode="normal" | colorscheme solarized | set diffopt= | else | colorscheme Tomorrow-Night | endif
" TODO:
" -output name of schema
" -make schema persist over session
nmap <F6> :NextColorScheme<CR>
map <leader>n :colorscheme Tomorrow-Night<cr>
map <leader>c :colorscheme
try
colorscheme seoul256 | let g:airline_theme='qwq'
" colorscheme gruvbox| let g:airline_theme='pencil'
" colorscheme spring-night | let g:airline_theme='night_owl'
" colorscheme solarized | let g:airline_theme='solarized_flood'
catch
endtry
hi Folded cterm=NONE
nnoremap zO zczO
nnoremap zm zM
nnoremap zM zm
" TODO: Add "default" foldexprs for
" -ascii trees (uftrace,etc.)
" -dash/line separators
" foldexpr for path-like lists
function! FoldExprAsciiTree(lnum)
return len(split(getline(a:lnum), "/"))
endfunction
function! FoldExprPath(lnum)
return len(split(getline(a:lnum), "/"))
endfunction
" foldexpr for single space indention
function! FoldExprSpace(lnum)
return matchend(getline(a:lnum), "\\S")
endfunction
set foldexpr=FoldExprSpace(v:lnum)
"}}}
" Open log files at the bottom of the file{{{
" TODO: autocmd.txt is not so clear about the the interpretation of slashes in face of multiple comma-separated {pat}s
autocmd vimrc BufReadPost *.log normal G
autocmd vimrc BufReadPost */log/* normal G
autocmd vimrc BufReadPost *.log :set filetype=messages
"}}}
" Restore last position in file upon opening a file{{{
autocmd BufReadPost * call RestorePosition()
function! RestorePosition()
if !exists("b:_goto_pos") || b:_goto_po
if line("'\"") > 0
if line("'\"") <= line("$")
execute "norm `\""
else
execute "norm $"
endif
endif
else
let b:_goto_pos = 1
endif
endfunction
"}}}
" Configure help system {{{
runtime! ftplugin/man.vim
nmap K :exe "Vman " . expand("<cword>") <CR>
autocmd vimrc FileType man set sidescrolloff=0
autocmd vimrc FileType man wincmd L
let g:ft_man_open_mode = 'vert'
let g:ft_man_folding_enable = 1
autocmd vimrc FileType vim nmap <buffer> K :exe "help " . expand("<cword>")<CR>
autocmd vimrc FileType help nmap <buffer> q <c-w>c
autocmd vimrc FileType help set nonumber
autocmd vimrc FileType help set sidescrolloff=0
autocmd vimrc FileType help wincmd L
" autocmd vimrc FileType help wincmd L | vert resize 80
" }}}
" Setup cursorcolumn {{{
" Add a cursorline(/cursorcolumn) to the active window
" autocmd vimrc BufWinLeave * set nocursorline |
" \ highlight CursorLineNr ctermbg=grey
autocmd vimrc BufRead,BufNewFile *.strace set filetype=strace
autocmd vimrc BufWinEnter * set cursorline |
\ highlight CursorLineNr ctermfg=white |
\ highlight CursorLineNr ctermbg=red |
\ highlight CursorLine cterm=underline
set cursorline
set cursorcolumn
" }}}
" Setup listchars {{{
" set listchars=tab:\|\ ,trail:+,extends:>,precedes:<,nbsp:.
" TODO: the following setting gives very slow rendering on macOS
set listchars=tab:‣\ ,trail:_,extends:↦,precedes:↤,nbsp:∙
" set listchars=tab:→\ ,trail:·,eol:¬,extends:…,precedes:…
" let &showbreak = '↳'
" set list
highlight SpecialKey ctermfg=DarkRed ctermbg=NONE
highlight NonText ctermfg=DarkGreen ctermbg=NONE
" }}}
" Setup spell checking {{{
hi SpellBad ctermbg=none ctermfg=red cterm=undercurl
nmap <leader>zz ]seas
nmap zZ :spellr<cr>
set lazyredraw
au BufRead *.md set filetype=markdown | if expand("%:p") =~ '.*/Notizen/.*' | echo "spell german" | setl spelllang="de_20" | else | echo "NO german" | endif
" }}}
" Function: removes trailing spaces {{{