-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
1031 lines (948 loc) · 30.8 KB
/
init.vim
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
" __ __ _ _ _
" | \/ |_ _| \ | |_ _(_)_ __ ___ _ __ ___
" | |\/| | | | | \| \ \ / / | '_ ` _ \| '__/ __|
" | | | | |_| | |\ |\ V /| | | | | | | | | (__
" |_| |_|\__, |_| \_| \_/ |_|_| |_| |_|_| \___|
" |___/
" * Originated by Rainbow Chen *
"""""""""""""""""""""""""""""""
" some initial commands "
"""""""""""""""""""""""""""""""
" Auto load plugins at the first time uses
if empty(glob(
\ '$HOME/' . (has('win32') ? 'vimfiles' : '.config/nvim') . '/autoload/plug.vim'))
execute '!curl -fLo ' .
\ (has('win32') ? '\%USERPROFILE\%/vimfiles' : '$HOME/.config/nvim') .
\ '/autoload/plug.vim --create-dirs ' .
\ 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
"""""""""""""""""""""""""""
" some vim settings "
"""""""""""""""""""""""""""
" nocompatible mode
set nocompatible
" open filetype, plugin, indent
filetype plugin indent on
" syntax enable
syntax on
set encoding=utf-8
set title
set autoread
set autowrite
set number
set relativenumber
set cursorline
set colorcolumn=80
set wrap
set showcmd
set ruler
set wildmenu
set history=100
" for map timeout
set timeout
set timeoutlen=1500
" for keycode timeout
set nottimeout
set hlsearch
set incsearch
set ignorecase
set smartcase
set whichwrap=b,s
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
set list
set listchars=tab:▸\ ,trail:▫
set conceallevel=2
set concealcursor=
set scrolloff=16
set autoindent
set smartindent
set backspace=indent,eol,start
set foldmethod=indent
set foldlevel=99
set laststatus=2
set updatetime=100
set updatecount=100
set autochdir
set lazyredraw
set termguicolors
" for preview of the substitue
set inccommand=split
" for echodoc
set noshowmode
" for tags generator
set tags=./.tags;,.tags
set backup
set backupext=.bak
set undofile
set shada=!,'100,<50,s10,h
let s:vim_cachedir = $HOME. "/.cache/nvim/"
" swap file
let &directory = s:vim_cachedir. "swap"
" file backup
let &backupdir = s:vim_cachedir. "backup"
" undo file
let &undodir = s:vim_cachedir. "undo"
" view file
let &viewdir = s:vim_cachedir. "view"
" shada file
let &shadafile = s:vim_cachedir. "shada"
" file path of swap, backup, undo, view and vimtex&vista plugin files
for d in [ &directory, &backupdir, &undodir, &viewdir,
\ s:vim_cachedir."vimtex", s:vim_cachedir."vista" ]
call mkdir(d, "p", 0700)
endfor
" go back the last line where you quit vim
augroup AutoLastLine
autocmd BufReadPost * if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\"" | endif
augroup END
" automatically deletes all trailing whitespace and newlines at end of file on save
augroup AutoTrailWhitespace
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
augroup END
" turn off relative-line-number when enter insert mode and enable otherwise
augroup AutoRelativeLineNums
autocmd!
au InsertEnter * set norelativenumber
au InsertLeave * set relativenumber
augroup END
" leader map
let g:mapleader=" "
"""""""""""""""""""""""""""""""
" something about plugins "
"""""""""""""""""""""""""""""""
" Compile function
func! FileRun()
exec "w"
if &filetype == 'markdown'
exec "MarkdownPreview"
elseif &filetype == 'tex'
silent! exec "VimtexStop"
silent! exec "VimtexCompile"
else
set splitbelow
exec "AsyncTask file-run"
endif
endfunc
" Standard plugins -- for gdb
packadd termdebug
call plug#begin('~/.config/nvim/plugged')
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'glepnir/dashboard-nvim'
Plug 'glepnir/galaxyline.nvim' , {'branch': 'main'}
Plug 'romgrk/barbar.nvim'
Plug 'aklt/plantuml-syntax'
Plug 'p00f/nvim-ts-rainbow'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'terryma/vim-multiple-cursors'
Plug 'preservim/nerdcommenter'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'antoinemadec/coc-fzf'
Plug 'honza/vim-snippets'
Plug 'puremourning/vimspector', {'do': './install_gadget.py --enable-c --enable-python --enable-go'}
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
Plug 'mzlogin/vim-markdown-toc'
Plug 'dhruvasagar/vim-table-mode'
Plug 'junegunn/vim-easy-align'
Plug 'liuchengxu/vista.vim'
Plug 'kshenoy/vim-signature'
Plug 'easymotion/vim-easymotion'
Plug 'lambdalisue/suda.vim'
Plug 'skywind3000/asynctasks.vim'
Plug 'skywind3000/asyncrun.vim'
Plug 'skywind3000/asyncrun.extra'
Plug 'lervag/vimtex'
Plug 'voldikss/vim-floaterm'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'andymass/vim-matchup'
Plug 'tpope/vim-repeat'
Plug 'brooth/far.vim'
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
Plug 'pechorin/any-jump.vim'
Plug 'drmikehenry/vim-headerguard', { 'for': 'cpp' }
Plug 'mbbill/undotree'
Plug 'unblevable/quick-scope'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" Plug 'ludovicchabant/vim-gutentags'
Plug 'Shougo/echodoc.vim'
Plug 'rhysd/accelerated-jk'
Plug 'kevinhwang91/nvim-hlslens'
Plug 'mhartington/formatter.nvim'
Plug 'junegunn/vim-peekaboo'
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
Plug 'rafcamlet/coc-nvim-lua'
Plug 'wellle/context.vim'
Plug 'norcalli/nvim-colorizer.lua'
Plug 'MattesGroeger/vim-bookmarks'
Plug 'wfxr/minimap.vim'
" themes
Plug 'joshdick/onedark.vim'
Plug 'arcticicestudio/nord-vim'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'connorholyday/vim-snazzy'
Plug 'arzg/vim-colors-xcode'
Plug 'ayu-theme/ayu-vim'
Plug 'morhetz/gruvbox'
Plug 'nerdypepper/agila.vim'
Plug 'sainnhe/forest-night'
Plug 'mhartington/oceanic-next'
Plug 'rakr/vim-one'
Plug 'ajmwagar/vim-deus'
call plug#end()
" oceanic-next
let g:oceanic_next_terminal_bold = 1
let g:oceanic_next_terminal_italic = 1
" ayu
let ayucolor = "mirage"
" onedark
let g:onedark_terminal_italics = 1
" nord
let g:nord_italic = 1
let g:nord_italic_comments = 1
let g:nord_underline = 1
" xcode
augroup vim-colors-xcode
autocmd!
augroup END
autocmd vim-colors-xcode ColorScheme * hi Comment cterm=italic gui=italic
autocmd vim-colors-xcode ColorScheme * hi SpecialComment cterm=italic gui=italic
" gruvbox
let g:gruvbox_italic = 1
let g:gruvbox_italicize_strings = 1
let g:gruvbox_invert_signs = 1
let g:gruvbox_invert_indent_guides = 1
let g:gruvbox_invert_tabline = 1
" let g:gruvbox_improved_strings = 1
let g:gruvbox_improved_warnings = 1
" forest
let g:forest_night_enable_italic = 1
let g:forest_night_disable_italic_comment = 1
" vim-one
let g:one_allow_italics = 1 " I love italic for comments
" quick-scope highlight
augroup qs_colors
autocmd!
autocmd ColorScheme * highlight QuickScopePrimary guifg='#5fffff' gui=underline ctermfg=155 cterm=underline
autocmd ColorScheme * highlight QuickScopeSecondary guifg='#ff99ff' gui=underline ctermfg=81 cterm=underline
augroup END
" vim colorscheme
colorscheme gruvbox
" auto-pairs
let g:AutoPairsShortcutToggle = ''
let g:AutoPairsShortcutBackInsert = ''
let g:AutoPairsMapCh = 0
let g:AutoPairsShortcutFastWrap = '<C-a>'
let g:AutoPairsShortcutJump = '<C-;>'
" coc.nvim
let g:coc_global_extensions = [
\ 'coc-emoji',
\ 'coc-zi',
\ 'coc-svg',
\ 'coc-marketplace',
\ 'coc-post',
\ 'coc-lists',
\ 'coc-bibtex',
\ 'coc-picgo',
\ 'coc-actions',
\ 'coc-tasks',
\ 'coc-git',
\ 'coc-snippets',
\ 'coc-explorer',
\ 'coc-floaterm',
\ 'coc-yank',
\ 'coc-diagnostic',
\ 'coc-calc',
\ 'coc-html',
\ 'coc-json',
\ 'coc-xml',
\ 'coc-yaml',
\ 'coc-tsserver',
\ 'coc-clangd',
\ 'coc-lua',
\ 'coc-cmake',
\ 'coc-jedi',
\ 'coc-vimlsp',
\ 'coc-sh',
\ 'coc-vimtex',
\ 'coc-sql']
"" use <tab> for trigger completion
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <silent><expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" common operation
noremap <LEADER>cd :CocFzfList commands<CR>
nmap [d <Plug>(coc-diagnostic-prev)
nmap ]d <Plug>(coc-diagnostic-next)
nmap [r <Plug>(coc-range-select)
nmap ]r <Plug>(coc-range-select-backward)
nmap gd <Plug>(coc-definition)
nmap gD <Plug>(coc-declaration)
nmap gi <Plug>(coc-implementation)
nnoremap gt :stjump <C-R><C-W><CR>
nmap gT <Plug>(coc-type-definition)
nmap gl <Plug>(coc-references)
nmap gr <Plug>(coc-rename)
nmap gR <Plug>(coc-refactor)
nmap gL <Plug>(coc-openlink)
vmap gF <Plug>(coc-format-selected)
nmap gF <Plug>(coc-format-selected)
nmap gq <Plug>(coc-fix-current)
nmap ga <Plug>(coc-codeaction)
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
nnoremap <silent> g; :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" coc-clangd
noremap gh :CocCommand clangd.switchSourceHeader<CR>
" coc-snippets
imap <C-j> <Plug>(coc-snippets-expand-jump)
vmap <C-j> <Plug>(coc-snippets-select)
let g:coc_snippet_next = '<C-j>'
let g:coc_snippet_prev = '<C-k>'
function! s:edit_snippets()
execute 'tabedit '. $HOME. '/.config/nvim/snippets/'. &filetype. '.snippets'
endfunction
noremap <silent> gs :call <SID>edit_snippets()<CR>
" coc-explorer
noremap <LEADER>n :CocCommand explorer<CR>
" coc-yank
nnoremap <silent> <LEADER>y :CocFzfList yank<CR>
" coc-git
nmap [g <Plug>(coc-git-prevchunk)
nmap ]g <Plug>(coc-git-nextchunk)
nmap [c <Plug>(coc-git-prevconflict)
nmap ]c <Plug>(coc-git-nextconflict)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" fzf&coc.nvim
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
" rainbow
let g:rainbow_active = 1
" vim-surround
nmap <LEADER>" ysiW"
nmap <LEADER>' ysiW'
nmap <LEADER>( ysiW)
nmap <LEADER>{ ysiW{
nmap <LEADER>[ ysiW[
nmap <LEADER>/ ysiW*ysiW/f*a<SPACE><ESC>f*i<SPACE><ESC>b
" vim-multiple-cursors
let g:multi_cursor_use_default_mapping=0
" Default mapping
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_select_all_word_key = 'g<C-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-s>'
let g:multi_cursor_quit_key = '<ESC>'
" nerdcommenter
let g:NERDCreateDefaultMappings = 0
let g:NERDSpaceDelims = 1
let g:NERDTrimTrailingWhitespace = 1
nmap <LEADER>ca <plug>NERDCommenterAppend
nmap <Leader>cc <plug>NERDCommenterToggle
vmap <Leader>cc <plug>NERDCommenterToggle
nmap <Leader>cm <plug>NERDCommenterMinimal
vmap <Leader>cm <plug>NERDCommenterMinimal
" markdown-preview.vim
let g:mkdp_auto_start = 0
let g:mkdp_auto_close = 1
let g:mkdp_refresh_slow = 0
let g:mkdp_command_for_global = 0
let g:mkdp_open_to_the_world = 0
let g:mkdp_open_ip = ''
let g:mkdp_browser = ''
let g:mkdp_echo_preview_url = 0
let g:mkdp_browserfunc = ''
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {}
\ }
let g:mkdp_markdown_css = ''
let g:mkdp_highlight_css = ''
let g:mkdp_port = ''
let g:mkdp_page_title = '「${name}」'
" vim-fzf
noremap <LEADER>ff :Files<CR>
noremap <LEADER>fg :GFiles<CR>
noremap <LEADER>fb :Buffers<CR>
noremap <LEADER>fc :Colors<CR>
noremap <LEADER>fl :Lines<CR>
noremap <LEADER>ft :Tags<CR>
noremap <LEADER>fm :Marks<CR>
noremap <LEADER>fw :Rg<CR>
noremap <LEADER>fW :Windows<CR>
noremap <LEADER>fh :History<CR>
noremap <LEADER>fs :CocFzfList snippets<CR>
noremap <LEADER>fo :CocFzfList outline<CR>
noremap <LEADER>fM :Maps<CR>
" vimspector
nnoremap <F3> :VimspectorReset<CR>
nnoremap <F4> :call vimspector#Restart()<CR>
nnoremap <F5> :call vimspector#Continue()<CR>
nnoremap <F8> :call vimspector#AddFunctionBreakpoint('<cexpr>')<CR>
nnoremap <F9> :call vimspector#ToggleBreakpoint()<CR>
nnoremap <F10> :call vimspector#StepOver()<CR>
nnoremap <F11> :call vimspector#StepInto()<CR>
nnoremap <F12> :call vimspector#StepOut()<CR>
function! s:read_template_into_buffer(template)
" has to be a function to avoid the extra space fzf#run insers otherwise
execute '0r ~/.config/nvim/vimspector_json_templation/'.a:template
endfunction
command! -bang -nargs=* LoadVimSpectorJsonTemplate call fzf#run({
\ 'source': 'ls -1 ~/.config/nvim/vimspector_json_templation',
\ 'down': 20,
\ 'sink': function('<sid>read_template_into_buffer')
\ })
noremap <leader>vs :tabe .vimspector.json<CR>:LoadVimSpectorJsonTemplate<CR>
sign define vimspectorBP text=🔸 texthl=Normal
sign define vimspectorBPDisabled text=🔹 texthl=Normal
sign define vimspectorPC text=🔴 texthl=SpellBad
" vim-markdown-toc
noremap <LEADER>tg :GenTocGFM<CR>
let g:vmt_auto_update_on_save = 1
let g:vmt_dont_insert_fence = 0
let g:vmt_cycle_list_item_markers = 1
let g:vmt_include_headings_before = 0
let g:vmt_fence_text = 'TOC'
let g:vmt_fence_closing_text = '/TOC'
" vim-table-mode
let g:table_mode_corner = '|'
" vim-easy-align
nmap <LEADER>al <Plug>(EasyAlign)
xmap <LEADER>al <Plug>(EasyAlign)
" vista
noremap T :Vista!!<CR>
noremap <C-t> :Vista finder coc<CR>
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
let g:vista_default_executive = 'ctags'
let g:vista_fzf_preview = ['right:50%']
let g:vista#renderer#enable_icon = 1
let g:vista#renderer#icons = {
\ "function": "\uf794",
\ "variable": "\uf71b",
\ }
let g:vista_executive_for = {
\ 'c': 'coc',
\ 'cpp': 'coc',
\ }
" formatter.nvim
lua <<EOF
require('formatter').setup({
logging = false,
filetype = {
c = {
function()
return {
exe = "clang-format",
args = {"--style=Google"},
stdin = true
}
end
},
cpp = {
function()
return {
exe = "clang-format",
args = {"--style=Google"},
stdin = true
}
end
},
python = {
function()
return {
exe = "autopep8",
args = {""},
stdin = true
}
end
},
json = {
function()
return {
exe = "fixjson",
args = {""},
stdin = true
}
end
},
markdown = {
function()
return {
exe = "remark",
args = {""},
stdin = true
}
end
},
}
})
EOF
noremap <LEADER>af :Format<CR>
" vim-signature
let g:SignatureMap = {
\ 'Leader' : "m",
\ 'PlaceNextMark' : "m,",
\ 'ToggleMarkAtLine' : "m.",
\ 'PurgeMarksAtLine' : "m-",
\ 'DeleteMark' : "dm",
\ 'PurgeMarks' : "m<SPACE>",
\ 'PurgeMarkers' : "m<BS>",
\ 'GotoNextLineAlpha' : "",
\ 'GotoPrevLineAlpha' : "",
\ 'GotoNextSpotAlpha' : "",
\ 'GotoPrevSpotAlpha' : "",
\ 'GotoNextLineByPos' : "",
\ 'GotoPrevLineByPos' : "",
\ 'GotoNextSpotByPos' : "",
\ 'GotoPrevSpotByPos' : "",
\ 'GotoNextMarker' : "]-",
\ 'GotoPrevMarker' : "[-",
\ 'GotoNextMarkerAny' : "",
\ 'GotoPrevMarkerAny' : "",
\ 'ListBufferMarks' : "m/",
\ 'ListBufferMarkers' : "m?"
\ }
" vim-easymotion
" Disable default mappings
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1
let g:EasyMotion_use_smartsign_us = 1
"/f{char} to move to {char}
vmap sf <Plug>(easymotion-bd-f)
nmap sf <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
vmap sc <Plug>(easymotion-bd-f2)
nmap sc <Plug>(easymotion-overwin-f2)
" Move to line
vmap sL <Plug>(easymotion-bd-jk)
nmap sL <Plug>(easymotion-overwin-line)
" Move to word
vmap sw <Plug>(easymotion-bd-w)
nmap sw <Plug>(easymotion-overwin-w)
" Goyo
nnoremap <LEADER>gy :Goyo<CR>
let g:goyo_width = '80'
let g:goyo_height = '80%'
" suda.vim
nnoremap <LEADER>S :SudaWrite<CR>
let g:suda#prompt = '(. > .) password please: '
let g:suda_smart_edit = 1
" asyncrun.vim
let g:asyncrun_open = 6
let g:asyncrun_rootmarks = ['.git', '.svn', '.root', '.project' ]
" asynctasks.vim
" make task run on floaterm
let g:asynctasks_term_pos = 'floaterm_reuse'
noremap <F6> <CMD>AsyncTask file-build<CR>
noremap <F7> <CMD>call FileRun()<CR>
noremap <LEADER><F6> <CMD>AsyncTask project-build<CR>
noremap <LEADER><F7> <CMD>AsyncTask project-run<CR>
" vimtex
let g:vimtex_mappings_enabled = 0
let g:vimtex_cache_root = s:vim_cachedir. 'vimtex'
let g:tex_flavor = 'latex'
let g:vimtex_toc_enabled = 0
let g:vimtex_quickfix_autoclose_after_keystrokes = 1
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_view_method = 'zathura'
let g:vimtex_compiler_latexmk = {
\ 'build_dir' : 'build',
\ 'callback' : 1,
\ 'continuous' : 1,
\ 'executable' : 'latexmk',
\ 'hooks' : [],
\ 'options' : [
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
let g:vimtex_compiler_latexmk_engines = {
\ '_' : '-pdf',
\ 'pdflatex' : '-pdf',
\ 'dvipdfex' : '-pdfdvi',
\ 'lualatex' : '-lualatex',
\ 'xelatex' : '-xelatex',
\ 'context (pdftex)' : '-pdf -pdflatex=texexec',
\ 'context (luatex)' : '-pdf -pdflatex=context',
\ 'context (xetex)' : '-pdf -pdflatex=''texexec --xtx''',
\}
let g:vimtex_doc_handlers = ['MyHandler']
function! MyHandler(context)
call vimtex#doc#make_selection(a:context)
if !empty(a:context.selected)
execute '!texdoc' a:context.selected '&'
endif
return 1
endfunction
" floaterm
let g:floaterm_keymap_toggle = '<F1>'
" vim-matchup
let g:matchup_mappings_enabled = 1
let g:matchup_text_obj_enabled = 0
let g:matchup_override_vimtex = 1
xmap a% <plug>(matchup-%)
xmap i% <plug>(matchup-%)
" vim-which-key
nnoremap <silent> <LEADER> :WhichKey '<SPACE>'<CR>
" far.vim
nnoremap ss :Farp<CR>
let g:far#default_mappings = 1
let g:far#enable_undo = 1
let g:far#mapping = {
\ "exclude" : "",
\ "include" : "",
\ "toggle_exclude" : "",
\ "exclude_all" : "",
\ "include_all" : "",
\ "toggle_exclude_all" : "",
\ "expand" : "",
\ "collapse" : "",
\ "toggle_expand" : "",
\ "expand_all" : "",
\ "collapse_all" : "",
\ "toggle_expand_all" : "",
\ "stoggle_exclude" : "e",
\ "stoggle_exclude_all" : "E",
\ "jump_to_source" : "<CR>",
\ "open_preview" : "p",
\ "close_preview" : "P",
\ "preview_scroll_up" : "<C-k>",
\ "preview_scroll_down" : "<C-j>",
\ "stoggle_expand" : "za",
\ "stoggle_expand_all" : "zA",
\ "replace_do" : "r",
\ "replace_undo" : "u",
\ "replace_undo_all" : "U",
\ "quit" : "q"
\ }
" any-jump.vim
let g:any_jump_disable_default_keybindings = 1
noremap gj :AnyJump<CR>
" vim-headerguard.vim
noremap <LEADER>ah :HeaderguardAdd<CR>
" undotree.vim
nnoremap <LEADER>U :UndotreeToggle<cr>
function g:Undotree_CustomMap()
nmap <buffer> J <plug>UndotreeNextState
nmap <buffer> K <plug>UndotreePreviousState
endfunc
" nvim-treesitter
lua <<EOF
require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
highlight = {
enable = true, -- false will disable the whole extension
disable = {}, -- list of language that will be disabled
},
rainbow = {
enable = true
}
}
EOF
" vim-gutentags
" let g:gutentags_project_root = ['.root', '.svn', '.git', '.project']
" let g:gutentags_ctags_tagfile = '.tags'
" let s:vim_tags = expand('~/.cache/tags')
" if !isdirectory(s:vim_tags)
" silent! call mkdir(s:vim_tags, 'p')
" endif
" let g:gutentags_cache_dir = s:vim_tags
" let g:gutentags_modules = []
" if executable('ctags')
" let g:gutentags_modules += ['ctags']
" endif
" if executable('gtags-cscope') && executable('gtags')
" let g:gutentags_modules += ['gtags_cscope']
" endif
" let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
" let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
" let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" let g:gutentags_ctags_extra_args += ['--output-format=e-ctags']
" let g:gutentags_auto_add_gtags_cscope = 0
" let g:gutentags_define_advanced_commands = 1
" let g:gutentags_enabled = 0
" augroup auto_gutentags
" au FileType c,cpp let g:gutentags_enabled=1
" augroup END
" echodoc.vim
let g:echodoc_enable_at_startup = 1
" dashboard-nvim
let g:dashboard_default_executive ='fzf'
let g:dashboard_custom_shortcut={
\ 'new_file' : 'SPC c n',
\ 'find_file' : 'SPC f f',
\ 'book_marks' : 'SPC f m',
\ 'find_word' : 'SPC f w',
\ 'find_history' : 'SPC f h',
\ 'change_colorscheme' : 'SPC f c',
\ 'last_session' : 'SPC s l',
\ }
let g:dashboard_custom_header = [
\' ⠀⠀⠀⠀⠀⠀⠀⡴⠞⠉⢉⣭⣿⣿⠿⣳⣤⠴⠖⠛⣛⣿⣿⡷⠖⣶⣤⡀⠀⠀⠀ ',
\' ⠀⠀⠀⠀⠀⠀⠀⣼⠁⢀⣶⢻⡟⠿⠋⣴⠿⢻⣧⡴⠟⠋⠿⠛⠠⠾⢛⣵⣿⠀⠀⠀⠀ ',
\' ⣼⣿⡿⢶⣄⠀⢀⡇⢀⡿⠁⠈⠀⠀⣀⣉⣀⠘⣿⠀⠀⣀⣀⠀⠀⠀⠛⡹⠋⠀⠀⠀⠀ ',
\' ⣭⣤⡈⢑⣼⣻⣿⣧⡌⠁⠀⢀⣴⠟⠋⠉⠉⠛⣿⣴⠟⠋⠙⠻⣦⡰⣞⠁⢀⣤⣦⣤⠀ ',
\' ⠀⠀⣰⢫⣾⠋⣽⠟⠑⠛⢠⡟⠁⠀⠀⠀⠀⠀⠈⢻⡄⠀⠀⠀⠘⣷⡈⠻⣍⠤⢤⣌⣀ ',
\' ⢀⡞⣡⡌⠁⠀⠀⠀⠀⢀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⢿⡀⠀⠀⠀⠸⣇⠀⢾⣷⢤⣬⣉ ',
\' ⡞⣼⣿⣤⣄⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⣿⠀⠸⣿⣇⠈⠻ ',
\' ⢰⣿⡿⢹⠃⠀⣠⠤⠶⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⣿⠀⠀⣿⠛⡄⠀ ',
\' ⠈⠉⠁⠀⠀⠀⡟⡀⠀⠈⡗⠲⠶⠦⢤⣤⣤⣄⣀⣀⣸⣧⣤⣤⠤⠤⣿⣀⡀⠉⣼⡇⠀ ',
\' ⣿⣴⣴⡆⠀⠀⠻⣄⠀⠀⠡⠀⠀⠀⠈⠛⠋⠀⠀⠀⡈⠀⠻⠟⠀⢀⠋⠉⠙⢷⡿⡇⠀ ',
\' ⣻⡿⠏⠁⠀⠀⢠⡟⠀⠀⠀⠣⡀⠀⠀⠀⠀⠀⢀⣄⠀⠀⠀⠀⢀⠈⠀⢀⣀⡾⣴⠃⠀ ',
\' ⢿⠛⠀⠀⠀⠀⢸⠁⠀⠀⠀⠀⠈⠢⠄⣀⠠⠼⣁⠀⡱⠤⠤⠐⠁⠀⠀⣸⠋⢻⡟⠀⠀ ',
\' ⠈⢧⣀⣤⣶⡄⠘⣆⠀⠀⠀⠀⠀⠀⠀⢀⣤⠖⠛⠻⣄⠀⠀⠀⢀⣠⡾⠋⢀⡞⠀⠀⠀ ',
\' ⠀⠀⠻⣿⣿⡇⠀⠈⠓⢦⣤⣤⣤⡤⠞⠉⠀⠀⠀⠀⠈⠛⠒⠚⢩⡅⣠⡴⠋⠀⠀⠀⠀ ',
\' ⠀⠀⠀⠈⠻⢧⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⣻⠿⠋⠀⠀⠀⠀⠀⠀ ',
\' ⠀⠀⠀⠀⠀⠀⠉⠓⠶⣤⣄⣀⡀⠀⠀⠀⠀⠀⢀⣀⣠⡴⠖⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀ ',
\ ]
let g:dashboard_custom_footer = [ "Welcome to RainbowCh's Nvim!" ]
nnoremap <silent> <Leader>cn :DashboardNewFile<CR>
nmap <Leader>cs :<C-u>SessionSave<CR>
nmap <Leader>cl :<C-u>SessionLoad<CR>
" galaxyline.nvim
lua require('eviline')
" nvim-hlslens
noremap <silent> n <Cmd>execute('normal! ' . v:count1 . 'n')<CR>
\<Cmd>lua require('hlslens').start()<CR>
noremap <silent> N <Cmd>execute('normal! ' . v:count1 . 'N')<CR>
\<Cmd>lua require('hlslens').start()<CR>
noremap * *<Cmd>lua require('hlslens').start()<CR>
noremap # #<Cmd>lua require('hlslens').start()<CR>
noremap g* g*<Cmd>lua require('hlslens').start()<CR>
noremap g# g#<Cmd>lua require('hlslens').start()<CR>
" limelight.vim
augroup limelight
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
augroup END
" barbar.nvim
nnoremap sb :BufferPick<CR>
" go to next buffer
noremap ]b :BufferNext<CR>
" go to previous buffer
noremap [b :BufferPrevious<CR>
" go to the buffer that you view just before
noremap L <C-^>
" delete current buffer
noremap H :BufferClose<CR>
" indent-blankline.nvim
let g:indent_blankline_buftype_exclude = ['terminal']
let g:indent_blankline_filetype_exclude = ['help', 'startify', 'dashboard', 'packer', 'neogitstatus']
let g:indent_blankline_char = '▏'
let g:indent_blankline_use_treesitter = 1
let g:indent_blankline_show_trailing_blankline_indent = 0
let g:indent_blankline_show_current_context = 1
let g:indent_blankline_context_patterns = [
\ 'class', 'return', 'function', 'method', '^if', '^while', 'jsx_element', '^for', '^object', '^table', 'block',
\ 'arguments', 'if_statement', 'else_clause', 'jsx_element', 'jsx_self_closing_element', 'try_statement',
\ 'catch_clause', 'import_statement', 'operation_type'
\ ]
" context.vim
let g:context_add_mappings = 0
nnoremap <LEADER>ct <CMD>ContextToggle<CR>
" nvim-colorizer.lua
lua require'colorizer'.setup()
" yank highlight
autocmd TextYankPost * silent! lua vim.highlight.on_yank{ timeout=100 }
" vim-bookmarks
let g:bookmark_sign = ''
let g:bookmark_annotation_sign = '☰'
let g:bookmark_no_default_key_mappings = 1
nmap <Leader>mt <Plug>BookmarkToggle
nmap <Leader>ma <Plug>BookmarkAnnotate
nmap <Leader>mm <Plug>BookmarkShowAll
nmap ]m <Plug>BookmarkNext
nmap [m <Plug>BookmarkPrev
nmap <Leader>mc <Plug>BookmarkClear
nmap <Leader>mC <Plug>BookmarkClearAll
" lazygit
noremap <LEADER>gi <CMD>FloatermNew --autoclose=1 lazygit<CR>
noremap <LEADER>R <CMD>FloatermNew --autoclose=1 ranger<CR>
noremap <LEADER>rg <CMD>FloatermNew --autoclose=1 --width=0.8 --height=0.8 rg<CR>
"""""""""""""""""""""""""""""""""""""""""
" some mappings about common operation "
"""""""""""""""""""""""""""""""""""""""""
" Open the vimrc file
noremap <LEADER>rc :edit $MYVIMRC<CR>
" shut dowm the highlight of last search
noremap <LEADER><CR> :nohlsearch<CR>
" move cursor to other window
noremap <LEADER>l <C-w>l
noremap <LEADER>k <C-w>k
noremap <LEADER>h <C-w>h
noremap <LEADER>j <C-w>j
" swith the position of current window
noremap <LEADER>L <C-w>L
noremap <LEADER>K <C-w>K
noremap <LEADER>H <C-w>H
noremap <LEADER>J <C-w>J
" substitute
noremap <LEADER>s :%s///g<left><left><left>
" switch upper or lower
noremap <LEADER>u ~h
" cute font
noremap <LEADER>fr :r !figlet<SPACE>
" alter the keymap between colemak with normal us keyboard
noremap <LEADER>bc :source $HOME/.config/nvim/insert-colemak.vim<CR>
noremap <LEADER>bu :source $HOME/.config/nvim/insert-normal.vim<CR>
" plus 1 to value in current location
noremap <LEADER>. <C-a>
" minus 1 to value in current location
noremap <LEADER>, <C-x>
" jump to the next placehold and edit it
noremap <LEADER><LEADER> <Esc>/<++><CR>:nohlsearch<CR>c4l
" go next or previous searched text and keep in middle of screen
nnoremap - Nzz
nnoremap = nzz
" change indent
nnoremap < <<
nnoremap > >>
" use accelerated-jk for normal up/down movement
nmap j <Plug>(accelerated_jk_gj)
nmap k <Plug>(accelerated_jk_gk)
noremap J 5j
noremap K 5k
" move current line up
nnoremap <C-k> :<c-u>move -2<CR>
xnoremap <C-k> :move -2<CR>gv
" move current line down
nnoremap <C-j> :<c-u>move +1<CR>
xnoremap <C-j> :move '>+1<CR>gv
" move cusor to head of current line
noremap <C-h> ^
" move cusor to end of current line
noremap <C-l> $
" <C-u> go to older position, <C-o> go to newer position
noremap <C-o> <C-i>
noremap <C-u> <C-o>
" use sys-clipboard in normal mode
nnoremap <C-y> "+yy
nnoremap <C-p> o<Esc>"+p
" go the end of the current line but ignore the return char
xnoremap <C-l> g_
" use sys-clipboard in v mode
xnoremap <C-y> "+y
xnoremap <C-p> "+p
" command mode movement
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-h> <Left>
cnoremap <C-l> <Right>
" re-select view block after indent in v mode
xnoremap < <gv
xnoremap > >gv
" save
nnoremap S :w<CR>
nnoremap s <nop>
" quit
nnoremap Q :q<CR>
" refresh my vimrc
nnoremap R :source $MYVIMRC<CR>
" split windows
nnoremap sl :set splitright<CR>:vsplit<CR>
nnoremap sh :set nosplitright<CR>:vsplit<CR>
nnoremap sk :set nosplitbelow<CR>:split<CR>
nnoremap sj :set splitbelow<CR>:split<CR>
" alter size of the current window
noremap <up> :resize +5<CR>
noremap <down> :resize -5<CR>
noremap <left> :vertical resize+5<CR>
noremap <right> :vertical resize-5<CR>
" tab operation
nnoremap <LEADER>te :tabedit<CR>
nnoremap [t :-tabnext<CR>
nnoremap ]t :+tabnext<CR>
nnoremap <LEADER>tk :-tabmove<CR>
nnoremap <LEADER>tj :+tabmove<CR>
" make current window widest on left or top
nnoremap sv <C-w>H
nnoremap sh <C-w>K
" rotate windows
nnoremap sr <C-w>r
nnoremap sR <C-w>R
" terminal keymaps
tnoremap <Esc> <C-\><C-n>