forked from archibate/vimrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
839 lines (759 loc) · 28.2 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
"
" .vimrc used by a naive C++ coder: github.com/archibate
"
" I manage plugins using vim-plug (already bundled in my .vim folder):
" https://github.com/junegunn/vim-plug
"
" IMPORTANT: Simply put this .vimrc and .vim to your home folder won't work
" immediately. You need to run
"
" :PlugInstall
"
" when you launch Vim for the first time.
" This will initialize all the plugins, otherwise they will not shows up.
"
" Scroll to the end of this file to see my plugin list.
" Comment or uncomment some of them as you wish.
"
"
" Key maps
" --------
"
" Z - equivalent to :wq, save and exit current window
" Q - equivalent to :wa! then :qa!, save and exit all windows
" H - equivalent to ^, goto start of line
" L - equivalent to $, goto end of line
" kj - equivalent to <ESC>, exit insert mode
"
" g1 - switch the 1st tab
" g2 - switch the 2nd tab
" g3 - switch the 3rd tab
" ...
"
" <F1> - save and switch to last used tab
" <F2> - save and switch to previous tab
" <F3> - save and switch to next tab
" <F4> - save all opened files
"
" gci - comment/uncomment selected code (visual mode)
"
" <F8> - start shell in fullscreen (equivalent to :sh)
" <F9> - toggle project file tree window (:NERDTreeToggle)
"
" <F5> - build and run current CMake project
" <F6> - build current CMake project, but don't run
" <F7> - run current file as a single script (.c .cpp .py)
" <S-F7> - configure current CMake project (via ccmake)
" <F10> - toggle compile error window (equivalent to :QFix)
" <F12> - search for required-from-here (useful for errors)
"
" <C-t> - toggle built-in terminal
" <C-\> - enter normal mode in terminal (to select text)
" i or a - get back to insert mode in terminal
" <C-w> w - switch out of terminal window (back to editor)
" <C-w> "" - paste from vim clipboard to terminal
"
"
" Build and Run
" =============
"
" For build and run projects, I use the plugin 'asynctasks.vim'.
"
" By default <F5> will build the CMake project, and run the target named 'main'.
" This is defined in the '~/.vim/tasks.ini', which is bundled in my '.vim':
"
" [+]
" build_type=Release
" build_target=main
" build_dir=build
" build_generator=Ninja
" run_target="$(VIM:build_dir)/$(VIM:build_target)"
" build_options=--parallel
" build_configs=
"
" [project-build]
" command=cmake -G "$(VIM:build_generator)" -B "$(VIM:build_dir)" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE="$(VIM:build_type)" $(VIM:build_configs) && cmake --build "$(VIM:build_dir)" --target "$(VIM:build_target)" --config "$(VIM:build_type)" $(VIM:build_options)
" output=quickfix
" cwd=$(VIM_ROOT)
"
" [project-run]
" command=$(VIM:run_target)
" output=quickfix
" cwd=$(VIM_ROOT)
"
" You can create a file named '.tasks' locally in the root of your project to
" override the default rules and variables, customized for your project, e.g.:
"
" [+]
" build_type=Debug
" build_target=zeno_pybind_module
" build_generator=Unix Makefiles
" run_target=python my_start_script.py
"
" May also use the :AsyncTaskEdit to create the '.tasks' file in project root.
" It will recognize the first directory containing '.tasks' or '.git' as root.
"
" See https://github.com/skywind3000/asynctasks.vim/blob/master/README-cn.md
"
"
" Auto completion
" ===============
"
" For auto-completion, I use the plugin 'coc.nvim', recommended by my students.
" Although 'coc.nvim' sounds like a NeoVim plugin, it works well in Vim too.
"
" IMPORTANT: Even after running :PlugInstall, auto-completion still won't work.
" You need the follow the below instructions carefully to set it up as well.
"
" To make 'coc.nvim' work at all, you need to first install Node.js:
"
" $ pacman -S nodejs # Arch Linux
" $ apt install nodejs # Ubuntu
" $ brew install -g node # MacOS
" $ node --version # check if installation succeed
"
"
" For C++ developers
" ------------------
"
" To make 'coc.nvim' work for C++, you need to install 'ccls'.
" First, run this command in Vim to enable 'ccls' in 'coc.nvim':
"
" :CocInstall coc-ccls
"
" Second, you need to install 'ccls' to your system.
" Arch Linux could install from their package manager:
"
" $ sudo pacman -S ccls
" $ ccls --version
"
" Ubuntu and MacOS could build ccls from source (tested on clang-13):
"
" $ git clone --depth=1 --recursive https://github.com/MaskRay/ccls.git
" $ cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++
" $ cmake --build build --parallel 4
" $ sudo cmake --build build --target install
" $ ccls --version
"
" Now create a C++ file to test if auto-completion works, say:
"
" $ vim /tmp/test.cpp
"
" If it complains an error: 'extension "coc-ccls" doesn't contain main file'
" Don't worry, I meet this error too. Fix it by executing:
"
" $ cd ~/.config/coc/extensions/node_modules/coc-ccls/
" $ ln -s node_modules/ws/lib/ ./
"
" Now restart Vim and the error is gone, and another error occurs:
"
" [coc.nvim] Server languageserver.ccls failed to start: Error: invalid params
" of initialize: expected array for /workspaceFolders
"
" This means it doesn't find the 'compile_commands.json' of your project.
" This file contains information like compiler flags, include directories which
" are required by 'ccls' for providing auto-completion.
"
" If your project is CMake, simply set CMAKE_EXPORT_COMPILE_COMMANDS to ON:
"
" $ cd MyProject/
" $ cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON
" $ vim MySourceFile.cpp
"
" CMake will automatically create the file 'build/compile_commands.json'.
" 'ccls' will recognize it. Now restart Vim, and auto-completion should work.
" If you use other build systems, search Bing: 'Bazel compile_commands.json'
"
" If you are using my <F5> key mapping to build your CMake project, then the
" '-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON' is automatically added, no worry.
"
" Note that the build directory must be 'build', otherwise ccls won't find it.
"
" Also try run :CocConfig to open the ~/.vim/coc-settings.json file. This file
" is already bundled in my .vim folder, containing a C/C++ configuration.
"
"
" For Python developers
" ---------------------
"
" To make 'coc.nvim' work for Python, you need 'pyright'.
" First, run this command in Vim to enable 'pyright' in 'coc.nvim':
"
" :CocInstall coc-pyright
"
" For more details (e.g. work with Conda), see their official document:
" https://github.com/fannheyward/coc-pyright
"
" For other languages support of 'coc.nvim', see their official support list:
"
" https://github.com/neoclide/coc.nvim/wiki/Language-servers#ccobjective-c
"
"
" Key maps
" --------
"
" <c-space> - trigger completion (in insert mode)
" <tab> - next completion (in insert mode)
" <s-tab> - previous completion (in insert mode)
"
" gd - goto definition
" gD - goto type definition
" gc - goto declaration
" gC - goto implementation
" gr - goto references
" gR - rename current symbol under cursor
" gq - format selected code (visual mode)
" gf - goto file path under cursor (no line number)
" gF - goto file path under cursor (with line number)
" K - show documentation of symbol under cursor
"
" gaga - show code actions on current line
" gaq - quick fix error on current line
"
" vif - select current function scope (inner)
" vaf - select current function scope (outer)
" vic - select current class scope (inner)
" vac - select current class scope (outer)
"
"
" Fuzzy find
" ==========
"
" For fuzzy find, I use the plugin 'LeaderF'. It uses the Unix command
" line tools 'rg'. So make sure you have installed it first:
"
" $ pacman -S ripgrep # Arch Linux
" $ apt-get install ripgrep # Ubuntu
" $ brew install ripgrep # MacOS
" $ rg --version # check if installation succeed
"
"
" Key maps
" --------
"
" gff - fuzzy find file names in project directory
" gfb - fuzzy find file names in all opened files
" gfm - fuzzy find most-recently-used opened files
" gf: - fuzzy find runned ex-commands (:) in history
" gf/ - fuzzy find searched strings (/) in history
" gfx - fuzzy find vim ex-commands (including plugins)
" gfj - fuzzy find in vim jump history (related to Ctrl-I Ctrl-O)
" gfl - fuzzy find string in current opened file
" gft - fuzzy find tags in current opened file
" gfi - fuzzy find string under cursor in current file (may visual)
" gfa - fuzzy find string under cursor in project directory (may visual)
"
" <C-J> - select next fuzzy candidate (in fuzzy find window)
" <C-K> - select previous fuzzy candidate (in fuzzy find window)
" <CR> - open current selected candidate (double click will work too)
" <TAB> - switch between normal mode / insert mode (in fuzzy find window)
" p - peek the current selected candidate in popup window
" v - open current selected candidate in vertical splitted window
" x - open current selected candidate in horizontal splitted window
" Q - add current selected candidate to quickfix list
" L - add current selected candidate to location list
" d - delete current selected candidate
"
set nocompatible
set encoding=utf-8
set et ts=4 sts=4 sw=4
set fdm=syntax fdl=100
set nu ru ls=2
set hls is si
set cinoptions=j1,(0,ws,Ws,g0
set formatoptions-=cro
set timeout nottimeout ttimeoutlen=10
set mouse=a
set listchars=tab:▸\ ,trail:⋅,extends:❯,precedes:❮
set showbreak=↪
set list
"set noek
"set rulerformat=%55(%{strftime('%a\ %b\ %e\ %I:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%)
"set switchbuf=usetab
set undofile
if has('nvim')
set undodir=/tmp/nvim//,.
set backupdir=/tmp/nvim//,.
set directory=/tmp/nvim//,.
else
set undodir=/tmp//,.
set backupdir=/tmp//,.
set directory=/tmp//,.
endif
"set bg=dark
syntax on
filetype on
filetype plugin on
filetype indent on
"let g:mapleader = ' '
"let g:mapleader = ','
let g:mapleader = 'g'
nnoremap <silent> <F1> :wa<CR>:b#<CR>
nnoremap <silent> <F2> :wa<CR>:bp<CR>
nnoremap <silent> <F3> :wa<CR>:bn<CR>
nnoremap <silent> <F4> :wa<CR>
inoremap <silent> <F1> <ESC>
inoremap <silent> <F2> <ESC>:wa<CR>:bp<CR>
inoremap <silent> <F3> <ESC>:wa<CR>:bn<CR>
inoremap <silent> <F4> <ESC>:wa<CR>
inoremap <silent> <F8> <ESC>:wa<CR>:sh<CR><CR>
nnoremap <F5> :AsyncTasks project-build project-run<CR>
nnoremap <F6> :AsyncTask project-build<CR>
nnoremap <F7> :AsyncTasks file-build file-run<CR>
if has('nvim')
nnoremap <F19> :AsyncTask project-config<CR>
else
nnoremap <S-F7> :AsyncTask project-config<CR>
endif
nnoremap <silent> <F8> :wa<CR>:sh<CR><CR>
nnoremap <silent> <F9> :wa<CR>:NERDTreeToggle<CR><C-w>l:Vista!!<CR><C-w>h
nnoremap <silent> <F10> :wa<CR>:QFix<CR>
nnoremap <silent> <F12> /required from here<CR>
"nnoremap <silent> <C-k> <C-w>k:q<CR>
"nnoremap <silent> <C-j> <C-w>j
inoremap kj <ESC>
"inoremap <DEL> <ESC>
"nnoremap <DEL> <ESC>
"vnoremap <DEL> <ESC>
nnoremap Z ZZ
nnoremap Q :wa!<CR>:qa!<CR>
nnoremap H ^
nnoremap L $
vnoremap H ^
vnoremap L $
"nnoremap z zz
"vnoremap z zz
"nnoremap <CR> O<ESC>cc<ESC>j
tnoremap <C-\> <C-\><C-n>
if !has('nvim')
tnoremap <ScrollWheelUp> <C-\><C-n><ScrollWheelUp>
tnoremap <ScrollWheelDown> <C-\><C-n><ScrollWheelDown>
endif
vnoremap Z :w !xsel -ib<CR><CR>
" MacOS user should use this:
"vnoremap Z :w !pbcopy<CR><CR>
" no longer used vimspector:
"nmap <S-F3> <Plug>VimspectorStop
"nmap <S-F4> <Plug>VimspectorRestart
"nmap <S-F5> <Plug>VimspectorContinue
"nmap <S-F6> <Plug>VimspectorPause
"nmap <S-F8> <Plug>VimspectorRunToCursor
"nmap <C-S-F8> <Plug>VimspectorAddFunctionBreakpoint
"nmap <S-F9> <Plug>VimspectorToggleBreakpoint
"nmap <C-S-F9> <Plug>VimspectorToggleConditionalBreakpoint
"nmap <S-F10> <Plug>VimspectorStepOver
"nmap <S-F11> <Plug>VimspectorStepInfo
"nmap <S-F12> <Plug>VimspectorStepOut
"nmap <LEADER>= <Plug>VimspectorBalloonEval
"xmap <LEADER>= <Plug>VimspectorBalloonEval
"let g:ycm_semantic_triggers = {'VimspectorPrompt': ['.', '->', ':', '<']}
"let g:cmake_vimspector_support = 1
"let g:cmake_vimspector_default_configuration = {
"\ 'adapter': 'vscode-cpptools',
"\ 'configuration': {
"\ 'type': '',
"\ 'request': 'launch',
"\ 'cwd': '${workspaceRoot}',
"\ 'Mimode': '',
"\ 'args': [],
"\ 'program': '',
"\ "setupCommands": [
"\ {
"\ "description": "Enable pretty-printing for gdb",
"\ "text": "-enable-pretty-printing",
"\ "ignoreFailures": 'true',
"\ }
"\ ],
"\ }
"\ }
" rid annoying swap prompts:
autocmd SwapExists * let v:swapchoice = "e"
" goto last location on open:
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" open NERDTree on vim start:
"autocmd VimEnter * NERDTree | wincmd p
"autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" no longer used cmake4vim:
"let g:cmake_usr_args = '-GNinja'
"let g:cmake_build_target = 'main'
"let g:cmake_build_type = 'Release'
"let g:cmake_compile_commands = 1
"let g:cmake_build_path_pattern = ["%s/build", "getcwd()"]
" no longer used YouCompleteMe:
"let g:ycm_confirm_extra_conf = 0
"let g:ycm_error_symbol = '✗'
"let g:ycm_warning_symbol = '⚠'
"let g:ycm_filetype_whitelist = {"c": 1, "cpp": 1, "python": 1}
"let g:ycm_min_num_of_chars_for_completion = 2
"let g:ycm_show_diagnostics_ui = 1
"let g:ycm_key_invoke_completion = '<c-z>'
"let g:ycm_enable_diagnostic_signs = 0
"let g:ycm_enable_diagnostic_highlighting = 1
""let g:ycm_show_diagnostics_ui = 0
""let g:ycm_key_list_select_completion = ['<TAB>']
""let g:ycm_key_list_previous_completion = []
" no longer used ultisnips:
"let g:UltiSnipsExpandTrigger="<c-s>"
"let g:UltiSnipsJumpForwardTrigger="<tab>"
"let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
"let g:UltiSnipsEditSplit="vertical"
" no longer used vim-cpp-modern:
"let g:cpp_attributes_highlight = 1
"let g:cpp_member_highlight = 1
" for vim-airline:
let g:airline#extensions#coc#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#buffer_nr_show = 0
let g:airline#extensions#tabline#formatter = 'default'
let g:airline#extensions#keymap#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
" 设置切换tab的快捷键 <\> + <i> 切换到第i个 tab
nmap <silent> <leader>1 <Plug>AirlineSelectTab1
nmap <silent> <leader>2 <Plug>AirlineSelectTab2
nmap <silent> <leader>3 <Plug>AirlineSelectTab3
nmap <silent> <leader>4 <Plug>AirlineSelectTab4
nmap <silent> <leader>5 <Plug>AirlineSelectTab5
nmap <silent> <leader>6 <Plug>AirlineSelectTab6
nmap <silent> <leader>7 <Plug>AirlineSelectTab7
nmap <silent> <leader>8 <Plug>AirlineSelectTab8
nmap <silent> <leader>9 <Plug>AirlineSelectTab9
"nmap <silent> <leader>1 :tab1<CR>
"nmap <silent> <leader>2 :tab2<CR>
"nmap <silent> <leader>3 :tab3<CR>
"nmap <silent> <leader>4 :tab4<CR>
"nmap <silent> <leader>5 :tab5<CR>
"nmap <silent> <leader>6 :tab6<CR>
"nmap <silent> <leader>7 :tab7<CR>
"nmap <silent> <leader>8 :tab8<CR>
"nmap <silent> <leader>9 :tab9<CR>
"cabbrev o tab drop
"cabbrev e tabe
"cabbrev m tabm
"cabbrev a tab ball
"autocmd BufReadPost * tab ball
" no longer used vim-terminal-help:
"let g:terminal_key = '<c-=>'
"let g:terminal_default_mapping = 1
"inoremap ÏF <ESC>A
"inoremap ÏH <ESC>I
"nnoremap ÏH ^
"nnoremap ÏF $
"vnoremap ÏH ^
"vnoremap ÏF $
" no longer used YouCompleteMe:
"nnoremap <LEADER><LEADER> :YcmCompleter GoTo<CR>
"nnoremap <LEADER>[ :YcmCompleter GoToDefinitionElseDeclaration<CR>
"nnoremap <LEADER>d :YcmCompleter GetDoc<CR>
"nnoremap <LEADER>r :YcmCompleter RefactorRename<SPACE>
"nnoremap <LEADER>f :YcmCompleter FixIt<CR>1
"nnoremap <LEADER>y :call ToggleYcmDiagnostics()<CR><CR>:wa<CR>:e<CR>
"func! ToggleYcmDiagnostics()
"let g:ycm_show_diagnostics_ui = !g:ycm_show_diagnostics_ui
"YcmRestartServer
"endfunc
" no longer used vim-ctrlspace:
"if has('nvim')
"let g:CtrlSpaceDefaultMappingKey = "<C-space> "
"endif
"let g:CtrlSpaceLoadLastWorkspaceOnStart = 1
"let g:CtrlSpaceSaveWorkspaceOnSwitch = 1
"let g:CtrlSpaceSaveWorkspaceOnExit = 1
"if executable('rg')
"let g:CtrlSpaceGlobCommand = 'rg --color=never --files'
"elseif executable('ag')
"let g:CtrlSpaceGlobCommand = 'ag -l --nocolor -g ""'
"endif
"nnoremap <silent><C-p> :CtrlSpace O<CR>
" no longer used fzf.vim:
"nnoremap <silent> <space>f :Files<CR>
"nnoremap <silent> <space>g :GFiles<CR>
"nnoremap <silent> <space>s :GFiles?<CR>
"nnoremap <silent> <space>b :Buffers<CR>
"nnoremap <silent> <space>a :Ag<CR>
"nnoremap <silent> <space>r :Rg<CR>
"nnoremap <silent> <space>l :Lines<CR>
"nnoremap <silent> <space>o :BLines<CR>
"nnoremap <silent> <space>h :History<CR>
"nnoremap <silent> <space>: :History:<CR>
"nnoremap <silent> <space>/ :History/<CR>
"nnoremap <silent> <space>c :Commits<CR>
"nnoremap <silent> <space>x :Commands<CR>
"nnoremap <silent> <space>w :Windows<CR>
"nnoremap <silent> <space>m :Maps<CR>
"nmap <leader><tab> <plug>(fzf-maps-n)
"xmap <leader><tab> <plug>(fzf-maps-x)
"omap <leader><tab> <plug>(fzf-maps-o)
"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)
" for LeaderF:
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1
let g:Lf_PreviewCode = 1
"let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2", 'font': "DejaVu Sans Mono for Powerline" }
"let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 }
let g:Lf_ShortcutF = "<leader>ff"
"noremap <leader>ff :<C-U><C-R>=printf("Leaderf file %s", "")<CR><CR>
noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
noremap <leader>fx :<C-U><C-R>=printf("Leaderf command %s", "")<CR><CR>
noremap <leader>f: :<C-U><C-R>=printf("Leaderf cmdHistory %s", "")<CR><CR>
noremap <leader>f/ :<C-U><C-R>=printf("Leaderf searchHistory %s", "")<CR><CR>
noremap <leader>fw :<C-U><C-R>=printf("Leaderf window %s", "")<CR><CR>
noremap <leader>fj :<C-U><C-R>=printf("Leaderf jumps %s", "")<CR><CR>
noremap <leader>fi :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s", expand("<cword>"))<CR><CR>
noremap <leader>fa :<C-U><C-R>=printf("Leaderf! rg -e %s", expand("<cword>"))<CR><CR>
xnoremap <leader>fi :<C-U><C-R>=printf("Leaderf! rg --current-buffer -F -e %s", leaderf#Rg#visual())<CR><CR>
xnoremap <leader>fa :<C-U><C-R>=printf("Leaderf! rg -F -e %s", leaderf#Rg#visual())<CR><CR>
noremap <leader>fr :<C-U>Leaderf! rg --recall<CR>
" should use `Leaderf gtags --update` first
"let g:Lf_GtagsAutoGenerate = 0
"let g:Lf_Gtagslabel = 'native-pygments'
"noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR>
"noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR>
"noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR>
"noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR>
"noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>
" for coc.nvim:
"let g:coc_global_extensions = ['coc-ccls', 'coc-pyright', 'coc-json', 'coc-git']
" BEGIN_COC_NVIM {{{
" References: https://github.com/neoclide/coc.nvim#example-vim-configuration
set nohidden
set nobackup
set nowritebackup
set updatetime=300
set cmdheight=1
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("nvim-0.5.0") || has("patch-8.1.1564")
set signcolumn=number
else
set signcolumn=yes
endif
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> pumvisible() ? coc#_select_confirm() : coc#refresh()
else
inoremap <silent><expr> <c-@> pumvisible() ? coc#_select_confirm() : coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
"inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
"\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
"inoremap <silent><expr> <space> pumvisible() ? (<SID>check_back_space() ? "\<space>" : coc#_select_confirm()) : "\<space>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> <leader>l[ <Plug>(coc-diagnostic-prev)
nmap <silent> <leader>l] <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> <leader>d <Plug>(coc-definition)
nmap <silent> <leader>D <Plug>(coc-type-definition)
nmap <silent> <leader>c <Plug>(coc-declaration)
nmap <silent> <leader>C <Plug>(coc-implementation)
nmap <silent> <leader>r <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>R <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>q <Plug>(coc-format-selected)
"nmap <leader>q <Plug>(coc-format-selected)
nnoremap <leader>q :Format<CR>
" Restart CoC
"nmap <silent> <leader>t :CocRestart<CR><CR>
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>aq <Plug>(coc-fix-current)
" Run the Code Lens action on the current line.
nmap <leader>al <Plug>(coc-codelens-action)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
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)
" 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
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('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 OrgImport :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings for CoCList
" Using CocList
" Show all diagnostics
nnoremap <silent> <leader>la :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <leader>le :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <leader>lc :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <leader>lo :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <leader>ls :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <leader>lj :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <leader>lk :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <leader>lp :<C-u>CocListResume<CR>
" Show git status
nnoremap <silent> <leader>lg :<C-u>CocList --normal gstatus<CR>
" }}} END_COC_NVIM
" for coc-snippets:
let g:coc_snippet_next = '<tab>'
" for vim-floaterm:
let g:floaterm_wintype = 'split'
let g:floaterm_position = 'botright'
let g:floaterm_height = 12
"let g:floaterm_keymap_new = '<F1>'
"let g:floaterm_keymap_prev = '<F2>'
"let g:floaterm_keymap_next = '<F3>'
let g:floaterm_keymap_toggle = '<C-t>'
" for asynctasks.vim:
let g:asyncrun_open = 6
let g:asynctasks_term_pos = 'floaterm_reuse'
let g:asynctasks_term_rows = 6
let g:asynctasks_term_cols = 50
let g:asynctasks_term_reuse = 1
let g:asynctasks_term_focus = 0
let g:asyncrun_rootmarks = ['.tasks', '.git/']
function! AsyncTaskMultiple(first, ...)
if len(a:000) >= 1
if a:first == 0
cclose
endif
let l:tmp = ""
for task in a:000[1:]
let l:tmp .= "'".l:task."',"
endfor
let l:tmp = l:tmp[:-1]
let g:asyncrun_exit = "if g:asyncrun_code == 0 | call AsyncTaskMultiple(0, ".l:tmp.") | else | call AsyncTaskMultiple(0) | endif"
exec "AsyncTask ".a:000[0]
else
let g:asyncrun_exit = ""
endif
endfunction
command! -nargs=+ AsyncTasks :call AsyncTaskMultiple(1, <f-args>)
" for incsearch.vim
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
set hlsearch
let g:incsearch#auto_nohlsearch = 1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
function! s:noregexp(pattern) abort
return '\V' . escape(a:pattern, '\')
endfunction
function! s:incsconfig() abort
return {'converters': [function('s:noregexp')]}
endfunction
noremap <silent><expr> z/ incsearch#go(<SID>incsconfig())
" begin plugin list
call plug#begin()
"Plug 'vim-scripts/surround.vim'
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'archibate/QFixToggle', {'on': 'QFix'}
Plug 'tpope/vim-fugitive'
"Plug 'bfrg/vim-cpp-modern', {'for': 'cpp'}
Plug 'vim-scripts/vim-airline'
"Plug 'cskeeters/vim-smooth-scroll'
Plug 'tikhomirov/vim-glsl', {'for': 'glsl'}
"Plug 'junegunn/vim-slash'
"Plug 'vim-scripts/a.vim', {'for': ['c', 'cpp', 'cuda']}
Plug 'machakann/vim-swap'
Plug 'preservim/nerdcommenter'
"Plug 'preservim/vimux'
"Plug 'peterhoeg/vim-qml', {'for': 'qml'}
"Plug 'SirVer/ultisnips'
"Plug 'honza/vim-snippets'
"Plug 'neoclide/coc-snippets'
Plug 'jackguo380/vim-lsp-cxx-highlight'
Plug 'mbbill/undotree', {'on': 'UndoTreeToggle'}
"Plug 'ilyachur/cmake4vim', {'on': ['CMake', 'CMakeBuild', 'CMakeInfo', 'CMakeRun']}
"Plug 'puremourning/vimspector'
"Plug 'ctrlpvim/ctrlp.vim', {'on': ['CtrlP']}
"Plug 'ycm-core/YouCompleteMe', {'do': './install.py --clang-completer', 'for': ['c', 'cpp', 'python']}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
"Plug 'junegunn/fzf.vim'
Plug 'skywind3000/asynctasks.vim'
Plug 'skywind3000/asyncrun.vim'
"Plug 'skywind3000/vim-terminal-help'
"Plug 'aben20807/vim-runner'
"Plug 'christoomey/vim-tmux-runner'
"Plug 'viniciusgerevini/tmux-runner.vim'
"Plug 'vim-ctrlspace/vim-ctrlspace'
Plug 'haya14busa/incsearch.vim'
Plug 'voldikss/vim-floaterm'
Plug 'findango/vim-mdx', {'for': 'mdx'}
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
Plug 'liuchengxu/vista.vim', {'on': 'Vista!!'}
call plug#end()
if filereadable(".vim_localrc")
source .vim_localrc
endif