- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
Latest commit
421 lines (355 loc) · 11 KB
/
Copy pathvimrc
File metadata and controls
421 lines (355 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
setnocompatible
setupdatetime=300
setautoread
setencoding=utf-8
settermencoding=utf-8
setfileencodings=utf-8,gb2312,gbk,gb18030
settabpagemax=10
setsigncolumn=yes
filetypeoff
" vim-plug
callplug#begin('~/.vim/plugged')
Plug 'altercation/vim-colors-solarized'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'mileszs/ack.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-fugitive'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'derekwyatt/vim-fswitch'
Plug 'kshenoy/vim-signature'
Plug 'vim-scripts/BOOKMARKS--Mark-and-Highlight-Full-Lines'
Plug 'dyng/ctrlsf.vim'
Plug 'Yggdroot/LeaderF',{'do':':LeaderfInstallCExtension'}
Plug 'scrooloose/nerdcommenter'
Plug 'vim-scripts/DrawIt'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'derekwyatt/vim-protodef'
Plug 'scrooloose/nerdtree'
"Plug 'fholgado/minibufexpl.vim'
Plug 'gcmt/wildfire.vim'
Plug 'sjl/gundo.vim'
Plug 'Lokaltog/vim-easymotion'
Plug 'suan/vim-instant-markdown'
Plug 'Yggdroot/indentLine'
" Plug 'dense-analysis/ale'
Plug 'Chiel92/vim-autoformat'
Plug 'heavenshell/vim-pydocstring'
Plug 'mhinz/vim-signify'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'yaegassy/coc-pylsp', {'do': 'yarn install --frozen-lockfile'}
callplug#end()
" map <leader> key
let mapleader=";"
" load corresponding plugins based on different types detected
"code smart indent
filetypepluginindenton
syntaxon
setbackground=dark
colorscheme monokai
"colorscheme solarized
sett_Co=256
setnoshowmode
setnoainosi
setpastetoggle=<F3>
" enable mouse
setmouse=r
setselection=exclusive
setselectmode=mouse,key
" show line number
setnumber
setautoindent
setsmartindent
" disable wrap
setnowrap
" show cursor location
setruler
" show status bar
setlaststatus=2
" highlight current line
setcursorline
setcursorcolumn
" split window on right pane
setsplitright
setsplitbelow
settextwidth=79
setcolorcolumn=+1
setshowcmd
setincsearch
sethlsearch
nnoremap<leader>h :noh<cr>
setignorecase
" display question
set conceallevel=0
" auto reload on file modify by outter application
setautoread
" config virtualedit
setvirtualedit=onemore,block,insert
" how many lines under cursor
noremapjjzz
noremapkkzz
noremapnnzz
noremap<s-n><s-n>zz
noremap**zz
noremap##zz
noremap<c-o><c-o>zz
noremap<c-i><c-i>zz
" status bar style
letg:powerline_colorscheme='solarized256'
setnowrap
noremap<leader>c <Esc>
inoremap<c-c><Esc>
inoremapjk<Esc>
" make configuration changes take effect immediately
autocmdBufWritePost$MYVIMRCsource$MYVIMRC
" vim cmd autocomplete
setwildmenu
" show tab
setlistchars=tab:>-,trail:-
" paste from system clipboard
noremap<leader>p "+p
"copy to system clipboard
noremap<leader>y "+y
nnoremap<leader>w :w<cr>
inoremap<leader>w <Esc>:w<cr>
vnoremap<leader>w <Esc>:w<cr>
nnoremap<leader>q :q<cr>
inoremap<leader>q <Esc>:wq<cr>
" save read only file
nnoremap<leader>x :w !sudo tee %<cr>
inoremap<leader>x <Esc>:w !sudo tee %<cr>
vnoremap<leader>x <Esc>:w !sudo tee %<cr>
vnoremap<leader>g <c-g>
" enable insert model backspace not working
setbackspace=2
setexpandtab
settabstop=4
setshiftwidth=4
setsofttabstop=4
" autocmd BufNewFile,BufRead *.py set shiftwidth=4
" autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
" code fold method
setfoldmethod=syntax
setnofoldenable
noremapzkza
" edit config
" move line to up
noremap<c-k>ddkP
" move linte to down
noremap<c-j>ddp
" insert blank line below
" nnoremap <silent><c-l> :set paste<cr>m`o<esc>``:set nopaste<cr>
" insert blank line above
" nnoremap <silent><s-l> :set paste<cr>m`O<esc>``:set nopaste<cr>
" buffer switch
nnoremapBn:bn<cr>
nnoremapBp:bp<cr>
nnoremapBr:br<cr>
nnoremapBl:bl<cr>
nnoremapB1:bfirst<cr>
nnoremapB2:bfirst<cr>:1bn<cr>
nnoremapB3:bfirst<cr>:2bn<cr>
nnoremapB4:bfirst<cr>:3bn<cr>
nnoremapB5:bfirst<cr>:4bn<cr>
nnoremapB6:bfirst<cr>:5bn<cr>
nnoremapB7:bfirst<cr>:6bn<cr>
nnoremapB8:bfirst<cr>:7bn<cr>
nnoremapB9:bfirst<cr>:8bn<cr>
nnoremapBd:bd<cr>:bn<cr>
" 使用 NERDTree 插件查看工程文件。设置快捷键,速记:file list
nmap<Leader>b :NERDTreeToggle %<cr>
nmap<F6>:NERDTreeToggle %<cr>
" 设置NERDTree子窗口宽度"
let NERDTreeWinSize=32
" 设置NERDTree子窗口位置
let NERDTreeWinPos="left"
" 显示隐藏文件
let NERDTreeShowHidden=1
" NERDTree 子窗口中不显示冗余帮助信息
let NERDTreeMinimalUI=1
" 删除文件时自动删除文件对应 buffer
let NERDTreeAutoDeleteBuffer=1
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$','\.pyc','\.swp','^__pycache__$','^\.git$']
let NERDTreeShowBookmarks=1
let NERDChristmasTree=0
autocmdStdinReadPre*lets:std_in=1
autocmdVimEnter*ifargc() ==0&&!exists("s:std_in") | NERDTree | endif
letg:plug_window='noautocmd vertical topleft new'
" nerdcommenter config
letg:NERDSpaceDelims=1
letg:NERDCompactSexyComs=1
letg:NERDDefaultAlign='left'
letg:NERDToggleCheckAllLines=1
" indentline
letg:indentLine_enabled=1
" Vim
letg:indentLine_color_term=102
letg:indentLine_bgcolor_term=235
letg:indentLine_char='¦'
letg:indentLine_first_char='|'
letg:indentLine_showFirstIndentLevel=0
" GVim
letg:indentLine_color_gui='#A4E57E'
letg:indentLine_bgcolor_gui='#262626'
" none X terminal
letg:indentLine_color_tty_light=7" (default: 4)
letg:indentLine_color_dark=1" (default: 2)
" autoformat
noremap<Leader>r :Autoformat<cr>
letg:formatter_yapf_style='google'
letg:formatdef_yapf="'yapf --style=\"{based_on_style:'.g:formatter_yapf_style.',indent_width:4}\" -l '.a:firstline.'-'.a:lastline"
letg:formatters_python= ['yapf']
letg:autoformat_autoindent=0
letg:autoformat_retab=0
letg:autoformat_remove_trailing_spaces=1
" python3 syntax
letg:python_highlight_all=1
" ale for python3
letg:ale_set_highlights=0
"自定义error和warning图标
letg:ale_sign_error='✗'
letg:ale_sign_warning='⚡'
""在vim自带的状态栏中整合ale
letg:ale_statusline_format= ['✗ %d', '⚡ %d', '✔ OK']
"显示Linter名称,出错或警告等相关信息
letg:ale_echo_msg_error_str='E'
letg:ale_echo_msg_warning_str='W'
letg:ale_echo_msg_format='[%linter%] %s [%severity%]'
""打开文件时进行检查
letg:ale_lint_on_enter=1
" 只在光标所在的行才显示virtualtext
letg:ale_virtualtext_cursor=1
" 普通模式下,sp前往上一个错误或警告,sn前往下一个错误或警告
nmapsp<Plug>(ale_previous_wrap)
nmapsn<Plug>(ale_next_wrap)
" <Leader>s触发/关闭语法检查
nmap<Leader>s :ALEToggle<cr>
" <Leader>d查看错误或警告的详细信息
nmap<Leader>d :ALEDetail<cr>
" 使用clang对c和c++进行语法检查,对python使用pylint进行语法检查
letg:ale_linters= {
\ 'c': ['clang'],
\ 'c++': ['clang'],
\ 'python': ['pylint'],
\}
" UltiSnips 的 tab 键与 YCM 冲突,重新设定
letg:UltiSnipsExpandTrigger="<leader><tab>"
letg:UltiSnipsJumpForwardTrigger="<c-j>"
letg:UltiSnipsJumpBackwardTrigger="<c-k>"
letg:UltiSnipsSnippetDirectories=['~/.vim/snippets/', 'UltiSnips']
" coc config
" 确保 coc.nvim 的片段跳转键与 UltiSnips 一致
letg:coc_global_extensions= ['coc-snippets']
letg:coc_snippet_next='<c-j>'
letg:coc_snippet_prev='<c-k>'
imap<c-j><Plug>(coc-snippets-expand-jump)
vmap<c-j><Plug>(coc-snippets-select)
imap<c-k><Plug>(coc-snippets-expand)
"
inoremap<silent><expr><TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap<expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
noremap<silent><expr><CR>
\ coc#pum#visible() ? coc#pum#confirm():
\ "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function!CheckBackspace() abort
letcol=col('.') -1
return!col||getline('.')[col-1] =~# '\s'
endfunction
inoremap<silent><expr><c-@> coc#refresh()
" GoTo code navigation
nmap<silent>gk<Plug>(coc-definition)
nmap<silent>gy<Plug>(coc-type-definition)
nmap<silent>gi<Plug>(coc-implementation)
nmap<silent>gr<Plug>(coc-references)
nmap<silent>gm<Plug>(coc-rename)
function!ShowDocumentation()
ifCocAction('hasProvider', 'hover')
callCocActionAsync('doHover')
else
callfeedkeys('K', 'in')
endif
endfunction
" Use K to show documentation in preview window
noremap<silent>K:call ShowDocumentation()<CR>
" Highlight the symbol and its references when holding the cursor
" autocmd CursorHold * silent call CocActionAsync('highlight')
autocmdCursorHold* :redraw!
" Symbol renaming
" airline config
letg:airline_theme="molokai"
letg:airline_powerline_fonts=1
letg:airline#extensions#whitespace#enabled =1
letg:airline#extensions#whitespace#symbol =''
letg:airline#extensions#tabline#enabled =1
letg:airline#extensions#tabline#buffer_nr_show =1
letg:airline#extensions#tabline#left_sep =''
letg:airline#extensions#tabline#left_alt_sep ='|'
letg:airline#extensions#tabline#buffer_idx_mode =1
if!exists('g:airline_symbols')
letg:airline_symbols= {}
endif
letg:airline_left_sep='|'
letg:airline_left_alt_sep='|'
letg:airline_right_sep='|'
letg:airline_right_alt_sep='|'
letg:airline_symbols.branch ='Y'
letg:airline_symbols.paste='P'
letg:airline_symbols.readonly='🔒'
letg:airline_symbols.colnr ='C:'
letg:airline_symbols.linenr='L'
letg:airline_symbols.maxlinenr =''
letg:airline_symbols.dirty='!'
letg:airline_symbols.whitespace=''
letg:airline_symbols.crypt ='🔒'
letg:airline_symbols.spell='Ꞩ'
letg:airline_symbols.notexists ='?'
nmap<leader>1 <plug>Airlineselecttab1
nmap<leader>2 <plug>Airlineselecttab2
nmap<leader>3 <Plug>AirlineSelectTab3
nmap<leader>4 <Plug>AirlineSelectTab4
nmap<leader>5 <Plug>AirlineSelectTab5
nmap<leader>6 <Plug>AirlineSelectTab6
nmap<leader>7 <Plug>AirlineSelectTab7
nmap<leader>8 <Plug>AirlineSelectTab8
nmap<leader>9 <Plug>AirlineSelectTab9
nmap<leader>p <Plug>AirlineSelectPrevTab
nmap<leader>n <Plug>AirlineSelectNextTab
nmap<leader>= :tabnew<cr>
nmap<leader>- :tabclose<cr>
" gundo config
letg:gundo_prefer_python3=1
nmap<Leader>o :GundoToggle<cr>
" pydoctring config
letg:pydocstring_doq_path='/usr/local/bin/doq'
letg:pydocstring_formatter='numpy'
nmap<silent><C-H>d<Plug>(pydocstring)
" config persistentr undo
ifhas('persistent_undo')" check if vim support it
setundofile" turn on persistentr undo feature
setundodir=$HOME/.vim/undo" directory where undo file will be stored
endif
" ack config
" 使用 leader + a search
cnoreabbrev Ack Ack!
nnoremap<leader>a :Ack!<Space>
ifexecutable('rg')
letg:ackprg='rg --vimgrep --type-not sql --smart-case'
endif
" 高亮搜索关键词
letg:ackhighlight=1
" Auto close the Quickfix list after pressing '<enter>' on a list item
letg:ack_autoclose=1
" Any empty ack search will search for the work the cursor is on
letg:ack_use_cword_for_empty_search=1
" vim-signify config
letg:signify_vcs_list= ['git']
iffilereadable("custom.vim")
socustom.vim
endif