-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
1715 lines (1522 loc) · 55.5 KB
/
.vimrc
File metadata and controls
1715 lines (1522 loc) · 55.5 KB
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
" ===
" === Auto load for first time uses
" ===
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 VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" ===
" === Create a _machine_specific.vim file to adjust machine specific stuff, like python interpreter location
" ===
let has_machine_specific_file = 1
if empty(glob('~/.config/_machine_specific.vim'))
let has_machine_specific_file = 0
silent! exec "!cp ~/.config/default_configs/_machine_specific_default.vim ~/.config/_machine_specific.vim"
endif
" Open vim display Garbage R^[[>1;4205;0c^[]10;rgb:ffff/ffff/ffff^G
" But one side-effect of this setting is broken setting background auto-detection
" set t_RB= t_RF= t_RV= t_u7= t_ut=
" when opening vim have latency and Dispaly >4;2m.Maybe it's because of Xmodmap .
" let &t_TI = ""
" let &t_TE = ""
" Change cursor shape in different modes
" [Refer](https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes)
let &t_SI.="\e[6 q" "SI = INSERT mode 6 -> solid vertical bar
let &t_SR.="\e[4 q" "SR = REPLACE mode 4 -> solid underscore
let &t_EI.="\e[2 q" "EI = NORMAL mode 2 -> solid block
" Vim overrule your settings(Highlight colors) with the defaults, use: > `:syntax on`
syntax enable
set nocompatible
filetype on
filetype plugin indent on
set encoding=UTF-8
set fileencodings=utf-8,sjis,gbk,default
" Shift+insert paste from system clipboard without any dependency.
" vim version feature must include clipboard.
" I recommend nvim more.
" `"+y` means to first press `"` release then press `+` finally press `y`
set clipboard=unnamedplus
" Copy/Paste. vim must be running when using shared clipboard.
vnoremap Y "+y
nnoremap Y "+yy
" nnoremap <C-b> "*p
" tab to indentation.
vmap <tab> >gv
vmap <s-tab> <gv
" Move up/down the selected lines in visual mode.
vnoremap <c-p> :m '<-2<CR>gv=gv
vnoremap <c-n> :m '>+1<CR>gv=gv
nnoremap <c-p> V:m '<-2<CR>gv=gv<esc>
nnoremap <c-n> V:m '>+1<CR>gv=gv<esc>
let mapleader=" "
set scrolloff=3 "at least 3 lines on the screenup and screendown
noremap <LEADER>sb :set scrollbind!<CR>
set tabstop=4
autocmd BufNewFile,BufRead *.c.orig set syntax=c
autocmd BufNewFile,BufRead *.nas,*.asm set filetype=asm
autocmd FileType python,asm set expandtab
set shiftwidth=4
set softtabstop=4
" :help 'whichwrap, [Automatically wrap left and right].
" By default, when pressing left/right cursor keys
" Vim will not move to the previous/next line after reaching first/last character in the line.
set whichwrap+=<,>,[,]
" :help 'backspace
set backspace=indent,eol,start
set list
" set listchars=tab:\|\ ,trail:▫
set listchars=tab:\|\ ,trail:■
set wrap
" close autowrap at insert mode.when textwidth > x, text will auto wrap
set textwidth=0
set ruler
set cursorline
set number
set relativenumber
set autochdir " auto change working directory
set showcmd
set wildmenu
set mouse=nv
" set noswapfile
set hlsearch
exec "nohlsearch"
set incsearch
set ignorecase
set smartcase
set autoindent
set nofoldenable
set foldmethod=manual
"To move to a misspelled word, use ]s and [s.
"use z=, open suggest list.
"use zg, add the word to vim dictionary. zw to mark words as incorrect.
set spell spelllang=en_us
""" setlocal spell
""" set spelllang=nl,en_gb
""" inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
" spell checking
noremap <LEADER>ss :set spell!<CR>
set nospell
set ttimeoutlen=100 " reduce latency of swithing input method for Plug fcitx.vim
" :help keycode
" <m-s> == Alt+s ?, they are unequal in ubuntu.
" j/k will move virtual lines (lines that wrap)
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" nnoremap j jzz
" nnoremap k kzz
noremap J 5j
noremap K 5k
" ^ to first non-blank character, 0 to first character.
" noremap H 0
" noremap L $
noremap W 5w
noremap B 5b
" nnoremap <CR> o<Esc>
nnoremap <S-CR> i<CR><Esc>
nnoremap <C-k> Hzz
nnoremap <C-j> Lzz
" it would be prone to bugs if mapping : ;.
" noremap ; :
" copy current filepath and line
" nnoremap y. :let @+ = expand("%") . ':' . line(".")<cr>
"===
"=== Window Manage
"===
" Disable the default s key
noremap s <nop>
" split the screens
map sk :set nosplitbelow<CR>:split<CR>:set splitbelow<CR>
map sj :set splitbelow<CR>:split<CR>
map sh :set nosplitright<CR>:vsplit<CR>:set splitright<CR>
map sl :set splitright<CR>:vsplit<CR>
" has() is a system command. use it as little as possible. Maybe, not sure.
" Maybe conflict with your terminator's shortcuts.
" Please resolve conflicts
if !has('nvim')
execute "set <M-w>=\ew"
execute "set <M-h>=\eh"
execute "set <M-j>=\ej"
execute "set <M-k>=\ek"
execute "set <M-l>=\el"
execute "set <M-0>=\e0"
execute "set <M-1>=\e1"
execute "set <M-2>=\e2"
execute "set <M-3>=\e3"
execute "set <M-4>=\e4"
execute "set <M-5>=\e5"
execute "set <M-6>=\e6"
execute "set <M-7>=\e7"
execute "set <M-8>=\e8"
execute "set <M-9>=\e9"
endif
" Terminal mode:
tnoremap <M-h> <c-\><c-n><c-w>h
tnoremap <M-j> <c-\><c-n><c-w>j
tnoremap <M-k> <c-\><c-n><c-w>k
tnoremap <M-l> <c-\><c-n><c-w>l
" Insert mode:
inoremap <M-h> <Esc><c-w>h
inoremap <M-j> <Esc><c-w>j
inoremap <M-k> <Esc><c-w>k
inoremap <M-l> <Esc><c-w>l
" Visual mode:
vnoremap <M-w> <Esc><c-w>w
vnoremap <M-h> <Esc><c-w>h
vnoremap <M-j> <Esc><c-w>j
vnoremap <M-k> <Esc><c-w>k
vnoremap <M-l> <Esc><c-w>l
" Normal mode:
nnoremap <LEADER>h <c-w>h
nnoremap <LEADER>j <c-w>j
nnoremap <LEADER>k <c-w>k
nnoremap <LEADER>l <c-w>l
map <LEADER>1 1<C-w><C-w>
map <LEADER>2 2<C-w><C-w>
map <LEADER>3 3<C-w><C-w>
map <LEADER>4 4<C-w><C-w>
map <LEADER>5 5<C-w><C-w>
map <LEADER>6 6<C-w><C-w>
map <LEADER>7 7<C-w><C-w>
map <LEADER>8 8<C-w><C-w>
map <LEADER>9 9<C-w><C-w>
map <LEADER>0 10<C-w><C-w>
nnoremap <M-h> <c-w>h
nnoremap <M-j> <c-w>j
nnoremap <M-k> <c-w>k
nnoremap <M-l> <c-w>l
map <M-1> 1<C-w><C-w>
map <M-2> 2<C-w><C-w>
map <M-3> 3<C-w><C-w>
map <M-4> 4<C-w><C-w>
map <M-5> 5<C-w><C-w>
map <M-6> 6<C-w><C-w>
map <M-7> 7<C-w><C-w>
map <M-8> 8<C-w><C-w>
map <M-9> 9<C-w><C-w>
map <M-0> 10<C-w><C-w>
" Resize splits with arrow keys
map <up> :res +5<CR>
map <down> :res -5<CR>
map <left> :vertical resize-5<CR>
map <right> :vertical resize+5<CR>
" use 'M' to maximize and 'm' to balance windows.
nnoremap <LEADER>wM <C-W>\| <C-W>_
nnoremap <LEADER>wm <C-W>=
noremap sv <C-w>t<C-w>H
noremap su <C-w>t<C-w>K
" Rotate screens
noremap srv <C-w>b<C-w>K
noremap sru <C-w>b<C-w>H
" ===
" === Tab Management
" ===
" `N Backpack` go to N tab or N buffer
" Create a new tab with tu
noremap ti :tabe<CR>
noremap tc :tabclose<CR>
noremap tC :tabonly<CR>
" Move around tabs with th and tl
noremap th :tabNext<CR>
noremap tl :tabnext<CR>
" Move the tabs with tmh and tml
noremap tmh :tabMove<CR>
noremap tml :tabmove<CR>
"noremap <LEADER>j 20J
noremap U <C-r>
noremap ` ~
nnoremap < <<
nnoremap > >>
map S :w<CR>
" Alt+Shift+q to Switch to Ex mode.
map Q :q<CR>
map R :source $MYVIMRC<CR>
map <LEADER>Q :q!<CR>
map <LEADER>R S:source $MYVIMRC<CR>
map <LEADER>rc :tabedit ~/.config/.vimrc<CR>
map <LEADER><CR> :nohlsearch<CR>
map <LEADER>n :set nonu<CR>:set norelativenumber<CR>
map <LEADER>N :set nu<CR>:set relativenumber<CR>
"Greater Indent format for copying from Internet or no
set pastetoggle=<F10>
map <LEADER>sp :set paste!<CR>
" ===
" === terminal mode
" ===
"This was because that vim couldn't execute system function in fish. Add set
"shell=sh in your vimrc.Maybe the issue has been fixed.
set shell=zsh
" :terminal can open a terminal at vim>=8.1
" ctrl+d exit terminal at insert mode.
if has('nvim')
autocmd TermOpen term://* startinsert
noremap <Bslash>py :set splitbelow<CR>:split term://ipython3<CR>
noremap <Bslash>t :set splitbelow<CR>:split term://zsh<CR>
noremap <c-g> :tabe term://lazygit<CR>
else
noremap <Bslash>py :belowright term ipython3<CR>
noremap <Bslash>t :belowright term<CR>
noremap <c-g> :tab term lazygit<CR>
endif
" <C-v><Esc> exit insert mode into normal mode
tnoremap <C-v><Esc> <C-\><C-n>
tnoremap <C-q> <C-\><C-n>:bd!<CR>
tnoremap <C-o> <C-\><C-n><C-o>
" ===
" === Command line mode(cmdline)
" ===
cnoremap <c-a> <Home>
cnoremap <c-e> <End>
cnoremap <c-l> <Right>
cnoremap <c-h> <Left>
" words backward.
cnoremap <c-b> <S-Left>
" words forward.
cnoremap <c-f> <S-Right>
inoremap <c-a> <HOME>
inoremap <c-e> <END>
inoremap <c-f> <Right>
inoremap <c-b> <Left>
call plug#begin('~/.vim/plugged')
" Option 'on', means On-demand loading: Commands or <Plug>-mappings
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin'
" Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'johnstef99/vim-nerdtree-syntax-highlight'
Plug 'airblade/vim-gitgutter'
" Markdown, It only works on vim >= 8.1 and neovim
" :call mkdp#util#install()
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': ':call mkdp#util#install()', 'for': 'markdown' }
Plug 'Delayless/bullets.vim' " automated bullet lists, :RenumberSelection.
Plug 'SidOfc/mkdx' "used for jump headline from Toc.
" Plug 'plasticboy/vim-markdown'
Plug 'ferrine/md-img-paste.vim'
Plug 'mzlogin/vim-markdown-toc'
Plug 'iamcco/mathjax-support-for-mkdp'
Plug 'dhruvasagar/vim-table-mode', { 'on': 'TableModeToggle' }
" Plug 'KeitaNakamura/tex-conceal.vim', {'for': 'tex'}
Plug 'lervag/vimtex'
Plug 'Yggdroot/indentLine' " mess up vimwiki's conceallevel and highlight.
Plug 'skywind3000/vim-rt-format', { 'do': 'pip3 install autopep8' }
" Optimize Chinese input experience
" To avoid the Esc delay, please set 'ttimeoutlen' to 100 or some value.
" It's also related to screens's maptimeout
" Requirements: python-dbus
" Plug 'lilydjwg/fcitx.vim'
Plug 'rlue/vim-barbaric'
Plug 'tpope/vim-fugitive'
Plug 'SirVer/ultisnips'
Plug 'Delayless/vim-snippets'
" Requestment: universal-ctags for debian family, ctags for arch
Plug 'liuchengxu/vista.vim'
" Plug 'Konfekt/FastFold'
" Plug 'tpope/vim-capslock' " Ctrl+L (insert) to toggle capslock
" Pretty Dress
" Plug 'liuchengxu/eleline.vim' " statusbar
Plug 'itchyny/lightline.vim' " Lightline statusbar
Plug 'chrisbra/Colorizer' " Show colors with :ColorHighlight
Plug 'Delayless/vim-deus' " It only works on vim >=8.1 and neovim
Plug 'frazrepo/vim-rainbow'
Plug 'joshdick/onedark.vim'
Plug 'bling/vim-bufferline'
Plug 'ryanoasis/vim-devicons'
Plug 'Delayless/vim-bookmarks'
" fades your inactive buffers and preserves syntax highlighting.
Plug 'TaDaa/vimade'
Plug 'mhinz/vim-startify' " StartPage
Plug 'junegunn/goyo.vim' " focus read/write
Plug 'junegunn/limelight.vim' " Hyperfocus on a range
Plug 'vim-scripts/restore_view.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'Delayless/vim-bujo' "TODO
Plug 'mtth/scratch.vim' " Open a scratch window.
Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
Plug 'mattn/calendar-vim' " vimwiki daily Index in calendar.
" ysiw{ ysiw} yss<p1> cs ds{, Visual select and input S<p class="important">
Plug 'tpope/vim-surround'
Plug 'gcmt/wildfire.vim' " Enter to select the closest text object(brackets).
Plug 'jiangmiao/auto-pairs' " better than coc-pairs, Alt+p toggle autopairs.
Plug 'airblade/vim-matchquote' " %-style motion for single/double quotation mark, ` (backtick), and | (pipe).
Plug 'zef/vim-cycle' " toggle true/false....(ctrl+a, ctrl+x)
Plug 'voldikss/vim-translator' " better than coc-translator in nvim.
Plug 'godlygeek/tabular' "Align, :Tabularize /】\zs<CR>
Plug 'tpope/vim-repeat' " The . command will work with ds, cs, yss
Plug 'junegunn/vim-after-object' " copy, change, delete, yank after some symbols like `=/:/-/#/<space>`
Plug 'chrisbra/NrrwRgn' "display narrow region(focus)
Plug 'puremourning/vimspector', { 'do': './install_gadget.py --enable-python --enable-c --enable-go'}
"Plug 'liuchengxu/vim-which-key'
" lazy load
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
Plug 'mboughaba/i3config.vim'
Plug 'ron89/thesaurus_query.vim'
" if the filetype isn't supported, adjust 'commentstring'
" autocmd FileType apache setlocal commentstring=#\ %s
Plug 'tpope/vim-commentary'
Plug 'ap/vim-css-color'
Plug 'rbgrouleff/bclose.vim' "Dependency for ranger.vim
Plug 'francoiscabrol/ranger.vim'
" Plug 'terryma/vim-multiple-cursors'
Plug 'mg979/vim-visual-multi'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'ctrlpvim/ctrlp.vim'
if has('nvim')
" Plug 'cpiger/NeoDebug'
" Install nodejs when necessary: curl -sL install-node.now.sh/lts | bash
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'lambdalisue/suda.vim'
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
Plug 'kyazdani42/nvim-web-devicons'
Plug 'akinsho/nvim-bufferline.lua'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
map <LEADER>S :SudaWrite<CR>
else
map <LEADER>S :w !sudo tee %<CR><CR>
Plug 'mg979/vim-xtabline' "Tab manager in the top of windows
Plug 'tenfyzhong/joplin.vim'
endif
call plug#end()
" ===
" === restore_view
" ===
set viewoptions=cursor,folds,slash,unix " autosave cursor position and fold information
" let g:skipview_files = ['*\.vim'] " exclude some files to be autosaved.
" ===
" === NERDtree
" ===
" debug
map ff :NERDTreeToggle<CR>
" open NERDTree automatically when vim starts up on opening a directory
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
let NERDTreeShowHidden=1
let NERDTreeQuitOnOpen=1
let NERDTreeMapOpenExpl = ""
let NERDTreeMapUpdir = "u"
let NERDTreeMapUpdirKeepOpen = "U"
let NERDTreeMapOpenSplit = ""
let NERDTreeMapOpenVSplit = "L"
let NERDTreeOpenVSplit = ""
let NERDTreeMapActivateNode = "l"
let NERDTreeMapOpenInTab = "O"
let NERDTreeMapPreview = ""
let NERDTreeMapCloseDir = "h"
let NERDTreeMapChangeRoot = "o"
let NERDTreeMapToggleHidden="I"
let NERDTreeMapMenu = ","
let NERDTreeIgnore = ['\~$', '\.pyc$', '\.swp$']
" ===
" === nerdtree-git-plugin
" ===
"let g:NERDTreeShowIgnoredStatus = 1
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
" autocmd VimEnter * unlet g:NERDTreeUpdateOnCursorHold
" let g:NERDTreeGitStatusLogLevel = 3
" ==
" == vim-gitgutter
" ==
let g:gitgutter_map_keys = 0
let g:gitgutter_preview_win_floating = 1
autocmd BufWritePost * GitGutter
nnoremap <LEADER>gf :GitGutterFold<CR>
nnoremap <LEADER>gd :GitGutterPreviewHunk<CR>
nnoremap <LEADER>gk :GitGutterPrevHunk<CR>
nnoremap <LEADER>gj :GitGutterNextHunk<CR>
" Git add(stage) this change
nnoremap <LEADER>ga :GitGutterStageHunk<CR>
" Undo Changed Context
nnoremap <LEADER>gu :GitGutterUndoHunk<CR>
" ===
" === markdown-preview.nvim
" ===
let g:mkdp_open_to_the_world = 1
let g:mkdp_open_ip = ''
" set to 1, echo preview page url in command line when open preview page
let g:mkdp_echo_preview_url = 1
" use a custom port to start server or random for empty
let g:mkdp_port = ''
let g:mkdp_browser = '' "spcify brower
let g:mkdp_browserfunc = ''
let g:mkdp_auto_start = 0
let g:mkdp_auto_close = 1
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
let g:mkdp_command_for_global = 0
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1
\ }
let g:mkdp_markdown_css = ''
let g:mkdp_highlight_css = ''
let g:mkdp_port = ''
let g:mkdp_page_title = '「${name}」'
"nmap <F12> <Plug>MarkdownPreview
nmap <Bslash>m <Plug>MarkdownPreview
" markdown auto spell
" autocmd BufRead,BufNewFile *.md setlocal spell
" ===
" === bullets.vim
" ===
" automated bullet lists, select code at visual mode, :RenumberSelection.
" In Insert mode, <C-t> for child bullet and <C-d> for parent bullet.
"1. 2. 3. autoincrease, - is also.
let g:bullets_enabled_file_types = [
\ 'markdown',
\ 'text',
\ 'gitcommit',
\ 'scratch'
\]
" ===
" === mkdx
" ===
" The last two lines configure the concealment. focus
" LaTeX code is replaced or made invisible when your cursor is not on that line.
" e.g, conceal link on `[name](link)`, replaces `\bigcap` by ∩, \in by ∈ etc.
set conceallevel=2
" hi Conceal ctermbg=none
let g:tex_conceal='abdmg'
" folding function conflicts with tpope/vim-markdown.
" disable mkdx's folding by `let g:markdown_folding = 1`
" let g:markdown_folding = 1
let g:mkdx#settings = { 'highlight' : { 'enable': 1 },
\ 'enter' : { 'enable': 1, 'o': 0 },
\ 'checkbox' : { 'toggles': [' ', 'o', 'x'] } ,
\ 'map' : { 'enable': 1, 'prefix': '<leader>m'},
\ 'tab' : { 'enable': 1 },
\ 'links' : { 'external': { 'enable': 1 } },
\ 'image_extension_pattern': 'a\?png\|jpe\?g\|gif',
\ 'fold' : { 'enable': 0, 'components': ['fence', 'toc']},
\ 'tokens' : { 'strike': '~~' },
\ 'auto_update': { 'enable': 0 },
\ 'toc': { 'details': { 'summary': 'Click to expand {{toc.text}}' }} }
" make sure the xdg-utils package is installed
let g:mkdx#settings.gf_on_steroids = 1
let g:mkdx#settings.restore_visual = 0
let g:mkdx#settings.tab.enable = 0
autocmd FileType markdown nmap <CR> <Plug>(mkdx-jump-to-header)
" ===
" === vim-table-mode
" ===
" <Leader>tic insert column, <Leader>tdc delete column
noremap <LEADER>tm :TableModeToggle<CR>
noremap <LEADER>tM :TableModeRealign<CR>
vmap <LEADER>tM :TableModeRealign<CR>
" ===
" === vim-markdown
" ===
" let g:vim_markdown_folding_disabled = 1
" let g:vim_markdown_no_default_key_mappings = 1
" " LaTeX code is replaced or made invisible when your cursor is not on that line.
" " e.g, conceal link on `[name](link)`, replaces `\bigcap` by ∩, \in by ∈ etc.
" " To enable conceal use Vim's standard conceal configuration.
" let g:vim_markdown_math = 1
" let g:vim_markdown_conceal_code_blocks = 0
" let g:vim_markdown_auto_extension_ext = 'txt' "open txt using markdonw
" let g:vim_markdown_auto_insert_bullets = 0
" " open a new file in 'tab', 'vsplit', 'hsplit', 'current'
" let g:vim_markdown_edit_url_in = 'tab'
" " map `gx`: open the link under the cursor <Plug>Markdown_OpenUrlUnderCursor
" " map `ge`: open the link under the cursor in Vim for editing.
" " Useful for relative markdown links. <Plug>Markdown_EditUrlUnderCursor
" " See help documentation for more information.
" " e.g. `]]`, '[[`, `][', '[]', `]c`, ']u', ':Toc', 'InsertToc'
" map ge <Plug>Markdown_EditUrlUnderCursor
" map ]c <Plug>Markdown_MoveToCurHeader
" ===
" === md-img-paste.vim
" ===
autocmd FileType markdown nmap <buffer><silent> <leader>pi :call mdip#MarkdownClipboardImage()<CR>
" there are some defaults for image directory and image name, you can change them
" let g:mdip_imgdir = 'img'
" let g:mdip_imgname = 'image'
" let cwd = $PWD . 'static/img'
" let g:mdip_imgdir_absolute = cwd
" let g:mdip_imgdir_intext = '/static/img'
function! g:LatexPasteImage(relpath)
execute "normal! i\\includegraphics{" . a:relpath . "}\r\\caption{I"
let ipos = getcurpos()
execute "normal! a" . "mage}"
call setpos('.', ipos)
execute "normal! ve\<C-g>"
endfunction
autocmd FileType markdown let g:PasteImageFunction = 'g:MarkdownPasteImage'
autocmd FileType tex let g:PasteImageFunction = 'g:LatexPasteImage'
" ===
" === vim-markdown-toc
" ===
" :GenTocGFM generate TOC
" :GenTocGFM for GitHub, :GenTocGitLab for GitLab
let g:vmt_fence_text = 'TOC'
let g:vmt_fence_closing_text = '/TOC'
let g:vmt_cycle_list_item_markers = 1 " mark by *-+, not only *.
" let g:vmt_include_headings_before = 1
" ===
" === indentLine
" ===
" Add one of the two following lines.
" Otherwise, it will mess up vimwiki's conceallevel and highlight.
let g:indentLine_setConceal = 0
" let g:indentLine_concealcursor = ''
" ===
" === vim-rt-format
" ===
" By default, it will be triggered by `ENTER` in insert mode.
" set this to 1 to use `CTRL+ENTER` instead, and keep the
" default `ENTER` behavior unchanged.
let g:rtf_ctrl_enter = 0
" Enable formatting when leaving insert mode
let g:rtf_on_insert_leave = 1
" ===
" === fzf.vim
" ===
" :GitFiles
" :Ag
"===================================
" Fuzzy-find tags
" map <Leader>w :Windows<cr>
" nmap <Leader>w :Windows<cr>
" This is the default extra key bindings
" In any scenario(fzf,rg,buffers), Open the file in new tab, new split, new vsplit by pressing ctrl-t, ctrl-x, ctrl-v.
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let $FZF_DEFAULT_OPTS .= ' --bind ctrl-a:select-all'
let $FZF_DEFAULT_OPTS .= ' --bind ctrl-d:deselect-all'
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
if has('nvim') && !exists('g:fzf_layout')
autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
endif
" [[B]Commits] Customize the options used by 'git log':
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" :Rg - Start fzf with hidden preview window that can be enabled with "?" key
" :Rg! - Start fzf in fullscreen and display the preview window above
" the dot\. at end of command means regrex's everychar.
"\ 'rg --column --line-number --no-heading --color=always --smart-case --hidden .'.shellescape(<q-args>), 1,
" set the preview window to hidden by default(add ':hidden'), e.g:
"\ : fzf#vim#with_preview('right:50%:hidden', '?'),
" search code in current file.
command! -bang -nargs=* RgCurrentFile
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case --with-filename . '.fnameescape(expand('%')), 1,
\ <bang>0 ? fzf#vim#with_preview('up:40%')
\ : fzf#vim#with_preview('right:50%', '?'),
\ <bang>0)
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case --glob "!.git/*" --glob "!node_modules/*" --glob "!vendor/*" --hidden .'.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:40%')
\ : fzf#vim#with_preview('right:50%', '?'),
\ <bang>0)
command! -bang -nargs=* SearchVariableInProject
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case --hidden .'.shellescape(expand('<cword>')), 1,
\ <bang>0 ? fzf#vim#with_preview('up:40%')
\ : fzf#vim#with_preview('right:50%', '?'),
\ <bang>0)
" Default options are --nogroup --column --color
let s:ag_options = ' --column --one-device --skip-vcs-ignores --smart-case '
command! -bang -nargs=* Ag
\ call fzf#vim#ag(
\ <q-args>,
\ s:ag_options,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%', '?'),
\ <bang>0
\ )
command! -bang -nargs=* History call fzf#vim#history(fzf#vim#with_preview())
" Variables, same as the plug "Vista".
command! -bang BTags
\ call fzf#vim#buffer_tags('', {
\ 'down': '40%',
\ 'options': '--with-nth 1
\ --reverse
\ --prompt "> "
\ --preview-window="70%"
\ --preview "
\ tail -n +\$(echo {3} | tr -d \";\\\"\") {2} |
\ head -n 16"'
\ })
command! -bang -nargs=* GGrep
\ call fzf#vim#grep(
\ 'git grep --line-number -- '.shellescape(<q-args>), 0,
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
" Replace the default dictionary completion with fzf-based fuzzy completion
" if not exist the file, can download from github or `sudo pacman -S words`
" https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt
inoremap <expr> <c-x><c-k> fzf#vim#complete('cat /usr/share/dict/words')
" View commits in fzf
nmap <Bslash>c :Commits<cr>
" [rg](BurntSushi/ripgrep)
" search code in files. [s]ource code
noremap <silent> <Bslash>s :Rg<CR>
" [Ag](ggreer/the_silver_searcher)
" A code searching tool similar to ack, with a focus on speed.
" `sudo apt install the_silver_searcher`
" search filename
" setting in .bashrc for searching hidden files.:FZF actually would use the_silver_searcher's 'ag'.
nnoremap <silent> <Bslash>f :FZF<CR>
nnoremap <silent> <c-f> :RgCurrentFile<CR>
" `gr` go to references use coc.nvim.
nnoremap <silent> gR :SearchVariableInProject<CR>
" The history of the opened files.
noremap <silent> <Bslash>h :History<CR>
" the current file's variables
noremap <silent> <Bslash>bt :BTags<CR>
" Project tags, save all variables.
noremap <silent> <C-t> :Tags<CR>
noremap <silent> <Bslash>bu :Buffers<CR>
" ===
" === ctrlp.vim
" ===
let g:ctrlp_map = '<M-f>'
let g:ctrlp_cmd = 'CtrlP'
" ===
" === vim-bujo
" ===
nmap <Bslash>l :Todo<CR>
" Insert a new task:
nmap <c-s> <Plug>BujoAddnormal
imap <c-s> <Plug>BujoAddinsert
" Check off a task:
nmap <c-q> <Plug>BujoChecknormal
imap <c-q> <Plug>BujoCheckinsert
" Change cache directory:
let g:bujo#todo_file_path = $HOME . "/.cache/bujo"
" Change todo window width:
let g:bujo#window_width = 50
" ===
" === vimwiki
" ===
" :h vimwiki-local-mappings
let g:vimwiki_table_mappings = 0
" If set 1, vimwiki will set all markdown files' filetype to vimwiki.
let g:vimwiki_global_ext = 0
" let g:vimwiki_tab_key = '<F7>'
" let g:vimwiki_shift_tab_key = '<F8>'
" One or more wikis can be registered using the `g:vimwiki_list` variable.
" autocmd FileType mdvimwiki UltiSnipsAddFiletypes vimwiki
" use my custom folder, markdown syntax and custom extension
let g:vimwiki_list = [{'path': '~/vimwiki/', 'path_html': '~/vimwiki_html/', 'auto_toc': 1 },
\ {'path': '~/mdwiki/', 'syntax': 'markdown', 'ext': '.mdvimwiki'}]
nmap <LEADER>wj <Plug>VimwikiNextLink
nmap <LEADER>wk <Plug>VimwikiPrevLink
nmap <LEADER>wha <Plug>VimwikiAll2HTML
nmap <LEADER>wV <Plug>VimwikiSplitLink
nmap <LEADER>wv <Plug>VimwikiVSplitLink
" the same as glp and gln.
" At the same time, only one shortcut can take effect.
" after the map <Plug>, the original shortcut keys will be invalid.
" nmap <LEADER>w- <Plug>VimwikiDecrementListItem
" nmap <LEADER>w= <Plug>VimwikiIncrementListItem
" ===
" === ranger.vim
" ===
if !has("nvim")
execute "set <M-o>=\eo"
execute "set <M-i>=\ei"
endif
let g:ranger_map_keys = 0
nnoremap <M-o> :Ranger<CR>
nnoremap <M-i> :RangerNewTab<CR>
let g:NERDTreeHijackNetrw = 0 " add this line if you use NERDTree
let g:ranger_replace_netrw = 1 " open ranger when vim open a directory
" ===
" === vista.vim
" ===
noremap <silent> vv :Vista!!<CR>
let g:vista_close_on_jump = 1
" Note: this option only works the LSP executives, doesn't work for `:Vista ctags`.
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
" See all the avaliable executives via `:echo g:vista#executives`.
let g:vista_default_executive = 'ctags'
" To enable fzf's preview window set g:vista_fzf_preview.
" The elements of g:vista_fzf_preview will be passed as arguments to fzf#vim#with_preview()
" For example:
let g:vista_fzf_preview = ['right:50%']
" Ensure you have installed some decent font to show these pretty symbols, then you can enable icon for the kind.
let g:vista#renderer#enable_icon = 1
" The default icons can't be suitable for all the filetypes, you can extend it as you wish.
let g:vista#renderer#icons = {
\ "function": "\uf794",
\ "variable": "\uf71b",
\ }
autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
"compile function
noremap <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ -g % -o %<.o"
:below sp
:res -5
exec "term time ./%<.o"
" term gcc -ansi -Wall % -o %< && time ./%<.o
elseif &filetype == 'cpp'
set splitbelow
exec "!g++ -std=c++11 -g % -Wall -o %<.o"
:sp
:res -15
exec "term time ./%<.o"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<"
elseif &filetype == 'sh'
:!time bash %
elseif &filetype == 'python'
set splitbelow
:sp
:term python3 %
elseif &filetype == 'html'
silent! exec "!".g:mkdp_browser." % &"
silent! exec "!google-chrome-stable % &"
elseif &filetype == 'markdown'
exec "MarkdownPreview"
elseif &filetype == 'tex'
silent! exec "VimtexStop"
silent! exec "VimtexCompile"
elseif &filetype == 'go'
set splitbelow
:sp
:term go run %
endif
endfunc
"" ===
"" === fastfold
"" ===
"nmap zuz <Plug>(FastFoldUpdate)
"let g:fastfold_savehook = 1
"let g:fastfold_fold_command_suffixes = ['x','X','a','A','o','O','c','C']
"let g:fastfold_fold_movement_commands = [']z', '[z', 'zj', 'zk']
"let g:markdown_folding = 1
"let g:tex_fold_enabled = 1
"let g:vimsyn_folding = 'af'
"let g:xml_syntax_folding = 1
"let g:javaScript_fold = 1
"let g:sh_fold_enabled= 7
"let g:ruby_fold = 1
"let g:perl_fold = 1
"let g:perl_fold_blocks = 1
"let g:r_syntax_folding = 1
"let g:rust_fold = 1
"let g:php_folding = 1
" ===
" === eleline
" ===
set laststatus=2 ruler
let g:eleline_powerline_fonts = 1
" ===
" === lightline.vim
" ===
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ ['mode', 'paste'],
\ ['readonly', 'filename', 'currentfunction', 'modified'] ],
\ 'right': [ ['lineinfo'],
\ ['fileformat', 'fileencoding', 'filetype'] ],
\ },
\ 'component': {
\ 'currentfunction': '%{get(b:, "coc_current_function", "")}'
\ },
\ 'component_visible_condition': {
\ 'currentfunction': 'exists("b:coc_current_function")&&b:coc_current_function!=""'
\ },
\ }
set tabline=%!lightline#tabline()
" autocmd CursorMoved * call s:display_annotation()
" add the follow line to end of component to display abosolute path
" 'filename': '%<%{LightlineFilename()}',
" function! LightlineFilename() abort
" return expand('%:p') !=# '' ? expand('%:p') : '[No Name]'
" endfunction
" ===
" === Colorizer
" ===
let g:colorizer_syntax = 1
" Press F8 to regenerate the tag file
" map <F8> :!ctags -R --c++-kinds=+p --fields=+iaS --extras=+q .<CR><CR>
" imap <F8> <ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extras=+q .<CR><CR>
" set tags=tags
" set tags+=./tags "Search the tags in current filefolder
" set tags+=~/ctags/tags "When searching the tags, search the ~/ctags/tags at the same time. Don't move the tags file after 'ctags -R'. Otherwise, prompt the warning "Can't find any souce file" when you press Ctrl+]
" ===
" === Pretty Dress, Highlight Settings
" ===
" :hi to veiw palette
if exists('+termguicolors')
" e.g: the word "red" would be highlight red.
set termguicolors
" fix color bug about the display of vim's TrueColor.
" ctrl+v then press <Esc> to generate
let &t_8f = "[38;2;%lu;%lu;%lum"
let &t_8b = "[48;2;%lu;%lu;%lum"
let &t_Co = "256"
" set t_Co=256
" set t_8f=[38;2;%lu;%lu;%lum
" set t_8b=[48;2;%lu;%lu;%lum
endif
if (has("nvim"))
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
" effect on the color of eleline
set background=dark
" colorscheme deus
colorscheme onedark
" Python PEP8: Error: line too long (183 > 79 characters). So set colorcolumn=80
" set colorcolumn=81
" highlight ColorColumn term=reverse cterm=reverse