forked from sakinijino/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc.vim
More file actions
563 lines (470 loc) · 13 KB
/
Copy pathvimrc.vim
File metadata and controls
563 lines (470 loc) · 13 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
" vim-plug
" https://github.com/junegunn/vim-plug
let g:plug_window="topleft new"
if has("win32") || has("win64")
call plug#begin('~/vimfiles/bundle')
else
call plug#begin('~/.vim/bundle')
endif
"color schemes
Plug 'kristijanhusak/vim-hybrid-material'
"Plug 'tomasr/molokai'
"Plug 'yosiat/oceanic-next-vim'
"Plug 'mhumeSF/one-dark.vim'
Plug 'wangxd18/vim-atom-dark'
"Plug 'altercation/vim-colors-solarized'
"vim functional plugins
Plug 'rking/ag.vim'
"Plug 'scrooloose/syntastic'
Plug 'cep21/syntasticarc' "https://fb.facebook.com/groups/186093421431695/290554350985601/
Plug 'ntpeters/vim-better-whitespace'
Plug 'vim-scripts/bufexplorer.zip'
Plug 'vim-scripts/ctags.vim'
Plug 'Raimondi/delimitMate'
Plug 'godlygeek/tabular'
Plug 'kien/ctrlp.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"Plug 'edkolev/tmuxline.vim'
"Plug 'raichoo/haskell-vim'
Plug 'wangxd18/ultisnips'
Plug 'groenewege/vim-less'
"Plug 'jtratner/vim-flavored-markdown'
"Plug 'nelstrom/vim-markdown-preview'
Plug 'vim-scripts/matchit.zip'
Plug 'vim-scripts/mru.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'vim-scripts/ragtag.vim'
Plug 'duff/vim-scratch'
Plug 'rstacruz/sparkup'
Plug 'easymotion/vim-easymotion'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-endwise'
Plug 'terryma/vim-multiple-cursors'
Plug 'majutsushi/tagbar'
Plug 'vim-scripts/TagHighlight'
" html
Plug 'othree/html5.vim'
" css, scss
Plug 'hail2u/vim-css3-syntax'
Plug 'tpope/vim-haml'
" javascript
Plug 'othree/javascript-libraries-syntax.vim'
"Plug 'ramitos/jsctags'
Plug 'mxw/vim-jsx'
Plug 'pangloss/vim-javascript'
Plug 'flowtype/vim-flow'
" Hack
Plug 'hhvm/vim-hack'
" xhp
Plug 'mxw/vim-xhp'
" not using
"Plug 'jelera/vim-javascript-syntax'
"Plug 'Valloric/YouCompleteMe', { 'frozen': 1 }
" Add plugins to &runtimepath
call plug#end()
"Helptags
"set default workspace
if has("mac")
cd ~/local
elseif has('unix')
"cd ~/www
endif
noremap , ;
noremap \ ,
let mapleader=";"
let g:mapleader=";"
set history=400
set backspace=indent,eol,start
set ruler
set showcmd
set noshowmode
set ambiwidth=double
set gcr=a:blinkon0 "Disable cursor blink
set visualbell "No sounds
set autoread "Reload files changed outside vim
set equalalways
set autochdir
au BufRead,BufNewFile *.mustache set filetype=html
" fold setting
set foldmethod=indent
set foldlevel=20
set foldlevelstart=20
" Note, perl automatically sets foldmethod in the syntax file
autocmd Syntax c,cpp,vim,xml,html,xhtml, setlocal foldmethod=syntax
autocmd Syntax c,cpp,vim,xml,html,xhtml,perl normal zR
if has("win32") || has("win64")
language messages en.utf-8
endif
set encoding=utf-8
set fileencoding=utf-8
set fileformat=unix
set fileencodings=utf-8,chinese,latin-1
set fileformats=dos,unix
set t_Co=256
" colorscheme
set background=dark
"colorscheme molokai
let g:hybrid_use_Xresources = 1
"colorscheme OceanicNext
"colorscheme hybrid_material
"colorscheme solarized
colorscheme atom-dark-256
set number
set numberwidth=4
set wrap
set nolinebreak
if exists("&colorcolumn")
set colorcolumn=80
endif
"在输入命令时tab列出匹配项目
set wildmode=list:longest
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=.tmp/**
set wildignore+=*node_modules*
set wildignore+=*bundle*
set wildignore+=*bower_components*
set wildignore+=*.png,*.jpg,*.gif,*.ico
" ================ Scrolling ========================
set scrolloff=8 "Start scrolling when we're 8 lines away from margins
set sidescrolloff=15
set sidescroll=1
"set nobackup
"set noswapfile
set writebackup
set backupdir=~/.tmp/vim.backup//
set directory=~/.tmp/vim.swap//
set undodir=~/.tmp/vim.undo//
set undofile
"搜索忽略大小写
set ignorecase
"搜索包含大写时,只搜索大写
set smartcase
set gdefault
set incsearch " do incremental searching
set showmatch
"隐藏buffer,而不是unload
set hidden
set matchpairs=(:),{:},[:],<:>
set whichwrap=b,s,<,>,[,]
"t_Co means terminal_colors
if &t_Co > 2 || has("gui_running")
set hlsearch
set clipboard=unnamed
endif
"取消高亮, 同时关闭各种小窗口
nnoremap <silent> <leader><space> :nohlsearch<cr>:lclose<cr>:cclose<cr>:pclose<cr>
"窗口
if has("gui_running")
if has("win32") || has("win64")
set guifont=Monaco:h12:cANSI,Consolas:h12:cANSI
elseif has("mac")
set guifont=Monaco:h14
else
if has("gui_gtk2")
set guifont=Monaco:h12,Consolas:h12
set guifontwide=Microsoft\ Yahei\ 12,WenQuanYi\ Zen\ Hei\ 12
elseif has("x11")
" Also for GTK 1
set guifont=*-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-*
endif
endif
"去掉工具栏
set guioptions=e
"set cursorline
"窗口最大化
if has("win32") || has("win64")
if has("autocmd")
au GUIEnter * simalt ~x
else
set fu
endif
endif
else
set nocursorline
endif
"缩进
set smarttab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set linespace=2
set expandtab
" display the status line always
set laststatus=2
" reduce delay when leaving insert mode
set ttimeoutlen=50
"自动去除utf8 bom
if has("autocmd")
au BufReadPost *
\ if &fileencoding=="utf-8" && &bomb |
\ set nobomb |
\ write |
\ endif
endif
"win换行自动转换为unix换行
if has("autocmd")
au BufReadPost *
\ if &fileformat=="dos" |
\ set fileformat=unix |
\ write |
\ endif
endif
"js语法高亮脚本的设置
let g:javascript_enable_domhtmlcss=1
"map ctrl+g to G, go to end of file
nnoremap <c-g> G
nnoremap <leader>1 :set filetype=javascript<cr>
nnoremap <leader>2 :set filetype=html<cr>
nnoremap <leader>3 :set filetype=php<cr>
nnoremap <leader>4 :set filetype=css<cr>
map Q <Nop>
map K <Nop>
inoremap jk <esc>
"inoremap <esc> <nop>
"Paste in ic Modes
noremap! jj <c-r>"
cnoremap gj <c-r>+
"Global Clipboard
nnoremap <leader>g "+
vnoremap <leader>g "+
"重新选取刚刚粘贴的内容
nnoremap <leader>v V`]
"快速修改当前目录
nnoremap <leader>cd :cd %:p:h<cr>:pwd<cr>
"buffer
nnoremap <silent> <leader>bn :bnext<cr>
vnoremap <silent> <leader>bn :bnext<cr>
nnoremap <silent> <c-tab> :bprev<cr>
vnoremap <silent> <c-tab> :bprev<cr>
nnoremap <silent> <leader>bp :bprevious<cr>
vnoremap <silent> <leader>bp :bprevious<cr>
nnoremap <silent> <leader>bu :bunload<cr>
vnoremap <silent> <leader>bu :bunload<cr>
nnoremap <silent> <leader>bd :bdelete<cr>
vnoremap <silent> <leader>bd :bdelete<cr>
" toggle paste mode
set pastetoggle=<c-t>
"窗口
nnoremap <leader>wv <c-w>v<c-w>l
nnoremap <leader>wc <c-w>c
nnoremap <leader>wo <c-w>o
nnoremap <silent> <leader>q :close<cr>
"窗口调整
nnoremap <leader>wh <c-w>H
nnoremap <leader>wj <c-w>J
nnoremap <leader>wk <c-w>K
nnoremap <leader>wl <c-w>L
"多窗口移动
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
"禁用鼠标
if has('mouse')
set mouse=""
endif
"禁用方向键
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
"插入模式下移动光标
inoremap <c-h> <left>
inoremap <c-j> <down>
inoremap <c-k> <up>
inoremap <c-l> <right>
inoremap <c-z> <esc>zzi
nnoremap j gj
nnoremap k gk
nnoremap <c-a> ^
nnoremap <c-e> $
vnoremap <c-a> ^
vnoremap <c-e> $
"surround
let g:surround_60 = "<\r>" "<
let g:surround_40 = "(\r)" "(
" Matchit
" mapping <tab> to % in visual mode
nmap <tab> %
vmap <tab> %
omap <tab> %
"bufExplorer
let g:bufExplorerSortBy = 'mru'
let g:bufExplorerSplitRight = 0
let g:bufExplorerSplitVertical = 1
let g:bufExplorerSplitVertSize = 30
let g:bufExplorerUseCurrentWindow = 1
autocmd BufWinEnter \[Buf\ List\] setl nonumber
"netrw
let g:netrw_winsize = 30
noremap <silent> <leader>fe :Sexplore!<cr>
"NERDTree
noremap <silent> <leader>nt :NERDTree<cr>
let NERDTreeQuitOnOpen = 1
"Scratch
noremap <leader>ss :Scratch<cr>
"jsbeautify
"keymapp setted as <leader>jf
"EasyMotion
noremap <C-o> <nop>
imap ;w <C-o><leader><leader>w
imap ;b <C-o><leader><leader>b
" Airline
let g:airline_theme = 'hybrid'
"Ag
"let g:ag_prg="ag --vimgrep --smart-case"
nnoremap <leader>a :Ag <left>
"MRU
nnoremap <silent> <leader>fm :MRU<cr>
let MRU_File = &backupdir."/.vim_mru_files"
let MRU_Max_Entries = 2000
"YouCompleteMe options
let g:ycm_complete_in_comments = 1
let g:ycm_key_list_select_completion = ['<Down>']
let g:ycm_key_list_previous_completion = ['<Up>']
set completeopt-=preview
let g:ycm_global_ycm_extra_conf="~/.vim/bundle/YouCompleteMe/ycm_extra_conf.py"
" delimitMate
" enable expansion
let g:delimitMate_expand_space = 1
let g:delimitMate_expand_cr = 2
"better whitespace
"auto strip whitespace on save
"let g:strip_whitespace_on_save = 1
highlight ExtraWhitespace ctermbg = green guibg = #AFFD46
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufRead,BufNewFile *.es6 setfiletype javascript
autocmd FileType c,cpp,java,php,ruby,python,html,css,scss,javascript,jsx autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
" Syntastic settings
"let g:syntastic_javascript_checkers = ['eslint']
"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_loc_list_height = 5
"let g:syntastic_mode_map = {
"\ "mode": "passive",
"\ "passive_filetypes": ["javascript"] }
"noremap <leader>sc :SyntasticCheck<cr>
"noremap <leader>st :SyntasticToggleMode<cr>
"noremap <silent> <leader>ln :lnext<cr>
"noremap <silent> <leader>lp :lprev<cr>
" TernJs settings
"noremap <leader>td :TernDef<cr>
"noremap <leader>tr :TernRefs<cr>
"syntasticarc
set makeprg=syntasticarc
set errorformat=%f:%l:%c:%t:%m
" CtrlP setting
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlPMixed'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_match_window = 'top,order:ttb,min:1,max:10,results:10'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn|tmp)|dist|images)$',
\ 'file': '\v\.(exe|so|dll|class|png|jpg|jpeg|sw.*)$',
\}
let g:ctrlp_by_filename = 1
let g:ctrlp_show_hidden = 1
let g:ctrlp_max_depth = 25
let g:ctrlp_mruf_max = 500
let g:ctrlp_prompt_mappings = {
\ 'PrtSelectMove("u")': ['<kPageUp>'],
\ 'PrtSelectMove("d")': ['<kPageDown>'],
\ 'ToggleType(1)': ['<PageDown>'],
\ 'ToggleType(-1)': ['<PageUp>']
\}
" UltiSnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsEditSplit="vertical"
" javascript-libraries-syntax
let g:used_javascript_libs = 'react'
" Add some shortcuts for ctags
map <Leader>tt <esc>:TagbarToggle<cr>
set tags=tags;/
"Tabular
nnoremap <leader>tb :Tabularize /=
vnoremap <leader>tb :Tabularize /=
nnoremap <leader>tbz :Tabularize /:\zs<left><left><left>
vnoremap <leader>tbz :Tabularize /:\zs<left><left><left>
"Automatically fitting a quickfix window height
"http://vim.wikia.com/wiki/Automatically_fitting_a_quickfix_window_height
au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
exe max([min([line("$") + 1, a:maxheight]), a:minheight]) . "wincmd _"
endfunction
" Restore cursor to file position in previous editing session
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" Tell vim to remember certain things when we exit
" '100 : marks will be remembered for up to 100 previously edited files
" "200 : will save up to 200 lines for each register
" :80 : up to 80 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='100,\"200,:80,%,n~/.viminfo
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
if has("folding")
function! UnfoldCur()
if !&foldenable
return
endif
let cl = line(".")
if cl <= 1
return
endif
let cf = foldlevel(cl)
let uf = foldlevel(cl - 1)
let min = (cf > uf ? uf : cf)
if min
execute "normal!" min . "zo"
return 1
endif
endfunction
endif
augroup resCur
autocmd!
if has("folding")
autocmd BufWinEnter * if ResCur() | call UnfoldCur() | endif
else
autocmd BufWinEnter * call ResCur()
endif
augroup END
"Flow
let g:flow#enable=1
let g:flow#autoclose=1
nnoremap <leader>ft :HackType<cr>
nnoremap <leader>fr :HackFindRefs
"Hack and XHP
autocmd FileType php setlocal iskeyword+=:,-
nnoremap <leader>hd :HackSearch<cr>
nnoremap <leader>hs :HackSearch<cr>
nnoremap <leader>ht :HackType<cr>
nnoremap <leader>hm :HackMake<cr>
nnoremap <leader>hr :HackFindRefs