-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathvimrc.plugins
535 lines (469 loc) · 18.7 KB
/
vimrc.plugins
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
call plug#begin('~/.vim/plugins')
if filereadable(expand("~/.vimrc.plugins.before"))
source ~/.vimrc.plugins.before
endif
if !exists('g:dotvim_groups')
" more options: ['explorer', 'motion', 'writing', 'git', 'tmux', 'html', 'css', 'js', 'php', 'markdown', 'nginx', 'nfo', 'fcitx', 'matchtag', 'snippets', 'youcompleteme']
let g:dotvim_groups = []
endif
"" core themes
if !count(g:dotvim_groups, '-themes')
Plug 'tomasr/molokai'
"If you prefer the scheme to match the original monokai background color
let g:molokai_original = 1
Plug 'altercation/vim-colors-solarized'
let g:solarized_termcolors = 256
let g:solarized_italic = 1
Plug 'morhetz/gruvbox'
let g:gruvbox_italic = 1
Plug 'junegunn/seoul256.vim'
" seoul256 (dark):
" Range: 233 (darkest) ~ 239 (lightest)
" Default: 237
" seoul256 (light):
" Range: 252 (darkest) ~ 256 (lightest)
" Default: 253
Plug 'zeis/vim-kolor'
endif
if !count(g:dotvim_groups, '-interface')
" ==> vim-airline
Plug 'vim-airline/vim-airline'
" set airline to use powerline symbols
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
" let g:airline#extensions#tabline#fnamemod = ':t'
" 命令行(在状态行下)的高度,默认为1(不显示状态栏),这里是2
set laststatus=2
" ==> User Interface support
Plug 'Yggdroot/indentLine'
let g:indentLine_char = '¦'
let g:indentLine_color_term = 237
" background will auto set to light when some condition
" so force color_term to 239
" if &background ==# "light"
" let g:indentLine_color_term = 249
" else
" let g:indentLine_color_term = 239
" endif
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-explorer'))
\ || count(g:dotvim_groups, 'explorer')
Plug 'schickling/vim-bufonly'
nnoremap <Leader>bK :Bufonly<CR>
" ==> 快速文件搜索, 类似于sublime中的command + p
" Plug 'kien/ctrlp.vim'
Plug 'ctrlpvim/ctrlp.vim'
nnoremap <Leader>pf :CtrlP<CR>
nnoremap <Leader>bb :CtrlPBuffer<CR>
" create new file in current window
let g:ctrlp_open_new_file = 'r'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|rvm)$',
\ 'file': '\v\.(exe|so|dll|zip|tar|tar.gz|pyc)$',
\ }
if executable('ag')
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
let s:ctrlp_fallback = 'ag %s -i -l --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore node_modules
\ --ignore bower_components
\ --ignore "**/*.pyc"
\ -g ""'
elseif executable('ack-grep')
let s:ctrlp_fallback = 'ack-grep %s --nocolor -f'
elseif executable('ack')
let g:ctrlp_use_caching = 0
let s:ctrlp_fallback = 'ack %s --nocolor -f'
else
let s:ctrlp_fallback = 'find %s -type f'
endif
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ },
\ 'fallback': s:ctrlp_fallback
\ }
" <cr> Open the selected file in the 'current' window if possible.
" <c-v> Open the selected file in a 'vertical' split.
" <c-x>, <c-cr>, <c-s> Open the selected file in a 'horizontal' split.
" <c-y> Create a new file and its parent directories.
Plug 'tacahiroy/ctrlp-funky'
" search/symbol jump
nnoremap <Leader>sj :CtrlPFunky<CR>
Plug 'scrooloose/nerdtree'
let NERDTreeIgnore = ['\.DS_Store$', '\.git$', '\~$']
let NERDTreeShowHidden = 1
let NERDTreeShowLineNumbers = 1
nmap <leader>ft :NERDTreeToggle<CR>
nmap <leader>ff :NERDTreeFind<CR>
" o.......打开文件目录或书签
" t.......在新的tab页中打开文件或书签
" i.......在split window中打开选择的文件
" s.......在vsplit window中打开选择的文件
" O.......Recursively open the selected directory
" x.......Close the current nodes parent
" X.......Recursively close all children of the current node
" e.......Edit the current dir
" D.......删除当前书签
" P.......返回根节点
" p.......返回当前节点父节点
" C.......进入相应目录
" u.......返回上一级目录
" cd......Change the CWD to the dir of the selected node
" CD......Change tree root to the CWD
" I.......切换隐藏文件是否显示
" B.......切换书签隐藏显示
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-git'))
\ || count(g:dotvim_groups, 'git')
Plug 'Xuyuanp/nerdtree-git-plugin'
endif
" ==> 快速搜索插件
" An ack.vim alternative mimics Ctrl-Shift-F on Sublime Text 2
" require ag(a.k.a `the_silver_searcher`) or ack
Plug 'dyng/ctrlsf.vim'
let g:ctrlsf_winsize = '30%'
let g:ctrlsf_auto_close = 0
nmap <C-S>f <Plug>CtrlSFPrompt
vmap <C-S>f <Plug>CtrlSFVwordPath
vmap <C-S>F <Plug>CtrlSFVwordExec
nmap <C-S>n <Plug>CtrlSFCwordPath
nmap <C-S>p <Plug>CtrlSFPwordPath
nnoremap <C-S>o :CtrlSFOpen<CR>
nnoremap <C-S>t :CtrlSFToggle<CR>
inoremap <C-S>t <Esc>:CtrlSFToggle<CR>
" In CtrlSF window:
" Enter - Open corresponding file of current line in the window which CtrlSF is launched from.
" t - Like Enter but open file in a new tab.
" p - Like Enter but open file in a preview window.
" O - Like Enter but always leave CtrlSF window opening.
" T - Lkie t but focus CtrlSF window instead of new opened tab.
" q - Quit CtrlSF window.
" <C-J> - Move cursor to next match.
" <C-K> - Move cursor to previous match.
" In preview window:
" q - Close preview window.
Plug 't9md/vim-choosewin'
" if you want to use overlay feature
let g:choosewin_overlay_enable = 1
" invoke with '-'
nmap - <Plug>(choosewin)
" Key Action Description
" ; win_land Navigate to current window
" - previous Naviage to previous window
" s swap Swap windows #1
" S swap_stay Swap windows but stay #1
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-motion'))
\ || count(g:dotvim_groups, 'motion')
Plug 'justinmk/vim-sneak'
let g:sneak#streak = 1
"replace 'f' with 1-char Sneak
nmap f <Plug>Sneak_f
nmap F <Plug>Sneak_F
xmap f <Plug>Sneak_f
xmap F <Plug>Sneak_F
omap f <Plug>Sneak_f
omap F <Plug>Sneak_F
"replace 't' with 1-char Sneak
nmap t <Plug>Sneak_t
nmap T <Plug>Sneak_T
xmap t <Plug>Sneak_t
xmap T <Plug>Sneak_T
omap t <Plug>Sneak_t
omap T <Plug>Sneak_T
Plug 'unblevable/quick-scope'
let g:qs_enable = 0
" Map the leader key + q to toggle quick-scope's highlighting in normal/visual mode.
" Note that you must use nmap/vmap instead of their non-recursive versions (nnoremap/vnoremap).
nmap <leader>tq <plug>(QuickScopeToggle)
vmap <leader>tq <plug>(QuickScopeToggle)
Plug 'haya14busa/incsearch.vim'
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" <Plug>(incsearch-stay) doesn't move the cursor.
let g:incsearch#auto_nohlsearch = 1
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map # <Plug>(incsearch-nohl-*)
map * <Plug>(incsearch-nohl-#)
map g# <Plug>(incsearch-nohl-g*)
map g* <Plug>(incsearch-nohl-g#)
" 快速到达指定位置插件
Plug 'easymotion/vim-easymotion'
let g:EasyMotion_do_mapping = 0 " Disable default mappings
let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
" With this option set, v will match both v and V, but V will match V only. Default: 0.
let g:EasyMotion_smartcase = 1
" Integration between incsearch.vim and vim-easymotion
Plug 'haya14busa/incsearch-easymotion.vim'
" map z/ <Plug>(incsearch-easymotion-/)
" map z? <Plug>(incsearch-easymotion-?)
" map zg/ <Plug>(incsearch-easymotion-stay)
" You can use other keymappings like <C-l> instead of <CR> if you want to
" use these mappings as default search and somtimes want to move cursor with
" EasyMotion.
function! s:incsearch_config(...) abort
return incsearch#util#deepextend(deepcopy({
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
\ 'keymap': {
\ "\<CR>": '<Over>(easymotion)'
\ },
\ 'is_expr': 0
\ }), get(a:, 1, {}))
endfunction
noremap <silent><expr> z/ incsearch#go(<SID>incsearch_config())
noremap <silent><expr> z? incsearch#go(<SID>incsearch_config({'command': '?'}))
noremap <silent><expr> zg/ incsearch#go(<SID>incsearch_config({'is_stay': 1}))
Plug 'kshenoy/vim-signature'
" mx Toggle mark 'x' and display it in the leftmost column
" dmx Remove mark 'x' where x is a-zA-Z
" m, Place the next available mark
" m. If no mark on line, place the next available mark. Otherwise, remove (first) existing mark.
" m- Delete all marks from the current line
" m<Space> Delete all marks from the current buffer
" ]` Jump to next mark
" [` Jump to prev mark
" ]' Jump to start of next line containing a mark
" [' Jump to start of prev line containing a mark
" `] Jump by alphabetical order to next mark
" `[ Jump by alphabetical order to prev mark
" '] Jump by alphabetical order to start of next line having a mark
" '[ Jump by alphabetical order to start of prev line having a mark
" m/ Open location list and display marks from current buffer
" m[0-9] Toggle the corresponding marker !@#$%^&*()
" m<S-[0-9]> Remove all markers of the same type
" ]- Jump to next line having a marker of the same type
" [- Jump to prev line having a marker of the same type
" ]= Jump to next line having a marker of any type
" [= Jump to prev line having a marker of any type
" m? Open location list and display markers from current buffer
" m<BS> Remove all markers
Plug 'terryma/vim-expand-region'
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
Plug 't9md/vim-textmanip'
xmap <C-j> <Plug>(textmanip-move-down)
xmap <C-k> <Plug>(textmanip-move-up)
xmap <C-h> <Plug>(textmanip-move-left)
xmap <C-l> <Plug>(textmanip-move-right)
" toggle insert/replace with <F10>
nmap <F10> <Plug>(textmanip-toggle-mode)
xmap <F10> <Plug>(textmanip-toggle-mode)
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-writing'))
\ || count(g:dotvim_groups, 'writing')
" ==> Trailing whitespace
Plug 'ntpeters/vim-better-whitespace'
map <leader><space> :StripWhitespace<cr>
" ==> 自动补全引号, 括号等
Plug 'Raimondi/delimitMate'
let g:delimitMate_expand_cr = 1
let g:delimitMate_expand_space = 1
Plug 'junegunn/vim-easy-align'
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
Plug 'wellle/targets.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'scrooloose/nerdcommenter'
" 让注释符与语句之间留一个空格
let g:NERDSpaceDelims = 1
" 不自动绑定键位
let g:NERDCreateDefaultMappings = 0
" !!! can not use noremap here
nmap <leader>cl <Plug>NERDCommenterInvert
vmap <leader>cl <Plug>NERDCommenterInvert
nmap <leader>cy <Plug>NERDCommenterYank
vmap <leader>cy <Plug>NERDCommenterYank
" 鼠标多重选择
Plug 'terryma/vim-multiple-cursors'
" 搜索替换快速预览
Plug 'osyo-manga/vim-over'
" search and substitute
nnoremap <leader>ss :OverCommandLine<CR>
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-git'))
\ || count(g:dotvim_groups, 'git')
Plug 'airblade/vim-gitgutter'
" default maps
" nmap [c <Plug>GitGutterPrevHunk
" nmap ]c <Plug>GitGutterNextHunk
" nmap <Leader>hs <Plug>GitGutterStageHunk
" nmap <Leader>hr <Plug>GitGutterRevertHunk
" nmap <Leader>hp <Plug>GitGutterPreviewHunk
" Plug 'jreybert/vimagit'
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-syntastic'))
\ || count(g:dotvim_groups, 'syntastic')
" 语法分析插件
Plug 'scrooloose/syntastic'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_error_symbol='>>'
let g:syntastic_warning_symbol='>'
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 1
let g:syntastic_loc_list_height = 5
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_enable_highlighting=1
function! ToggleErrors()
let old_last_winnr = winnr('$')
lclose
if old_last_winnr == winnr('$')
" Nothing was closed, open syntastic error location panel
Errors
endif
endfunction
nnoremap <Leader>ss :call ToggleErrors()<cr>
nnoremap <Leader>sn :lnext<cr>
nnoremap <Leader>sp :lprevious<cr>
" let g:syntastic_debug=3
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-tmux'))
\ || count(g:dotvim_groups, 'tmux')
Plug 'tmux-plugins/vim-tmux'
" FocusGained and FocusLost autocommand events are not working in terminal vim.
" This plugin restores them when using vim inside Tmux.
Plug 'tmux-plugins/vim-tmux-focus-events'
" vim-tmux-navigator
Plug 'christoomey/vim-tmux-navigator'
" fix neovim C-h send backspace problem
" you should run it in `normal terminal` and `tmux` separately
" ```bash
" infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
" tic $TERM.ti
" rm $TERM.ti
" ```
nnoremap <Tab> <C-w>w
if has('nvim')
tnoremap <Esc> <C-\><C-n>
tnoremap <silent> <C-h> <C-\><C-n>:TmuxNavigateLeft<cr>
tnoremap <silent> <C-j> <C-\><C-n>:TmuxNavigateDown<cr>
tnoremap <silent> <C-k> <C-\><C-n>:TmuxNavigateUp<cr>
tnoremap <silent> <C-l> <C-\><C-n>:TmuxNavigateRight<cr>
end
" Window resizing mappings {{{
nnoremap <silent> <S-Up> 5<c-w>+<CR>
nnoremap <silent> <S-Down> 5<c-w>-<CR>
nnoremap <silent> <S-Left> 5<c-w><<CR>
nnoremap <silent> <S-Right> 5<c-w>><CR>
" }}}
endif
""" ==========================
""" File type specific plugins
""" ==========================
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-html'))
\ || count(g:dotvim_groups, 'html')
" ==> extended % matching for HTML, LaTeX, and many other languages
Plug 'tmhedberg/matchit'
" default keymap is `<C-Y>,` (not <leader>, just comma `,')
Plug 'mattn/emmet-vim'
let g:user_emmet_mode='inv'
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-css'))
\ || count(g:dotvim_groups, 'css')
" Write styles faster. Much faster.
" Plug 'rstacruz/vim-hyperstyle'
Plug 'groenewege/vim-less'
Plug 'hail2u/vim-css3-syntax'
augroup VimCSS3Syntax
autocmd!
autocmd FileType css setlocal iskeyword+=-
augroup END
" ap/vim-css-color # 不支持Vim74, 使用vim-colorsque 替代
Plug 'Marslo/vim-coloresque', {'for': ['css', 'less', 'scss']}
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-js'))
\ || count(g:dotvim_groups, 'js')
Plug 'leafgarland/typescript-vim'
Plug 'kchmck/vim-coffee-script'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
" javascript ES6 support, only enable this in pure javascript files,
Plug 'othree/yajs.vim', {'for': ['javascript', 'javascript.jsx']}
Plug 'heavenshell/vim-jsdoc'
let g:jsdoc_input_description = 1
let g:jsdoc_underscore_private = 1
let g:jsdoc_access_descriptions = 2
let g:jsdoc_enable_es6 = 1
autocmd Filetype {javascript,javascript.jsx} map <leader>doc :JsDoc<CR>
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-syntastic'))
\ || count(g:dotvim_groups, 'syntastic')
let g:syntastic_javascript_checkers = ['eslint']
Plug 'mtscout6/syntastic-local-eslint.vim'
endif
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-php'))
\ || count(g:dotvim_groups, 'php')
Plug 'SirVer/ultisnips'
" required by tobys/pdv
Plug 'tobyS/vmustache', {'for': ['php']}
" phpdoc generator,
" require tobys/pdv and SirVer/ultisnips
Plug 'tobyS/pdv', {'for': ['php']}
let g:pdv_template_dir = $HOME ."/.vim/plugins/pdv/templates_snip"
autocmd Filetype php map <leader>doc :call pdv#DocumentWithSnip()<CR>
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-markdown'))
\ || count(g:dotvim_groups, 'markdown')
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
" plasticboy/vim-markdown has a useful function TableFormat
" waiting for vim-pandoc/vim-pandoc-syntax#156 for inlinecode highlight correctly
" Plug 'vim-pandoc/vim-pandoc-syntax'
let g:pandoc#syntax#conceal#use = 0
if !exists('g:pandoc#syntax#codeblocks#embeds#langs')
let g:pandoc#syntax#codeblocks#embeds#langs = ['viml=vim', 'html', 'css', 'js=javascript', 'php', 'sh']
endif
" Plug 'vim-pandoc/vim-pandoc'
let g:pandoc#filetypes#handled = ["pandoc", "markdown"]
endif
if (count(g:dotvim_groups, 'common') && !count(g:dotvim_groups, '-nginx'))
\ || count(g:dotvim_groups, 'nginx')
Plug 'chr4/nginx.vim'
endif
""" ==========================
""" separate installed plugin groups
""" ==========================
if count(g:dotvim_groups, 'fcitx')
Plug 'CodeFalling/fcitx-vim-osx'
endif
if count(g:dotvim_groups, 'matchtag')
Plug 'Valloric/MatchTagAlways'
endif
if count(g:dotvim_groups, 'snippets')
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
let g:UltiSnipsExpandTrigger="<Tab>"
let g:UltiSnipsJumpForwardTrigger="<Tab>"
let g:UltiSnipsJumpBackwardTrigger="<S-Tab>"
endif
if count(g:dotvim_groups, 'youcompleteme')
" 更强大的补全插件
if has('nvim') || has('patch584') || has("gui_macvim")
Plug 'Valloric/YouCompleteMe'
let g:ycm_key_list_select_completion=['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion=['<C-p>', '<Up>']
let g:ycm_complete_in_comments = 1 "在注释输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 "注释和字符串中的文字也会被收入补全
let g:ycm_seed_identifiers_with_syntax=1 "语言关键字补全
" HACK: when popup menu shows, use enter to confirm select one complete option
" imap <expr> <CR> pumvisible() ? "<c-y>" : "<cr>"
endif
endif
" If user have own plugins or configs, load them here
if filereadable(expand("~/.vimrc.plugins.local"))
source ~/.vimrc.plugins.local
endif
call plug#end()