-
Notifications
You must be signed in to change notification settings - Fork 76
/
.vimrc
executable file
·580 lines (497 loc) · 19.4 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
""""""""""""""""""""""VIM-PLUG""""""""""""""""""""
" download plug.vim
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
" Initialize plugin system
call plug#begin('~/.vim/plugged')
" A tree explorer plugin for vim. https://github.com/scrooloose/nerdtree
Plug 'preservim/nerdtree'
" Vim plugin for intensely orgasmic commenting. https://github.com/scrooloose/nerdcommenter
Plug 'preservim/nerdcommenter'
" fugitive.vim: A Git wrapper so awesome, it should be illegal,放在最后可能airline不能显示branch
Plug 'tpope/vim-fugitive'
" lean & mean status/tabline for vim that's light as air. https://github.com/vim-airline/vim-airline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" color scheme. https://github.com/axiaoxin/vim-colorschemes
Plug 'axiaoxin/vim-colorschemes'
" Pick the VIM colorscheme that you are destined to be with.:) https://github.com/sunuslee/vim-plugin-random-colorscheme-picker
Plug 'sunuslee/vim-plugin-random-colorscheme-picker'
" The fancy start screen for Vim. https://github.com/mhinz/vim-startify
Plug 'mhinz/vim-startify'
" Go development plugin for Vim. https://github.com/fatih/vim-go
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries', 'for': 'go' }
" Better Rainbow Parentheses. https://github.com/kien/rainbow_parentheses.vim
Plug 'kien/rainbow_parentheses.vim'
" VIM Table Mode for instant table creation. https://github.com/dhruvasagar/vim-table-mode
Plug 'dhruvasagar/vim-table-mode', { 'for': ['md', 'markdown']}
" css/less/sass/html color preview for vim. https://github.com/gko/vim-coloresque
Plug 'gorodinskiy/vim-coloresque'
" Run Async Shell Commands in Vim 8.0 / NeoVim and Output to Quickfix Window. https://github.com/skywind3000/asyncrun.vim
Plug 'skywind3000/asyncrun.vim'
" Show a diff using Vim its sign column. https://github.com/mhinz/vim-signify
Plug 'mhinz/vim-signify'
" A vim plugin to display the indention levels with thin vertical lines. https://github.com/Yggdroot/indentLine
"Plug 'Yggdroot/indentLine' " not working now
" format json line in Vim. https://github.com/axiaoxin/vim-json-line-format
Plug 'axiaoxin/vim-json-line-format'
" Multiple cursors project for vim/neovim. https://github.com/mg979/vim-visual-multi
Plug 'mg979/vim-visual-multi'
" surround.vim: quoting/parenthesizing made simple. https://github.com/tpope/vim-surround
Plug 'tpope/vim-surround'
" An asynchronous fuzzy finder which is used to quickly locate files, buffers,
" mrus, tags, etc. in large project. https://github.com/Yggdroot/LeaderF
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
" A code-completion engine for Vim. (need macvim) https://github.com/ycm-core/YouCompleteMe
Plug 'ycm-core/YouCompleteMe'
" A Vim plugin that manages your tag files. https://github.com/ludovicchabant/vim-gutentags
Plug 'ludovicchabant/vim-gutentags'
" The right way to use gtags with gutentags. https://github.com/skywind3000/gutentags_plus
Plug 'skywind3000/gutentags_plus'
" Check syntax in Vim asynchronously and fix files, with Language Server
" Protocol (LSP) support. https://github.com/dense-analysis/ale
Plug 'dense-analysis/ale'
" The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips! https://github.com/SirVer/ultisnips
Plug 'SirVer/ultisnips'
" vim-snipmate default snippets (Previously snipmate-snippets) https://github.com/honza/vim-snippets
Plug 'honza/vim-snippets'
" Insert or delete brackets, parens, quotes in pair. https://github.com/jiangmiao/auto-pairs
Plug 'jiangmiao/auto-pairs'
" A calendar application for Vim https://github.com/itchyny/calendar.vim
Plug 'itchyny/calendar.vim'
" Improved nginx vim plugin (incl. syntax highlighting)
Plug 'chr4/nginx.vim'
" Instant Markdown previews from VIm! https://github.com/suan/vim-instant-markdown
Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
" Vim and Neovim plugin to reveal the commit messages under the cursor
Plug 'rhysd/git-messenger.vim'
" Adds file type icons to Vim plugins such as: NERDTree, vim-airline, CtrlP, unite, Denite, lightline, vim-startify and many more
Plug 'ryanoasis/vim-devicons'
" A Vim plugin for previewing sequence diagram in a browser
Plug 'xavierchow/vim-sequence-diagram'
" A vim plugin for adding import statements (for python and more) without LSP
Plug 'wookayin/vim-autoimport'
" https://black.readthedocs.io/en/stable/integrations/editors.html#vim
Plug 'psf/black', { 'branch': 'stable' }
call plug#end()
""""""""""""""""""""""BASE CONFIG"""""""""""""""""""""""
" 设置编码为 utf-8
set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
" 解决 console 输出乱码
language messages zh_CN.utf-8
" 取消备份
set nobackup
set noswapfile
" 状态栏配置
set laststatus=2
" 打开语法高亮
syntax enable
" 开启语法检测
syntax on
" vimrc 文件修改之后自动加载
autocmd! bufwritepost .vimrc source %
" 文件修改之后自动载入
set autoread
" 高亮搜索命中的文本
set hlsearch
" 随着键入即时搜索
set incsearch
" 搜索时忽略大小写
set ignorecase
" 有一个或以上大写字母时仍大小写敏感
set smartcase
set guifont=Menlo:h14
" 在状态栏显示正在输入的命令
set showcmd
" 显示括号配对情况
set showmatch
" :next, :make 命令之前自动保存
set autowrite
" 允许使用鼠标
set mouse=a
" 设置行号
set nu
" 退格键可用
set backspace=2
" 退格键一次删掉 4 个空格
set smarttab
" 缩进
set autoindent
set smartindent
" 保存文件时自动删除行尾空格或 Tab
autocmd BufWritePre * :%s/\s\+$//e
" 保存文件时自动删除末尾空行
autocmd BufWritePre * :%s/^$\n\+\%$//ge
" 保存文件时自动对中文中的英文单词和数字添加空格
" autocmd BufWritePre * silent! :%s/[^\x00-\xff]\zs\ze\w\|\w\zs\ze[^\x00-\xff]/ /g
" 填充 Tab
set expandtab
set tabstop=4
set shiftwidth=4
set shiftround
" 配置 go 文件 tab 显示方式:不填充 tab 但 tab 显示为 4 个空格的长度
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
" 代码折叠 用 za 命令折叠或展开
set foldmethod=indent
" 默认展开
set nofoldenable
" 有 6 种方法来选定折叠:
" 1 manual 手工定义折叠
" 2 indent 更多的缩进表示更高级别的折叠
" 3 expr 用表达式来定义折叠
" 4 syntax 用语法高亮来定义折叠
" 5 diff 对没有更改的文本进行折叠
" 6 marker 对文中的标志折叠
" 突出显示当前行,列
set cursorline
set cursorcolumn
" 设置 退出 vim 后,内容显示在终端屏幕, 可以用于查看和复制
set t_ti= t_te=
" 打开文件时始终跳转到上次光标所在位置
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
" 退出 vim 后,仍然可以 undo 上次编辑
if has('persistent_undo') "check if your vim version supports it
set undofile "turn on the feature
set undodir=$HOME/.vim/undo "directory where the undo files will be stored
endif
"""""""""""""""""""""""""KEY MAPPING""""""""""""""""""""
" j k 移动行的时候光标始终在屏幕中间
nnoremap j jzz
nnoremap k kzz
" 映射切换 buffer 的键位
nnoremap [b :bp<CR>
nnoremap ]b :bn<CR>
" 映射切换 tab 的键位
nnoremap [t :tabp<CR>
nnoremap ]t :tabn<CR>
" normal 模式下 Ctrl+c 全选并复制到系统剪贴板(linux 必须装有 vim-gnome)
nmap <C-c> gg"+yG
" visual 模式下 Ctrl+c 复制选中内容到剪贴板
vmap <C-c> "+y
" Ctrl+v 原样粘贴剪切板内容
inoremap <C-v> <ESC>"+pa
" w!!写入只读文件
cmap w!! w !sudo tee >/dev/null %
" F2 切换行号显示
nnoremap <F2> :set nonu!<CR>:set foldcolumn=0<CR>
" F3 打开目录树
nnoremap <F3> :NERDTreeToggle<CR>
" F4 显示函数 List
nmap <silent> <F4> :Leaderf! function --right<CR>
" F5 运行当前 Python 脚本
if exists("$VIRTUAL_ENV")
autocmd FileType python map <buffer> <F5> :AsyncRun $VIRTUAL_ENV'/bin/python' %:p<CR>
else
autocmd FileType python map <buffer> <F5> :AsyncRun python %:p<CR>
endif
autocmd FileType go map <buffer> <F5> :GoRun<CR>
" <F6> 新建标签页
map <F6> <Esc>:tabnew<CR>
" <F7>
" <F8> ale lint fix
nnoremap <F8> :ALEFix<CR>
" <F9> format json
nnoremap <F9> :%!python -m json.tool<CR>
" <F10> 中文中夹杂的英文和数字添加空格(注意\\| " 在 map 里面需要转义,直接执行使用\|)
nnoremap <F10> :%s/[^\x00-\xff]\zs\ze\w\\|\w\zs\ze[^\x00-\xff]/ /g<CR>
" 给当前单词添加引号
nnoremap w" viw<esc>a"<esc>hbi"<esc>lel
nnoremap w' viw<esc>a'<esc>hbi'<esc>lel
" 大小写转换并自动在前面加 _ (用于 abc`D`ef -> abc_def )
nnoremap <leader>_ i_<esc>l~
" 删除当前字符并对后面的字符进行大小写转换 (用于 abc`_`def -> abcDef )
nnoremap <leader>x x~
" 在 Normal Mode 和 Visual/Select Mode 下,利用 > 键和 < 键来缩进文本
nnoremap > >>
nnoremap < <<
vnoremap > >gv
vnoremap < <gv
" quicker window switching
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" quicker window resize
nnoremap <C-S-Left> <C-w><
nnoremap <C-S-Right> <C-w>>
nnoremap <C-S-Up> <C-w>+
nnoremap <C-S-Down> <C-w>-
" VIM 窗口操作命令:
"
" 左右分割窗口 Ctrl+w +v
" 上下分割窗口 Ctrl+w +s
"
" 关闭窗口 Ctrl+w +q
"
" 光标在所有窗口间按顺序移动 Ctrl+w +w
" 光标移动到左边窗口 Ctrl+w +h
" 光标移动到下面窗口 Ctrl+w +j
" 光标移动到上面窗口 Ctrl+w +k
" 光标移动到右面窗口 Ctrl+w +l
" 光标移动到最左上角的窗口 Ctrl+w +t
" 光标移动到最右下角的窗口 Ctrl+w +b
" 光标移动到上一次访问的窗口 Ctrl+w +p
"
" 交换窗口位置 Ctrl+w +r Ctrl+w +R Ctrl+w +x
"
" 交换窗口位置并还原大小 Ctrl+w +H Ctrl+w +J Ctrl+w +K Ctrl+w +L
"
" 将所有窗口调整到相同大小 Ctrl+w +=
" 将当前窗口最大化 Ctrl+w +|
" 将当前窗口覆盖全部只剩一个窗口 Ctrl+w +T
" close quickfix windows
nnoremap <leader>q :ccl<cr>
autocmd FileType markdown nnoremap <buffer> <leader>p :InstantMarkdownPreview<CR>
autocmd FileType markdown nnoremap <buffer> <leader>q :InstantMarkdownStop<CR>
""""""""""""""""""""""""""""""PLUGIN CONFIG""""""""""""""""""""""""""
" Leaderf
let g:Lf_ShortcutF = "<leader>ff"
nnoremap <leader>fg :Leaderf rg<CR>
nnoremap <leader>fm :LeaderfMru<CR>
" vim-go
let g:go_test_show_name = 1
let g:go_fmt_command="gopls"
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
let g:go_gopls_gofumpt=1
let g:go_highlight_types = 1 " 高亮显示 type 后的名称
let g:go_highlight_fields = 1 " 高亮显示结构体字段
let g:go_highlight_function_calls = 1 " 高亮显示函数名
let g:go_highlight_operators = 1 " 高亮运算符
let g:go_highlight_extra_types = 1 " 高亮其他 types
let g:go_highlight_build_constraints = 1 " 高亮编译标签
" 编译 golang 同时运行测试
" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
autocmd FileType go nmap <leader>gb :<C-u>call <SID>build_go_files()<CR>
" 运行 golang
autocmd FileType go nmap <leader>gr <Plug>(go-run)
" 运行单元测试
autocmd FileType go nmap <leader>gT :GoTest<cr>
" 运行光标处单元测试
autocmd FileType go nmap <leader>gt :GoTestFunc<cr>
" 显示引用
autocmd FileType go nmap <leader>r :GoReferrers<cr>
" 显示接口实现
autocmd FileType go nmap <leader>i :GoImplements<cr>
" 结构体添加 json tag
autocmd FileType go nmap <leader>t :GoAddTags<cr>
" 删除结构体 tag
autocmd FileType go nmap <leader>T :GoRemoveTags<cr>
" 填充结构体字段
autocmd FileType go nmap <leader>fs :GoFillStruct<cr>
" 代码添加 if err
autocmd FileType go inoremap <C-e> <ESC>:GoIfErr<cr>i
" rainbow_parentheses
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" vim-table-mode: markdown
let g:table_mode_corner="|"
" NerdCommenter
let g:NERDSpaceDelims=1
" NERDTREE
" 不显示的文件
let NERDTreeIgnore=['\.pyc$', '\~$']
" 显示隐藏文件
let NERDTreeShowHidden=1
" 删除侧边栏状态栏中的内容不进行展示
" let NERDTreeStatusline="%{matchstr(getline('.'), '\\s\\zs\\w\\(.*\\)')}"
" show nerdtree when starts up
" autocmd vimenter * NERDTree
" 退出最后一个 buff 时也退出 nerdtree
autocmd BufEnter * if 0 == len(filter(range(1, winnr('$')), 'empty(getbufvar(winbufnr(v:val), "&bt"))')) | qa! | endif
" airline
" airline 主题
if !exists('g:airline_theme')
let g:airline_theme = 'random'
endif
" section c 显示完整文件路径
let g:airline_section_c = '%<%F%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
" section y 的时间格式
let g:airline_section_y = '%{strftime("%H:%M")}'
" 开启 tabline
let g:airline#extensions#tabline#enabled = 1
" tabline 中当前 buffer 两端的分隔字符
let g:airline#extensions#tabline#left_sep = ' '
" tabline 中未激活 buffer 两端的分隔字符
let g:airline#extensions#tabline#left_alt_sep = '|'
" tabline 中 buffer 显示编号
let g:airline#extensions#tabline#buffer_nr_show = 1
" tabline 格式: default, jsformatter, unique_tail, unique_tail_improved
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
" https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt
let g:airline_powerline_fonts = 1 " need nerdfont
let g:airline_detect_modified=1
let g:airline_detect_paste=1
let g:airline_detect_crypt=1
let g:airline_detect_spell=1
let g:airline_detect_spelllang=1
let g:airline_detect_iminsert=1
let g:airline_inactive_collapse=1
let g:airline_inactive_alt_sep=1
let g:airline_filetype_overrides = {
\ 'coc-explorer': [ 'CoC Explorer', '' ],
\ 'defx': ['defx', '%{b:defx.paths[0]}'],
\ 'fugitive': ['fugitive', '%{airline#util#wrap(airline#extensions#branch#get_head(),80)}'],
\ 'gundo': [ 'Gundo', '' ],
\ 'help': [ 'Help', '%f' ],
\ 'minibufexpl': [ 'MiniBufExplorer', '' ],
\ 'nerdtree': [ get(g:, 'NERDTreeStatusline', 'NERD'), '' ],
\ 'startify': [ 'startify', '' ],
\ 'vim-plug': [ 'Plugins', '' ],
\ 'vimfiler': [ 'vimfiler', '%{vimfiler#get_status_string()}' ],
\ 'vimshell': ['vimshell','%{vimshell#get_status_string()}'],
\ 'vaffle' : [ 'Vaffle', '%{b:vaffle.dir}' ],
\ }
let g:airline_exclude_preview = 0
let g:airline#extensions#nerdtree_statusline = 1
" AsyncRun
" automatically open quickfix window when AsyncRun command is executed
" set the quickfix window 6 lines height.
let g:asyncrun_open = 6
" ring the bell to notify you job finished
let g:asyncrun_bell = 1
" vim-airline displaying the status of AsyncRun
let g:asyncrun_status = ''
let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
" gtags envvar
let $GTAGSLABEL = 'native-pygments'
let $GTAGSCONF = '/usr/local/share/gtags/gtags.conf'
" gutentags
" 打印日志
"let g:gutentags_trace = 1
" gutentags 搜索工程目录的标志,当前文件路径向上递归直到碰到这些文件/目录名
let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project', 'go.mod', 'requirements.txt']
" 所生成的数据文件的名称
let g:gutentags_ctags_tagfile = '.tags'
" 同时开启 ctags 和 gtags 支持:
let g:gutentags_modules = []
if executable('gtags-cscope') && executable('gtags')
let g:gutentags_modules += ['gtags_cscope']
endif
" 将自动生成的 ctags/gtags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录
let g:gutentags_cache_dir = expand('~/.cache/tags')
" 禁用 gutentags 自动加载 gtags 数据库的行为
let g:gutentags_auto_add_gtags_cscope = 0
" change focus to quickfix window after search (optional).
let g:gutentags_plus_switch = 1
" 配置 ctags 的参数
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']
if executable('ctags')
let g:gutentags_modules += ['ctags']
" 如果使用 universal ctags 需要增加下面一行
let g:gutentags_ctags_extra_args += ['--output-format=e-ctags']
endif
" YouCompleteMe
set completeopt=menu,menuone
" 是否显示函数原型预览窗口
let g:ycm_add_preview_to_completeopt = 0
" 显示诊断信息
let g:ycm_show_diagnostics_ui = 1
let g:ycm_server_log_level = 'info'
let g:ycm_server_keep_logfiles = 1
" 两个字符以后自动弹出的是基于符号的补全
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_complete_in_strings=1
" 触发语义补全
let g:ycm_key_invoke_completion = '<c-z>'
noremap <c-z> <NOP>
" 输入符号的两个字母,即可自动弹出语义补全
let g:ycm_semantic_triggers = {
\ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
\ 'cs,lua,javascript': ['re!\w{2}'],
\ }
" 编辑白名单
let g:ycm_filetype_whitelist = {
\ "c":1,
\ "cpp":1,
\ "go":1,
\ "python":1,
\ "java":1,
\ "javascript":1,
\ "perl":1,
\ "lua":1,
\ "sh":1,
\ "zsh":1,
\ }
autocmd FileType python nmap gd :YcmCompleter GoToDefinitionElseDeclaration<cr>
autocmd FileType python nmap <leader>r :YcmCompleter GoToReferences<cr>
autocmd FileType python nmap <leader>g :YcmCompleter GoTo<cr>
autocmd FileType python nmap <leader>i :ImportSymbol<cr> "光标所在行按 \i 自动import该行缺失的module
"关于设置 YouCompleteMe Python3 语法支持的帮助
"https://github.com/ycm-core/YouCompleteMe/issues/2876
"let g:ycm_server_python_interpreter='/usr/bin/python3'
" ALE
let g:airline#extensions#ale#enabled = 1
let airline#extensions#ale#error_symbol = 'E:'
let airline#extensions#ale#warning_symbol = 'W:'
let airline#extensions#ale#show_line_numbers = 1
let airline#extensions#ale#open_lnum_symbol = '(L'
let airline#extensions#ale#close_lnum_symbol = ')'
let g:ale_linters = {
\ 'python': ['mypy', 'pylint', 'flake8'],
\ 'c': ['gcc', 'cppcheck'],
\ 'cpp': ['gcc', 'cppcheck'],
\ 'go': ['gofmt', 'golint', 'gopls', 'govet'],
\ 'markdown': ['markdownlint'],
\ }
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'go': ['gofmt'],
\ 'python': ['black', 'isort'],
\ 'css': ['prettier'],
\ 'javascript': ['prettier'],
\ 'markdown': ['prettier'],
\ }
let g:ale_python_black_options='--line-length=100'
let g:ale_python_flake8_options = '--max-line-length=100'
let g:ale_fix_on_save = 1
" utilsnips
let g:UltiSnipsExpandTrigger = "<c-e>"
" random-colorscheme-picker
let g:colorscheme_user_path = '~/.vim/plugged/vim-colorschemes/colors'
" change color scheme
nnoremap <leader>c :CSnext<cr>
" vim-instant-markdown
let g:instant_markdown_autostart = 0
let g:instant_markdown_open_to_the_world = 1
let g:instant_markdown_port = 10086