forked from Why8n/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
827 lines (704 loc) · 24.8 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
"detected os:https://vi.stackexchange.com/questions/2572/detect-os-in-vimscript
function! IsWin32()
return has('win32')
endfunction
function! IsWin32Unix()
return has('win32unix')
endfunction
function! IsUnix()
return has('unix')
endfunction
function! IsMac()
return has('macunix')
endfunction
function! DownPlugVimAndInstall(path)
if empty(glob(a:path))
let cmd = '!curl -fLo "'.a:path.'" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
" silent !curl -fLo '~/.config/nvim/autoload/plug.vim' --create-dirs
" \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
execute l:cmd
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
endfunction
function! DownPlugVim2Windows4nvim(path)
call DownPlugVimAndInstall(a:path)
endfunction
function! DownPlugVim2Windows4vim(path)
call DownPlugVimAndInstall(a:path)
endfunction
function! DownPlugVim2Linux4nvim(path)
call DownPlugVimAndInstall(a:path)
endfunction
function! DownPlugVim2Windows()
if has('nvim')
call DownPlugVim2Windows4nvim($USERPROFILE.'/AppData/Local/nvim/autoload/plug.vim')
else
call DownPlugVim2Windows4vim($VIM.'/vimfiles/autoload/plug.vim')
endif
endfunction
function! DownPlugVim2Linux()
if has('nvim')
call DownPlugVim2Linux4nvim($HOME.'/.config/nvim/autoload/plug.vim')
else
call DownPlugVim2Linux4vim($HOME.'/.vim/autoload/plug.vim')
endif
endfunction
function! DownPlugVimIfNotExists()
if IsWin32()
call DownPlugVim2Windows()
elseif IsUnix() || IsWin32Unix() || IsMac()
call DownPlugVim2Linux()
endif
endfunction
" Auto download vim-plug for the first time
call DownPlugVimIfNotExists()
" global configurations
if IsWin32()
" source $VIMRUNTIME/general.vim
" C:/Users/<user>/general.vim
" source $userprofile/general.vim
let g:python3_host_prog ='D:\Program Files (x86)\Python\Python3\python.exe'
let g:ycm_extra_conf="D:/Program\ Files\ (x86)/Vim/vimfiles/.ycm_extra_conf.py"
let g:chrome = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
" custom plugin install path,so that vim and neovim can shared the same
" plugins (notice in windows: ~/.vim = c:\Users\<user>\.vim)
let g:plugins_path = 'D:\config\.vim\plugged'
" ctags_bin
let g:ctags_path = 'D:\config\ctags\ctags.exe'
elseif IsUnix() || IsWin32Unix() || IsMac()
let g:python3_host_prog ='/usr/bin/python'
let g:ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
let g:chrome = '/usr/bin/chrome'
let g:plugins_path = '~/.vim/plugged'
let g:ctags_path = '/usr/bin/ctags'
endif
" let g:python3_host_prog ='"D:/Program Files (x86)/Python/python3/python.exe"'
" let g:python3_host_prog = IsWin32() ? '"D:/Program Files (x86)/Python/python3/python.exe"' : '/usr/bin/python'
source ~/general.vim
" reload vimrc
map <C-l> :source $MYVIMRC<CR>
" no backup
set noundofile
set nobackup
set noswapfile
" No annoying sound on errors
set noerrorbells
set novisualbell
set vb t_vb= " turn off visual bell,error flash
set tm=500
" set cmd window height :( cmd )
set cmdheight=1
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" remove gui
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
" Fixing Vim's Background Color Erase for 256-color tmux and GNU screen
if !empty(&t_ut)
" see http://snk.tuxfamily.org/log/vim-256color-bce.html
let &t_ut=''
endif
" x显示末尾空格
set list
set listchars=tab:..,trail:_,extends:>,precedes:<,nbsp:~
set showbreak=\\ " [bonus]
" jump to last known cursor position when reopen a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
endif
" Disable arrow movement, resize splits instead.
" if get(g:, 'elite_mode')
map <Up> :resize +2<CR>
map <Down> :resize -2<CR>
map <Left> :vertical resize +2<CR>
map <Right> :vertical resize -2<CR>
" auto complete brackets
" inoremap {<CR> {<C-o>o}<C-o>O
" inoremap ( ()<ESC>i
" inoremap < <><ESC>i
" inoremap " ""<ESC>i
" inoremap ' ''<ESC>i
" disable window search style
" nnoremap <C-f> /
" inoremap <C-f> <ESC>/
" vnoremap <C-f> <ESC>/<C-r><C-w>
" " command mode
" cnoremap <C-f> <C-r><C-w>
" plug-vim configurations
call plug#begin(g:plugins_path)
"
" -------------------------------------------------------------------------
" add plugin here
" Plug 'dyng/ctrlsf.vim'
" way too slow on huge files,TODO::delete
Plug 'ctrlpvim/ctrlp.vim', {'on':'CtrlP'}
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'easymotion/vim-easymotion'
Plug 'vim-syntastic/syntastic'
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdcommenter'
" markdown
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install_sync() },'for':['markdown','vim-plug']}
" markdown table improvment
Plug 'dhruvasagar/vim-table-mode', { 'on': 'TableModeToggle' }
" Plug 'reedes/vim-pencil'
"Plug 'Valloric/YouCompleteMe'
" Plug 'Raimondi/delimitMate'
Plug 'jiangmiao/auto-pairs'
" Bookmarks
Plug 'kshenoy/vim-signature'
Plug 'vim-scripts/Marks-Browser'
Plug 'udalov/kotlin-vim', { 'for': 'kotlin' }
" switch input method
Plug 'https://github.com/vim-scripts/fcitx.vim.git'
" HTML, CSS, JavaScript, PHP, JSON, etc.
Plug 'elzr/vim-json'
Plug 'hail2u/vim-css3-syntax'
Plug 'gko/vim-coloresque', { 'for': ['vim-plug', 'php', 'html', 'javascript', 'css', 'less'] }
Plug 'pangloss/vim-javascript', { 'for' :['javascript', 'vim-plug'] }
Plug 'mattn/emmet-vim'
" Python
Plug 'vim-scripts/indentpython.vim', { 'for' :['python', 'vim-plug'] }
Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }
Plug 'terryma/vim-multiple-cursors'
" Hyperfocus-writing in Vim
Plug 'junegunn/limelight.vim'
" distraction free writing mode
Plug 'junegunn/goyo.vim'
" 文本对齐插件
Plug 'godlygeek/tabular'
" Find And Replace Vim plugin
Plug 'brooth/far.vim'
" 缩进指示线
Plug 'Yggdroot/indentLine'
" scheme for console
" Plug 'jnurmine/Zenburn'
Plug 'kristijanhusak/vim-hybrid-material'
" Plug 'davidhalter/jedi-vim'
if has('nvim')
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-jedi'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
" Plug 'ncm2/ncm2-match-highlight'
Plug 'ncm2/ncm2-markdown-subscope'
endif
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'majutsushi/tagbar', { 'on': 'TagbarOpenAutoClose' }
Plug 'mbbill/undotree'
Plug 'tpope/vim-repeat'
" -------------------------------------------------------------------------
" All of your Plugins must be added before the following line
" Initialize plugin system
call plug#end()
" colorscheme settings must after plug#end(),cuz only when plug#end that plugins work
if has('gui_running')
colorscheme SolarizedDark
else
" colorscheme zenburn
set background=dark
colorscheme hybrid_reverse
highlight Visual cterm=NONE ctermbg=0 ctermfg=NONE guibg=Grey40
endif
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set background=dark
colorscheme hybrid_reverse
highlight Visual cterm=NONE ctermbg=0 ctermfg=NONE guibg=Grey30
" making functions and language controls to be bolded
let g:enable_bold_font = 1
" make comments to be in italic
let g:enable_italic_font = 1
" make background transparent
let g:hybrid_transparent_background = 1
let g:airline_theme = "hybrid"
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
" ====== plugins configurations
" -------------
" ctrlsf
" -------------
" if executable('ag')
" let g:ctrlsf_ackprg = 'ag'
" endif
" let g:ctrlsf_case_sensitive = 'smart'
" let g:ctrlsf_default_root = 'project'
" let g:ctrlsf_default_view_mode = 'normal'
" let g:ctrlsf_position = 'left'
" let g:ctrlsf_winsize = '30%'
"
" nmap <C-f> :CtrlSF <C-r><C-w>
" imap <C-f> <ESC>:CtrlSF<Space>
" " visiual and select mode
" vmap <C-f> "1y:CtrlSF<Space><C-R>1<CR>
" " visiual mode
" " xnoremap <C-f> :CtrlSF<Space>
" " command line mode
" cmap <C-f> CtrlSF<Space>
"
" ------------
" ctrlp
" ------------
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
" set local working directory:current file
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_max_files=0
let g:ctrlp_max_depth=40
" exclusions
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ }
" let g:ctrlp_user_command = ['.git/', 'git ls-files --cached --others --exclude-standard %s']
" Use a custom file listing command:
" The Silver Searcher
if executable('ag')
" Use ag over grep
let g:ctrlp_user_command = ['ag','ag %s -i --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore "**/*.pyc"
\ -g ""' ]
elseif IsUnix() || IsMac()
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
elseif IsWin32()
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
endif
" ------------
" nerdtree
" ------------
nmap wm :NERDTreeToggle<CR>
let NERDTreeWinPos='left'
let NERDTreeWinSize=30
" 当不带参数打开Vim时自动加载项目树 -- no
autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" 当所有文件关闭时关闭项目树窗格
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" 不显示这些文件
let NERDTreeIgnore=['\.pyc$', '\~$', 'node_modules'] "ignore files in NERDTree
" 不显示项目树上额外的信息,例如帮助、提示什么的
let NERDTreeMinimalUI=1
"Refresh both CtrlP and NERDTree
nmap <Leader>r :NERDTreeFocus<cr>R<c-w><c-p>:CtrlPClearCache<cr>
" --------------
" syntastic
" --------------
" syntastic default config
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" overwrite quickfix when execute :SyntasticSetLocList
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
map <F2> :SyntasticToggleMode<CR>
" ---------------
" nerdcommenter
" ---------------
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
let g:NERDCustomDelimiters = { 'java': { 'left': '//'} }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
vmap <C-b> <leader>cc
" -----------------------
" markdown-preview.nvim
" -----------------------
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 0
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
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
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = g:chrome
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {}
\ }
" use a custom markdown style must be absolute path
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
map <silent> <F8> <Plug>MarkdownPreview
map <silent> <F9> <Plug>MarkdownPreviewStop
nmap <silent> <Leader>md <Plug>MarkdownPreview
" -----------------
" vim-table-mode
" -----------------
" 配置快捷键
nmap <Leader>tm :TableModeToggle<CR>
" markdown-compatible tables
let g:table_mode_corner='|'
function! s:isAtStartOfLine(mapping)
let text_before_cursor = getline('.')[0 : col('.')-1]
let mapping_pattern = '\V' . escape(a:mapping, '\')
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
endfunction
" 插入模式下,按 || 使能插件
inoreabbrev <expr> <bar><bar>
\ <SID>isAtStartOfLine('\|\|') ?
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
" 插入模式下,按 __ 失能插件
inoreabbrev <expr> __
\ <SID>isAtStartOfLine('__') ?
\ '<c-o>:silent! TableModeDisable<cr>' : '__'
" ---------------------------
" indentLine configuration
" ---------------------------
" do not highlight conceal color(not background)
let g:indentLine_setColors = 1
" customize conceal color
" Vim
let g:indentLine_color_term = 239
" GVim
let g:indentLine_color_gui = '#A4E57E'
" none X terminal
let g:indentLine_color_tty_light = 7 " (default: 4)
let g:indentLine_color_dark = 1 " (default: 2)
" Background (Vim, GVim)
let g:indentLine_bgcolor_term = 202
" let g:indentLine_char = 'c'
" let g:indentLine_char_list = ['|', '¦', '┆', '┊']
" change conceal behaviour
let g:indentLine_concealcursor = 'inc'
let g:indentLine_conceallevel = 2
" -------------
" ncm2 configuration
" -------------
if has('nvim')
" inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>": "\<CR>")
autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
let ncm2#popup_delay = 5
let g:ncm2#matcher = "substrfuzzy"
let g:ncm2_jedi#python_version = 3
" let g:ncm2#match_highlight = 'sans-serif'
endif
" -------------
" jedi-vim
" -------------
"let g:jedi#auto_initialization = 1
""let g:jedi#completion_enabled = 0
""let g:jedi#auto_vim_configuration = 0
""let g:jedi#smart_auto_mapping = 0
"let g:jedi#popup_on_dot = 1
"let g:jedi#completion_command = ""
"let g:jedi#show_call_signatures = "1"
" ----------------
" vim-pencil
" ----------------
" augroup pencil
" autocmd!
" autocmd FileType markdown,mkd,md call pencil#init()
" autocmd FileType text call pencil#init()
" augroup END
" let g:airline_section_x = '%{PencilMode()}'
"
"----------------------------
"YouCompleteMe
"----------------------------
"let g:ycm_key_invoke_completion = '<M-/>' "default <C-Space>,modify to alt+/
"" 自动补全配置
"set completeopt=longest,menu " "让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
"autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" "回车即选中当前项
"
""youcompleteme 默认tab s-tab 和自动补全冲突
"let g:ycm_key_list_select_completion=['<c-n>']
"let g:ycm_key_list_select_completion = ['<Down>']
"let g:ycm_key_list_previous_completion=['<c-p>']
"let g:ycm_key_list_previous_completion = ['<Up>']
"let g:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示
"
"let g:ycm_min_num_of_chars_for_completion = 1
""在注释输入中也能补全
"let g:ycm_complete_in_comments = 1
""在字符串输入中也能补全
"let g:ycm_complete_in_strings = 1
""注释和字符串中的文字也会被收入补全
"let g:ycm_collect_identifiers_from_comments_and_strings = 0
"" 让YouCompleteMe同时利用原来的ctags
"let g:ycm_collect_identifiers_from_tag_files = 1
"let g:clang_user_options='|| exit 0'
"nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处
let g:ycm_server_python_interpreter=g:python3_host_prog
let g:ycm_global_ycm_extra_conf= g:ycm_extra_conf
" add support completions of java
let g:EclimCompletionMethod = 'omnifunc'
" add support completions of python
let g:ycm_python_binary_path =g:python3_host_prog
" -------------------
" delimitMate
" ------------------
" inoremap {<CR> {<CR>}<C-o>O
" Use this option to tell delimitMate which characters should be considered
" matching pairs. Read |delimitMateAutoClose| for details.
" let delimitMate_matchpairs = "(:),[:],{:}"
" au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
"
"
" -----------------------
" vim-signature
" -----------------------
"
let g:SignatureMap = {
\ 'Leader' : "m",
\ 'PlaceNextMark' : "m,",
\ 'ToggleMarkAtLine' : "m.",
\ 'PurgeMarksAtLine' : "m-",
\ 'DeleteMark' : "dm",
\ 'PurgeMarks' : "dm/",
\ 'PurgeMarkers' : "m<BS>",
\ 'GotoNextLineAlpha' : "']",
\ 'GotoPrevLineAlpha' : "'[",
\ 'GotoNextSpotAlpha' : "`]",
\ 'GotoPrevSpotAlpha' : "`[",
\ 'GotoNextLineByPos' : "]<Leader>",
\ 'GotoPrevLineByPos' : "[<Leader>",
\ 'GotoNextSpotByPos' : "]`",
\ 'GotoPrevSpotByPos' : "[`",
\ 'GotoNextMarker' : "]-",
\ 'GotoPrevMarker' : "[-",
\ 'GotoNextMarkerAny' : "]=",
\ 'GotoPrevMarkerAny' : "[=",
\ 'ListBufferMarks' : "m/",
\ 'ListBufferMarkers' : "m?"
\ }
" -----------------------
" marks-browers
" -----------------------
nmap <silent> <leader>mb :MarksBrowser<cr>
" the browser window close itself after you jump to a mark
let marksCloseWhenSelected = 1
" ----------------------
" vim-multiple-cursor
" ----------------------
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 = '<A-n>'
let g:multi_cursor_start_key = 'g<C-n>'
let g:multi_cursor_select_all_key = 'g<A-n>'
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
" fix <A-n> not working in VIM,but works in gVIM
if !has('gui_running')
map "in Insert mode, type Ctrl+v Alt+n here" <A-n>
endif
" fix <C-n> not working in gVIM
set selection=inclusive
" ---------------
" limelight
" ---------------
" Color name (:help cterm-colors) or ANSI code
let g:limelight_conceal_ctermfg = 'gray'
let g:limelight_conceal_ctermfg = 240
" Color name (:help gui-colors) or RGB color
let g:limelight_conceal_guifg = 'DarkGray'
let g:limelight_conceal_guifg = '#777777'
" Default: 0.5
let g:limelight_default_coefficient = 0.7
" Number of preceding/following paragraphs to include (default: 0)
let g:limelight_paragraph_span = 1
" Beginning/end of paragraph
" When there's no empty line between the paragraphs
" and each paragraph starts with indentation
let g:limelight_bop = '^\s'
let g:limelight_eop = '\ze\n^\s'
" Highlighting priority (default: 10)
" Set it to -1 not to overrule hlsearch
let g:limelight_priority = -1
" ----------------
" goyo.vim
" ----------------
let g:gyo_width=80
let g:goyo_height='85%'
let g:goyo_linenr=0
nmap <Leader>gy :Goyo<CR>
xmap <Leader>gy :Goyo<CR>
"进入goyo模式后自动触发limelight,退出后则关闭
function! s:goyo_enter()
if executable('tmux') && strlen($TMUX)
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
Limelight
" ...
endfunction
function! s:goyo_leave()
if executable('tmux') && strlen($TMUX)
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" ------------------
" tagbar
" ------------------
map <silent> <leader>tb :TagbarOpenAutoClose<CR>
let g:tagbar_ctags_bin = g:ctags_path
" --------------------
" undotree
" --------------------
nnoremap <Leader>ud :UndotreeToggle<CR>
" 持久化历史记录
" if has("persistent_undo")
" set undodir=$HOME."/.undodir"
" set undofile
" endif
"
"
" ------------------------
" fzf
" ------------------------
if has('nvim') || has('gui_running')
let $FZF_DEFAULT_OPTS .= ' --inline-info'
endif
" Hide statusline of terminal buffer
autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
" In Neovim, you can set up fzf window using a Vim command
let g:fzf_layout = { 'window': 'enew' }
let g:fzf_layout = { 'window': '-tabnew' }
" let g:fzf_layout = { 'window': '10new' }
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
xnoremap <silent> <Leader>ag y:Ag <C-R>"<CR>
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
nnoremap <silent> <Leader>rg :Rg <C-R><C-W><CR>
xnoremap <silent> <Leader>rg y:Rg <C-R>"<CR>
nnoremap <silent> <Leader>fz :Files<CR>
" -------------------
" tpope/vim-repeat
" -------------------
silent! call repeat#set("\<Plug>MarkdownPreview", v:count)
" ===plugins configurations end
map <F5> :call CompileRun()<CR>
nmap <leader>cmd :call CompileRun()<CR>
func! CompileRun()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %< && ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %< && ./%<"
elseif &filetype == 'java'
exec "!javac % && java %<"
elseif &filetype == 'kotlin'
if IsWin32()
exec "!kotlinc % -include-runtime -d %<.jar && java -jar %<.jar && del %<.jar"
else
exec "!kotlinc % -include-runtime -d %<.jar && java -jar %<.jar && rm %<.jar"
endif
elseif &filetype == 'python'
exec "!\"".g:python3_host_prog."\" %"
elseif &filetype == 'html'
exec "!chrome % &"
elseif &filetype == 'go'
exec "!go build %< && go run %"
elseif &filetype == 'mkd'
exec "!~/.vim/markdown.pl % > %.html & && !chrome %.html &"
elseif &filetype == 'sh'
:!bash %
elseif &filetype == 'dosbatch'
exec "!cmd /c %"
endif
endfunc