forked from qiyan2019/vimrc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
561 lines (455 loc) · 15.6 KB
/
vimrc
File metadata and controls
561 lines (455 loc) · 15.6 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
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
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/vim-plug
call plug#begin('~/.vim/bundle')
Plug 'frtmelody/vim-plug'
Plug 'gmarik/Vundle.vim'
Plug 'a.vim'
Plug 'DoxygenToolkit.vim'
Plug 'tomasr/molokai'
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
""plugin
Plug 'auto_mkdir'
Plug 'TagHighlight'
Plug 'auto-pairs'
Plug 'cuteErrorMarker'
Plug 'easymotion/vim-easymotion'
Plug 'tpope/vim-repeat'
Plug 'indent-motion'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'OmniCppComplete'
Plug 'vim-airline'
Plug 'surround.vim'
Plug 'majutsushi/tagbar'
Plug 'tlib'
Plug 'indentLine.vim'
Plug 'project.tar.gz'
Plug 'Pydiction'
Plug 'fatih/vim-go'
Plug 'L9'
Plug 'FuzzyFinder'
Plug 'vim-orgmode'
Plug 'speeddating.vim'
Plug 'dantezhu/authorinfo'
Plug 'Valloric/YouCompleteMe'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'plasticboy/vim-markdown'
Plug 'scrooloose/syntastic'
Plug 'frtmelody/vim-autoformat'
Plug 'kien/rainbow_parentheses.vim'
Plug 'junegunn/vim-easy-align'
Plug 'bronson/vim-trailing-whitespace'
Plug 'vim-scripts/matchit.zip'
"Git
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
"cloorcheme
Plug 'flazz/vim-colorschemes'
" 等号对齐
Plug 'godlygeek/tabular'
"ctrlp
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tacahiroy/ctrlp-funky'
"ack, dash
Plug 'mileszs/ack.vim'
Plug 'rizzatti/dash.vim'
" c++ 代码生成
Plug 'derekwyatt/vim-protodef'
Plug 'derekwyatt/vim-fswitch'
" vim 终端
Plug 'frtmelody/conque'
"快速选中结对
Plug 'gcmt/wildfire.vim'
" undo
Plug 'sjl/gundo.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'ivanov/vim-ipython'
call plug#end()
" General Settings
set laststatus=2 " Always show the statusline
set showcmd
set cmdheight=1
set nocompatible " not compatible with the old-fashion vi mode
set bs=2 " allow backspacing over everything in insert mode
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set autoread " auto read when file is changed from outside
set nu
set mouse=h
set title
set magic
set cc=80
set titleold = "
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
au BufEnter /usr/include/c++/* setf cpp
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "<cr>"
else
execute "normal /" . l:pattern . "<cr>"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
if exists('$TMUX')
set term=screen-256color
endif
"使用粘贴的时候 禁止缩进
function! WrapForTmux(s)
if !exists('$TMUX')
return a:s
endif
let tmux_start = "\<Esc>Ptmux;"
let tmux_end = "\<Esc>\\"
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end
endfunction
let &t_SI .= WrapForTmux("\<Esc>[?2004h")
let &t_EI .= WrapForTmux("\<Esc>[?2004l")
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
" auto reload vimrc when editing it
autocmd! bufwritepost .vimrc source ~/.vimrc
syntax enable
syntax on " syntax highlight
set hlsearch " search highlighting
"nm<Space> i<space><Esc>l
set background=dark
set t_Co=256
"let g:solarized_termcolors=256
"colorscheme solarized
colorscheme molokai
let g:rehash256 = 1
let g:molokai_original = 1
"let g:airline_section_b = '%{strftime("%d")}'
"let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts=1
let g:airline_enable_branch= 1
"let g:airline_theme= "solarized"
let g:airline_enable_syntastic=1
let g:airline_detect_paste= 1
""" powerline symbols
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = '¶'
""""let g:airline_left_sep = 'ρ'
"let g:airline_right_sep = '«'
let g:airline_right_sep = 'Þ'
"let g:airline_symbols.linenr = '␊'
"""let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
"""let g:airline_symbols.branch = '⎇'
"let g:airline_symbols.paste = 'ρ'
""let g:airline_symbols.paste = 'Þ'
""let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
set cursorline " highlight current line
set guioptions-=T
"set clipboard=unnamed " yank to the system register (*) by default
set showmatch " Cursor shows matching ) and }
set showmode " Show current mode
set wildchar=<TAB> " start wild expansion in the command line using <TAB>
set wildmenu " wild char completion menu
" ignore these files while expanding wild chars
set wildignore=*.o,*.class,*.pyc
set autoindent " auto indentation
set incsearch " incremental search
set nobackup " no *~ backup files
set copyindent " copy the previous indentation on autoindenting
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to context
" disable sound on errors
set noerrorbells
set novisualbell
set vb t_vb=
set tm=500
" TAB setting{
set expandtab "replace <TAB> with spaces
set softtabstop=4
set shiftwidth=4
au FileType Makefile set noexpandtab
" C/C++ specific settings
autocmd FileType c,cpp,cc,h set cindent comments=sr:/*,mb:*,el:*/,:// cino=>s,e0,n0,f0,{0,}0,^0,:s,=s,g0,h1s,ps,t0,+s,(0,ms,)20,*30
"Restore cursor to file position in previous editing session
set viminfo='10,\"100,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
"---------------------------------------------------------------------------
" Tip #382: Search for <cword> and replace with input() in all open buffers
"---------------------------------------------------------------------------
fun! Replace(confirm)
let s:word = input("Replace " . expand('<cword>') . " with:")
if a:confirm
:exe 'argdo! %s/\<' . expand('<cword>') . '\>/' . s:word . '/gec'
else
:exe 'argdo! %s/\<' . expand('<cword>') . '\>/' . s:word . '/ge'
endif
:unlet! s:word
endfun
set wmw=0 " set the min width of a window to 0 so we can maximize others
set wmh=0 " set the min height of a window to 0 so we can maximize others
" Enable omni completion. (Ctrl-X Ctrl-O)
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType java set omnifunc=javacomplete#Complete
"---------------------------------------------------------------------------
" ENCODING SETTINGS
"---------------------------------------------------------------------------
set encoding=utf-8
set termencoding=utf-8
set fileencodings=utf-8,gbk,ucs-bom,cp936
" --- EasyMotion
"let g:EasyMotion_leader_key = '<Leader>m' " default is <Leader>w
hi link EasyMotionTarget ErrorMsg
hi link EasyMotionShade Comment
" --- TagBar
" toggle TagBar with F7
let NERDTreeQuitOnOpen = 0
let g:tagbar_width = 25
" set focus to TagBar when opening it
let g:tagbar_autofocus = 0
set path+=/usr/local/include
set path+=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include
set path+=/usr/include
set path+=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7
set path+=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux
set path+=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward
set path+=/usr/local/include
set path+=/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include
set path+=/usr/include
set path+=~/svn/include
"
"OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD", "string", "vector", "map"]
let OmniCpp_SelectFirstItem = 2
set completeopt=menuone,menu,longest,preview
"indentline
let g:indentLine_color_term = 239
let g:indentLine_color_gui = '#A4E57E'
let g:indentLine_color_dark = 1
let g:indentLine_char = '¦'
set cursorcolumn
highlight Pmenu guibg=darkgrey guifg=black
highlight PmenuSel guibg=lightgrey guifg=black
"author info
let g:vimrc_author='Ruichao Liu'
let g:vimrc_homepage='http://www.meelive.cn'
"doxygen setting
let s:licenseTag = "Copyright(C)\<enter>"
let s:licenseTag = s:licenseTag . "For free\<enter>"
let s:licenseTag = s:licenseTag . "All right reserved\<enter>"
let g:DoxygenToolkit_licenseTag = s:licenseTag
let g:DoxygenToolkit_briefTag_funcName="yes"
let g:doxygen_enhanced_color=1
"pydict"
let g:pydiction_location='~/.vim/bundle/Pydiction/complete-dict'
"snipmate
let g:UltiSnipsExpandTrigger="<c-k>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
"ycm config
let g:ycm_global_ycm_extra_conf = '~/.vim/ycm_extra_conf.py'
let g:ycm_confirm_extra_conf = 0
let g:ycm_filepath_completion_use_working_dir = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_echo_current_diagnostic = 1
let g:ycm_complete_in_strings = 1
let g:ycm_use_ultisnips_completer = 1
"let g:ycm_key_list_select_completion = ['<S-TAB>', '<Down>']
"let g:ycm_key_list_previous_completion = ['<C-S-TAB>', '<Up>']
"let g:SuperTabDefaultCompletionType = '<S-Tab>'
"
"markdown"
let g:vim_markdown_folding_disabled=1
"seystatistic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
"let g:syntastic_auto_jump = 1
"
let g:autoformat_autoindent = 0
"easymotione
let g:EasyMotion_startofline = 0 " keep cursor column when JK motion
let g:EasyMotion_do_mapping = 0 " Disable default mappings
let g:EasyMotion_smartcase = 1
"auto formater
au BufWritePre * :Autoformat
au BufWritePost * :SyntasticCheck
let g:formatters_c = ['astyle_c']
let g:formatdef_astyle_c = '"astyle --mode=c -A2 -f -S -p -k1 -v -U -H -N -M -w -L -s4 -o"'
let g:formatters_cpp = ['astyle_cpp']
let g:formatdef_astyle_cpp = '"astyle --mode=c -A2 -f -S -p -k1 -v -U -H -N -M -w -L -s4 -o"'
"let g:formatdef_autopep8 = '"autopep8 --aggressive --aggressive -"'
let g:syntastic_python_checkers = ['flake8']
"golang
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
"ctrlp
let g:ctrlp_funky_syntax_highlight = 1
let g:ctrlp_working_path_mode = 'ra'
" synatistic
"let g:syntastic_error_symbol = '✗'
let g:syntastic_error_symbol = '➜'
let g:syntastic_warning_symbol = '⚠'
"
"---------------------------------------------------------------------------
" USEFUL SHORTCUTS
"---------------------------------------------------------------------------
" set leader to ,
let mapleader=","
let g:mapleader=","
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
map gf :IHV<cr>
"replace the current word in all opened buffers
map <leader>s :call Replace(0)<CR>
map <leader>r :call Replace(1)<CR>
"surround
"ds
"cs
"ys$" 当前到行尾, 引号引住"
map <leader>e ysiw
" open the error console
map <leader>ec :botright cope<CR>
" move to next error
map <leader>] :cn<CR>
" move to the prev error
map <leader>[ :cp<CR>
" --- move around splits {
" move to and maximize the below split
map <C-j> <ESC><C-w>j
map <C-k> <ESC><C-w>k
map <C-h> <ESC><C-w>h
map <C-l> <ESC><C-w>l
" go to prev tab
map <S-H> gT
" go to next tab
map <S-L> gt
" new tab
map <C-t><C-t> :tabnew<CR>
" close tab
map <C-t><C-w> :tabclose<CR>
" ,/ turn off search highlighting
nmap <leader>/ :nohl<CR>
" allow multiple indentation/deindentation in visual mode
vnoremap < <gv
vnoremap > >gv
map <leader>g :call IncludeGuard()<CR>
fun! IncludeGuard()
let basename = substitute(bufname(""), '.*/', '', '')
let guard = '_' . substitute(toupper(basename), '\.', '_', "H")
call append(0, "#ifndef " . guard)
call append(1, "#define " . guard)
call append( line("$"), "#endif // for #ifndef " . guard)
endfun
"tagbar
nnoremap <silent> <F7> :TagbarToggle<CR>
nnoremap <silent> <leader>tt :TagbarToggle<CR>
nnoremap <silent> <F8> :NERDTreeToggle<CR>
nnoremap <silent> <leader>tn :NERDTreeToggle<CR>
"ctags
map <F10> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ .<CR>
"add author info
nmap <C-u> :AuthorInfoDetect<cr>
"add doc
nmap <F3> :Dox <cr>
nmap <F2> :ConqueTermVSplit
"goto here
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
nmap s <Plug>(easymotion-s)
map <Leader>l <Plug>(easymotion-lineforward)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>h <Plug>(easymotion-linebackward)
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
"map n <Plug>(easymotion-next)
"map N <Plug>(easymotion-prev)
" git fugitive
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>gl :Glog<CR>
nnoremap <silent> <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
" Mnemonic _i_nteractive
nnoremap <silent> <leader>gi :Git add -p %<CR>
nnoremap <silent> <leader>gt :SignifyToggle<CR>
"tabularize
vmap <Leader>a& :Tabularize /&<CR>
nmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
vmap <Leader>a= :Tabularize /^[^=]*\zs=<CR>
nmap <Leader>a=> :Tabularize /=><CR>
vmap <Leader>a=> :Tabularize /=><CR>
nmap <Leader>a: :Tabularize /:<CR>
vmap <Leader>a: :Tabularize /:<CR>
nmap <Leader>a:: :Tabularize /:\zs<CR>
vmap <Leader>a:: :Tabularize /:\zs<CR>
nmap <Leader>a, :Tabularize /,<CR>
vmap <Leader>a, :Tabularize /,<CR>
nmap <Leader>a,, :Tabularize /,\zs<CR>
vmap <Leader>a,, :Tabularize /,\zs<CR>
nmap <Leader>a<Bar> :Tabularize /<Bar><CR>
vmap <Leader>a<Bar> :Tabularize /<Bar><CR>
" This selects the next closest text object.
map <SPACE> <Plug>(wildfire-fuel)
" This selects the previous closest text object.
vmap <C-SPACE> <Plug>(wildfire-water)
nnoremap <Leader>u :GundoToggle<CR>
"彩色括弧
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
"ipython support
"reselect = False " reselect lines after sending from Visual mode
"show_execution_count = True " wait to get numbers for In[43]: feedback?
"monitor_subchannel = True " update vim-ipython 'shell' on every send?
"run_flags= "-i" " flags to for IPython's run magic when using <F5>