-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
456 lines (405 loc) · 10.2 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
""""""""""""""""""""""""""""""""""""""""""""
" 基本设置
""""""""""""""""""""""""""""""""""""""""""""
if !has('nvim')
syntax on
set nocompatible
set encoding=utf-8
set termencoding=utf-8
set laststatus=2
set autoindent
set autoread
set incsearch
set mouse-=a
endif
if has('nvim')
" 使用easymotion的搜索高亮, 关闭nvim默认的搜索高亮
set nohls
endif
"set hls
set nu
set rnu
set cmdheight=1
set smartindent
set shiftwidth=4
set expandtab
set tabstop=4
set softtabstop=4
set shiftround
set ignorecase
set title
set cursorline
set shortmess=atI
set nowrap
set backspace=indent,eol,start
set maxmempattern=5000
inoremap jk <esc>
autocmd Filetype html setlocal ts=2 sts=2 sw=2
autocmd Filetype javascript setlocal ts=2 sts=2 sw=2
autocmd Filetype vue setlocal ts=2 sts=2 sw=2
autocmd Filetype yaml setlocal ts=2 sts=2 sw=2
" 保存时自动删除行末尾空白
autocmd BufWritePre *.* :%s/\s\+$//e
" 保存时删除末尾空行
autocmd BufWritePre *.* :%s/\($\n\s*\)\+\%$//e
"---------
" 主题设置
"---------
syntax enable
set background=dark
"set t_Co=256
let g:solarized_termcolors=16
colorscheme solarized
"let g:rehash256 = 1
set pastetoggle=<F1>
"++++++++++++++++++++++++++++++++++++++++++++
" 按键映射
"++++++++++++++++++++++++++++++++++++++++++++
"-------
" 引导键
"-------
let mapleader=','
let g:mapleader=','
"-----------
" 关闭方向键
"-----------
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
map Y y$
" Copy selected content to clipboader, only osx
vmap <leader>y :w !pbcopy<CR><CR>
nmap <leader>z <C-Z>
nmap <leader>p <C-P>
" ,/ 关闭搜索高亮
nmap <silent><leader>/ :nohls<CR>
"----------------------
" 在vim中运行Python脚本
"----------------------
" ,r for python3
nmap <leader>r :w !python3<cr>
" f5 for python2
nmap <F5> :w !python2<cr>
" f6 also for python3
nmap <F6> :w !python3<cr>
"------
" vimrc
"------
" ,mc编辑vimrc文件
nmap <leader>mc :vnew ~/.vimrc<cr>
" 重新载入vim配置
nmap <F12> :source ~/.vimrc<cr>
"--------
" session
"--------
" ,ms创建session: Make Session
nmap <leader>ms :mksession! ~/.session.vim<cr>
" ,rs恢复session: Recover Session
nmap <leader>rs :source ~/.session.vim<cr>
"++++++++++++++++++++++++++++++++++++++++++++
" 窗口管理
"++++++++++++++++++++++++++++++++++++++++++++
" 水平切分窗口
nmap <leader>nh :new<cr>
" 垂直切分窗口
nmap <leader>nv :vnew<cr>
"-------------
" 在窗口间切换
"-------------
" ,j 上
nmap <leader>j <C-W>j
" ,k 下
nmap <leader>k <C-W>k
" ,h 左
nmap <leader>h <C-W>h
" ,l 右
nmap <leader>l <C-W>l
"-------------
" 调整窗口位置
"-------------
nmap <leader>L <C-W>L
nmap <leader>K <C-W>K
nmap <leader>J <C-W>J
nmap <leader>H <C-W>H
"-------------
" 改变窗口大小
"-------------
" ,-窗口高度-1
nmap <leader>- <C-W>-
" ,+窗口高度+1
nmap <leader>+ <C-W>+
" ,<窗口宽度-1
nmap <leader>< <C-W><
" ,>窗口宽度+1
nmap <leader>> <C-W>>
" ,_使窗口最高
nmap <leader>_ <C-W>_
" ,=使窗口等宽
nmap <leader>= <C-W>=
"++++++++++++++++++++++++++++++++++++++++++++
" Tab 管理
"++++++++++++++++++++++++++++++++++++++++++++
imap ,t <ESC>:tabnew<CR>
let g:airline#extensions#tabline#buffer_idx_mode = 1
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>- <Plug>AirlineSelectPrevTab
nmap <leader>+ <Plug>AirlineSelectNextTab
"-------------
" 快速保存退出
"-------------
" ,w 快速保存
nmap <leader>w :w<cr>
" ,wa 保存所有窗口
nmap <leader>wa :wall<cr>
" ,q 强制退出当前窗口
nmap <leader>q :q!<cr>
" ,c 快速关闭窗口
nmap <leader>c :close<cr>
" ,wz 保存所有窗口并退出
nmap <leader>wz :wqall<cr>
" ,wo
nmap <leader>wo :only<cr>
"++++++++++++++++++++++++++++++++++++++++++++
" 插件管理
"++++++++++++++++++++++++++++++++++++++++++++
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/nerdcommenter'
Plugin 'majutsushi/tagbar'
Plugin 'SirVer/ultisnips'
"Plugin 'honza/vim-snippets'
Plugin 'Raimondi/delimitMate'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'elzr/vim-json'
Plugin 'vim-scripts/a.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'kien/ctrlp.vim'
Plugin 'mattn/emmet-vim'
Plugin 'easymotion/vim-easymotion'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'tpope/vim-surround'
Plugin 'rking/ag.vim'
Plugin 'tpope/vim-repeat'
Plugin 'kien/rainbow_parentheses.vim'
Plugin 'posva/vim-vue'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'dyng/ctrlsf.vim'
call vundle#end()
filetype plugin indent on
"++++++++++++++++++++++++++++++++++++++++++++
" 插件设置
"++++++++++++++++++++++++++++++++++++++++++++
"--------------
" YouCompleteMe
"--------------
" 不显示Preview
set completeopt=menu
let g:ycm_key_invoke_completion = '<C-o>'
" 不用tab选择, 和UltiSnip冲突
let g:ycm_key_list_select_completion = ['<Down>']
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_min_num_of_chars_for_completion = 1
let g:ycm_confirm_extra_conf = 0
let g:ycm_global_ycm_extra_conf = '~/ycm_extra_conf.py'
let g:ycm_filetype_blacklist = {
\ 'nerdtree' : 1,
\ 'tagbar' : 1,
\ 'gitcommit' : 1,
\}
let g:ycm_complete_in_comments = 1 "在注释输入中也能补全
let g:ycm_complete_in_strings = 1 "在字符串输入中也能补全
let g:ycm_goto_buffer_command = 'vertical-split'
nnoremap <leader>jd :YcmCompleter GoTo<CR>
"----------
" Syntastic
"----------
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
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
let g:syntastic_python_python_exec = '/usr/bin/python'
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_c_checkers = ['splint']
let g:syntastic_html_checkers = []
let g:syntastic_python_flake8_args = '"--ignore=E501,E265,E126,E241,F403,E402,E225,E712"'
" 关闭错误显示窗口
nmap <leader>xx :lclose<cr>
"---------
" NERDTree
"---------
nmap <leader>f :NERDTreeToggle<cr>
let NERDTreeIgnore=[
\ '^venv$',
\ '^env$',
\ '^ENV$',
\ '^__pycache__$',
\ '^.cache$',
\ '\.pyc$',
\ '\.pyo$',
\ '\.obj$',
\ '\.o$',
\ '\.so$',
\ '\.out$',
\ '\.egg$',
\ '\.swp$',
\ '^\.git$',
\ '^\.svn$',
\ '^\.hg$',
\ '^\.pytest_cache$',
\ '^node_modules$',
\ '\.vendor$'
\]
" 显示隐藏文件
let NERDTreeShowHidden = 1
let NERDTreeMinimalUI = 1
let NERDTreeAutoDeleteBuffer = 1
let g:NERDTreeGitStatusIndicatorMapCustom= {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
"-------
" Tagbar
"-------
nmap <leader>g :TagbarToggle<cr>
" 不显示help信息
let g:tagbar_compact = 1
let g:tagbar_width = 32
let g:tagbar_autoshowtag = 0
"----------
" UltiSnips
"----------
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
let g:UltiSnipsSnippetDirectories = ['UltiSnips', 'Snippets']
" 编辑当前文件的snippets
map <leader>us :UltiSnipsEdit<CR>
" 水平打开snippets编辑窗口
let g:UltiSnipsEditSplit = 'vertical'
"------
" a.vim
"------
" ,a来回切换.h与.c文件
nmap <leader>a :A<cr>
"----------
" gitgutter
"----------
" 修改标识设为*
let g:gitgutter_sign_modified = '*'
"------
" CtrlP
"------
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.idea/*,*/.DS_Store,*/vendor
" 显示dotfiles
let g:ctrlp_show_hidden = 1
" 忽略
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]env|venv|\.(git|hg|svn)|node_modules|\.vendor$',
\ 'file': '\v\.(exe|so|dll|pyc|pyo|swp|o)$',
\ }
"------
" emmet
"------
let g:user_emmet_install_global = 0
autocmd FileType html,css EmmetInstall
let g:user_emmet_mode='i'
"let g:user_emmet_leader_key='<C-A>'
"-----------
" easymotion
"-----------
map ; <Plug>(easymotion-prefix)
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
hi EasyMotionTarget2First ctermbg=none ctermfg=darkblue
"-------------
" vim markdown
"-------------
let g:vim_markdown_folding_disabled = 1
"-------
" Ag.vim
" CtrlSF.vim
"-------
nmap <leader>s :CtrlSF
" 从项目目录开始搜索
let g:ag_working_path_mode='r'
vmap <leader>w <Plug>CtrlSFVwordExec
" -------
" airline
" -------
let g:airline_theme = 'solarized'
let g:airline#extensions#tabline#enabled = 1
" ------------------
" rainbow parerheses
" ------------------
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
let g:solarized_termtrans=1
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
"++++++++++++++++++++++++++++++++++++++++++++
" Gvim设置
"++++++++++++++++++++++++++++++++++++++++++++
if has("gui_running")
set guifont="Monospace":h12
" 关闭工具栏, 滚动条等
set guioptions-=T
set guioptions-=e
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
set guioptions-=m
set t_Co=256
" 最大化打开
set lines=999
set columns=999
endif