-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
292 lines (264 loc) · 8.31 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
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Bundle 'flazz/vim-colorschemes'
Bundle 'majutsushi/tagbar'
Bundle 'Valloric/YouCompleteMe'
Bundle 'ctrlpvim/ctrlp.vim'
Bundle 'tpope/vim-rails'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/nerdcommenter'
Bundle 'Shougo/neocomplete.vim'
Bundle 'minibufexpl.vim'
"Bundle 'msanders/snipmate.vim'
"Bundle 'dyng/ctrlsf.vim'
Bundle 'terryma/vim-multiple-cursors'
Bundle 'tpope/vim-bundler'
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-endwise'
Bundle 'thoughtbot/vim-rspec'
Bundle 'danro/rename.vim'
Bundle 'pbrisbin/vim-mkdir'
Bundle 'tpope/vim-surround'
Bundle 'tmhedberg/matchit'
Bundle 'vim-scripts/tComment'
"Bundle 'tomtom/tcomment_vim'
Bundle 'mattn/emmet-vim'
Bundle 'godlygeek/tabular'
Bundle 'easymotion/vim-easymotion'
Bundle 'vim-syntastic/syntastic'
Bundle 'christoomey/vim-run-interactive'
Bundle 'kchmck/vim-coffee-script'
Bundle 'tpope/vim-unimpaired'
Bundle 'tomasr/molokai'
Bundle 'vim-airline/vim-airline'
Bundle 'vim-airline/vim-airline-themes'
Bundle 'Yggdroot/indentLine'
Bundle 'othree/javascript-libraries-syntax.vim'
Bundle 'jelera/vim-javascript-syntax'
Bundle 'ternjs/tern_for_vim'
Bundle 'vim-scripts/JavaScript-Indent'
Bundle 'rking/ag.vim'
Bundle 'Shougo/vimshell.vim'
Bundle 'Shougo/vimproc.vim', {
\ 'build': {
\ 'mac': 'make',
\ 'linux': 'make',
\ 'unix': 'gmake'
\ }
\ }
Bundle 'SirVer/ultisnips'
Bundle 'honza/vim-snippets'
Bundle 'Konfekt/FastFold'
Bundle 'artur-shaik/vim-javacomplete2'
Bundle 'L9'
Bundle 'vim-scripts/FuzzyFinder'
" Bundle 'vim-scripts/AutoComplPop'
Bundle 'kana/vim-fakeclip'
Bundle 'jlanzarotta/bufexplorer'
Bundle 'c9s/gsession.vim'
Bundle 'pangloss/vim-javascript'
Bundle 'othree/html5.vim'
Bundle 'hail2u/vim-css3-syntax'
Bundle 'maralla/validator.vim'
Bundle 'NBUT-Developers/extra-instant-markdown'
Bundle 'isomoar/vim-css-to-inline'
Bundle 'metakirby5/codi.vim'
Bundle 'ervandew/supertab'
Bundle 'mbbill/undotree'
Bundle 'yuttie/comfortable-motion.vim'
Bundle 'w0rp/ale'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-pathogen'
Bundle 'klen/python-mode'
" Bundle 'vimcn/vimcdoc'
Bundle 'jiangmiao/auto-pairs'
Bundle 'vim-scripts/OmniCppComplete'
Bundle 'vim-scripts/c.vim'
Bundle 'vim-scripts/gdbmgr'
Bundle 'brookhong/cscope.vim'
Bundle 'fatih/vim-go'
call vundle#end() " required
" call pathogen#infect()
" call pathogen#helptags()
filetype plugin indent on " required
filetype plugin on
set ofu=syntaxcomplete#Complete
" syntastic 设置
let g:syntastic_check_on_open=1
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_wq = 0
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" 设置字符集为UTF-8
set encoding=utf-8
" 开启语法高亮功能
syntax enable
" 允许用指定的语法高亮配色方案替换默认方案
syntax on
set background=dark
colorscheme cobalt
set number
" 禁止光标闪烁
set gcr=a:block-blinkon0
" 禁止显示流动条
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
" 禁止显示菜单和工具条
set guioptions-=m
set guioptions-=T
let g:AutoPairsFlyMode = 1
" 总是显示状态栏
set laststatus=2
" 显示光标当前位置
set ruler
" 高亮显示当前行/列
set cursorline
set cursorcolumn
" 高亮显示搜索结果
set hlsearch
" 设置 gvim 显示字体
set guifont=YaHei\ Consolas\ Hybrid\ 16
" 禁止折行
" set nowrap
" 自适应不同语言的智能缩进
filetype indent on
" 将制表符扩展为空格
"set expandtab
" 设置编辑时制表符占用空格数
set tabstop=4
" 设置格式化时制表符占用空格数
set shiftwidth=4
" 让 vim 把连续数量的空格视为一个制表符
set softtabstop=4
set list
set list lcs=trail:·,tab:»·
" java 文件设置tab键等于4个空格
autocmd FileType css,html,jsp,js set tabstop=4 | set shiftwidth=4 | set softtabstop=4
autocmd FileType ruby,yaml set tabstop=2 | set shiftwidth=2 | set softtabstop=2 | set expandtab
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
" 随 vim 自启动
let g:indent_guides_enable_on_vim_startup=1
" 从第二层开始可视化显示缩进
let g:indent_guides_start_level=2
set foldmethod=syntax
" 启动 vim 时关闭折叠代码
set nofoldenable
" 开启实时搜索功能
set incsearch
" NERDTree设置
map <F7> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" Tagbar设置
nmap <F8> :TagbarToggle<CR>
" ctrlsf.vm 设置
"let g:ctrlsf_ackprg = 'ag'
" 搜索时大小写不敏感
set ignorecase
" 设置ctrlp.vim
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files.
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" Ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
let g:ctrlp_map = '<F9>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.png,*.jpg,*.jpeg,*.gif " MacOSX/Linux
let g:ctrlp_custom_ignore = '\v[\/]\.(atom|git|hg|svn)$'
let g:ctrlp_user_command = 'find %s -type f'
" RSpec.vim mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" Add this to your vimrc to provide a shortcut
nnoremap <leader>ri :RunInInteractiveShell<space>
" 快速移动文本块
nnoremap ∆ :m .+1<CR>==
nnoremap ˚ :m .-2<CR>==
inoremap ∆ <Esc>:m .+1<CR>==gi
inoremap ˚ <Esc>:m .-2<CR>==gi
vnoremap ∆ :m '>+1<CR>gv=gv
vnoremap ˚ :m '<-2<CR>gv=gv
" 设置wildmode 跟bash shell一样
set wildmode=longest,list
" 设置命名行补全方式跟zsh一样
"set wildmenu
"set wildmode=full
" 设置保存历史命令记录为200条
set history=200
" 结合C-n,C-p与Up, Down键的优点
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
" 扩展%:h
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" 设置neocomplete
let g:neocomplete#enable_at_startup = 1
" airline设置
let g:airline_section_b = '%{strftime("%c")}'
let g:airline_section_y = 'BN: %{bufnr("%")}'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
" ag.vim
let g:ackprg = 'ag --nogroup --nocolor --column --vimgrep'
let g:ag_working_path_mode="r"
" ultisnips configure
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsEditSplit="vertical"
" YCM configure
let g:ycm_key_list_select_completion=['<c-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
set guioptions-=T " 隐藏菜单栏
set guioptions-=m " 隐藏工具栏
" vim-javacomplete2 配置
autocmd FileType java setlocal omnifunc=javacomplete#Complete
nmap <F4> <Plug>(JavaComplete-Imports-AddSmart)
imap <F4> <Plug>(JavaComplete-Imports-AddSmart)
nmap <F5> <Plug>(JavaComplete-Imports-Add)
imap <F5> <Plug>(JavaComplete-Imports-Add)
nmap <F6> <Plug>(JavaComplete-Imports-AddMissing)
imap <F6> <Plug>(JavaComplete-Imports-AddMissing)
nmap <F3> <Plug>(JavaComplete-Imports-RemoveUnused)
imap <F3> <Plug>(JavaComplete-Imports-RemoveUnused)
" FuzzyFinder 配置
map <c-t> :FufCoverageFile!<CR>
" vim-javascript 配置
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_ngdoc = 1
let g:javascript_plugin_flow = 1
set foldmethod=syntax
" html5.vim 配置
let g:html5_event_handler_attributes_complete = 0
let g:html5_rdfa_attributes_complete = 0
let g:html5_microdata_attributes_complete = 0
let g:html5_aria_attributes_complete = 0
" vim-css3-syntax 配置
augroup VimCSS3Syntax
autocmd!
autocmd FileType css setlocal iskeyword+=-
augroup END
" validator.vim 配置
let g:validator_javascript_checkers = ['eslint']
let g:validator_css_checkers = ['csslint']
let g:validator_json_checkers = ['jsonlint']
let g:validator_vim_checkers = ['vimlparser']
let g:validator_sh_checkers = ['shellcheck']
let g:validator_python_checkers = ['flake8']
let g:validator_c_checkers = ['clang-tidy']
let g:validator_auto_open_quickfix = 1