-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
452 lines (363 loc) · 13.7 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
let $LANG = 'en' "设置英文
set langmenu=en "设置 gvim 为英文,注意 = 两边没有空格的
set autowriteall
set shell=sh
set guifont=Sarasa\ Mono\ SC
"set guifont=Nerd\ Fonts
set nocompatible "去除VIM一致性,必须"
set encoding=UTF-8
"设置包括vundle和初始化相关的运行时路径"
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
set rtp+=~/.vim/bundle/ctrlp.vim
"启用vundle管理插件,必须"
Plugin 'VundleVim/Vundle.vim'
"在此增加其他插件,安装的插件需要放在vundle#begin和vundle#end之间"
"安装github上的插件格式为 Plugin '用户名/插件仓库名'"
"Plugin 'ms-jpq/chadtree' ", {'branch': 'chad', 'do': 'python3 -m chadtree deps'}
Plugin 'xingangshi/vim-quick-create'
Plugin 'xingangshi/vim-base-plugin'
Plugin 'grep.vim'
Plugin 'taglist.vim'
Plugin 'rizzatti/dash.vim'
Plugin 'mileszs/ack.vim'
Plugin 'jiangmiao/auto-pairs'
Plugin 'nathangrigg/vim-beancount'
Plugin 'dkprice/vim-easygrep'
Plugin 'jreybert/vimagit'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rhubarb'
Plugin 'junegunn/gv.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'sodapopcan/vim-twiggy'
Plugin 'cwshugg/argonaut.vim'
Plugin 'cwshugg/fops.vim'
"Plugin 'Xuyuanp/git-nerdtree'
Plugin 'preservim/nerdtree'
\ | Plugin 'ryanoasis/vim-devicons'
\ | Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'kien/ctrlp.vim'
"Plugin 'liuchengxu/eleline.vim'
Plugin 'powerline/powerline'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" colors
Plugin 'mhartington/oceanic-next'
Plugin 'yuttie/hydrangea-vim'
Plugin 'liuchengxu/space-vim-theme'
" 开启 YouCompleteMe 安装,去掉下面一行的注释
Plugin 'Valloric/YouCompleteMe' "YouCompleteMe requires Vim 7.4.1578+, python3
" for flutter
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'thosakwe/vim-flutter'
"Plugin 'davidhalter/jedi-vim'
Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plugin 'junegunn/fzf.vim'
"for markdown
Plugin 'sheerun/vim-polyglot'
Plugin 'godlygeek/tabular'
Plugin 'preservim/vim-markdown'
Plugin 'iamcco/mathjax-support-for-mkdp'
Plugin 'iamcco/markdown-preview.nvim'
Plugin 'suan/vim-instant-markdown'
Plugin 'qadzek/link.vim'
let g:link_enabled_filetypes = ['markdown', 'gitcommit']
let g:polyglot_disabled = ['markdown']
let g:mkdp_path_to_chrome = "open -a Google\\ Chrome"
"let g:mkdp_browserfunc = 'MKDP_browserfunc_default'
let g:mkdp_auto_start = 1
let g:mkdp_auto_open = 1
let g:mkdp_auto_close = 1
let g:mkdp_refresh_slow = 0
let g:mkdp_command_for_global = 0
let g:mkdp_open_to_the_world = 0
" Filetype names and aliases for fenced code blocks.
let g:vim_markdown_fenced_languages = ['php', 'py=python', 'js=javascript', 'bash=sh', 'viml=vim']
" for rust
Plugin 'rust-lang/rust.vim'
Plugin 'neoclide/coc.nvim', {'branch': 'master'}
Plugin 'dense-analysis/ale'
let b:ale_linters = ['markdownlint', 'vale']
let b:ale_fixers = ['prettier']
" 可选插件 pandoc-vim
Plugin 'vim-pandoc/vim-pandoc'
Plugin 'vim-pandoc/vim-pandoc-syntax'
Plugin 'vim-pandoc/vim-markdownfootnotes'
Plugin 'vim-latex/vim-latex'
let g:pandoc#spell#enabled=0
" vim org mode
Plugin 'jceb/vim-orgmode'
Plugin 'tpope/vim-speeddating'
Plugin 'mattn/calendar-vim'
Plugin 'majutsushi/tagbar'
Plugin 'skywind3000/vim-rt-format', { 'do': 'pip3 install autopep8' }
let g:rtf_ctrl_enter = 0
" Enable formatting when leaving insert mode
let g:rtf_on_insert_leave = 1
set nofoldenable
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '_'
let g:airline#extensions#tabline#formatter = 'default'
let g:airline#extensions#statusline#top = 0
let g:airline_statusline_ontop=0
"NERD_tree
noremap <F2> <ESC>:TlistToggle<CR>
inoremap <C-F2> <ESC>:TlistToggle<CR>
noremap <F3> <ESC>:NERDTreeToggle<CR>
inoremap <C-F3> <ESC>:NERDTreeToggle<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
let g:NERDTreeMapJumpNextSibling = get(g:, 'NERDTreeMapJumpNextSibling', '<S-j>')
let g:NERDTreeMapJumpPrevSibling = get(g:, 'NERDTreeMapJumpPrevSibling', '<S-k>')
"let g:NERDTreeFileLines = 1
let g:NERDTreeModifiable = 1
let g:NERDTreeShowHidden = 1
let g:NERDTreeGitStatusPorcelainVersion = 1
let g:NERDTreeGitStatusUseNerdFonts = 1
let g:NERDTreeGitStatusShowIgnored = 1
let g:NERDTreeGitStatusUntrackedFilesMode = 'all'
let g:NERDTreeGitStatusShowClean = 1
let g:NERDTreeGitStatusConcealBrackets = 1
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' :'✹',
\ 'Staged' :'✚',
\ 'Untracked' :'✭',
\ 'Renamed' :'➜',
\ 'Unmerged' :'═',
\ 'Deleted' :'✖',
\ 'Dirty' :'✗',
\ 'Ignored' :'☒',
\ 'Clean' :'✔︎',
\ 'Unknown' :'?',
\ }
call vundle#end() " required
syntax enable
filetype plugin indent on "加载vim自带和插件相应的语法和文件类型相关脚本,必须"
autocmd FileType dart :call FlutterMenu()
" Some of these key choices were arbitrary;
" it's just an example.
nnoremap <leader>fa :FlutterRun<cr>
nnoremap <leader>fq :FlutterQuit<cr>
nnoremap <leader>fr :FlutterHotReload<cr>
nnoremap <leader>fR :FlutterHotRestart<cr>
nnoremap <leader>fD :FlutterVisualDebug<cr>
let g:ycm_semantic_triggers={'c,cpp,python,rust,java,go,erlang,perl,cs,lua,javascript':['re!\w{2}']}
let g:ycm_rust_src_path = '~/self/rust/rust-1.70.0/src/'
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
let g:ycm_always_populate_location_list = 1
set nonu
set background=dark
syntax on
nnoremap <silent> <F3> :Grep<CR>
" switch windows
map <C-H> <C-W>h
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-L> <C-W>l
set backspace=indent,eol,start
" Taglist
let Tlist_Auto_Update=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
let Tlist_WinWidth=27
let Tlist_Show_One_File=1
"omnicppcomplete
set nocp
let g:OmniCpp_GlobalScopeSearch = 1
let g:OmniCpp_NamespaceSearch = 1
"color
let g:rehash256 = 1
"let g:molokai_original = 0
highlight NonText guibg=#060606
highlight Folded guibg=#0A0A0A guifg=#9090D0
set t_Co=256
set background=dark
"set t_Co=256
"ctags
"map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> <Esc>:set tags+=./tags <CR>
"set path+=/usr/include
set listchars=tab:>-,trail:%
set list
"paste module
set pastetoggle=<F11>
filetype indent plugin on
"用 space 替代 tab 的输入
set expandtab
"不用 space 替代 tab 的输入
"set noexpandtab
"设定 tab 宽度为 4 个字符
set tabstop=4
"设置软缩进的宽度为 4 个空格
set softtabstop=4
"设定自动缩进为 4 个字符
set shiftwidth=4
set smartindent
set autoindent
set cindent
au Filetype python setlocal ts=4 sts=4 sw=4
"第 80 行之后高亮显示
hi LineTooLong ctermfg=223
au BufWinEnter *.py,*.h,*.cc let w:m1=matchadd('Search', '\%>79v', -1)
au BufWinEnter *.py,*.h,*.cc let w:m2=matchadd('LineTooLong', '\%>79v.\+', -1)
au BufWinEnter *.py,*.h,*.cc let w:m2=matchadd('LineTooLong', '^ +$', -1)
" highlight search
set hlsearch
" py highlight
let python_highlight_builtins = 1
let python_highlight_builtin_objs = 1
let python_highlight_exceptions = 1
let python_highlight_string_formatting = 1
let python_highlight_string_format = 1
let python_highlight_string_templates = 1
let python_highlight_indent_errors = 1
let python_highlight_space_errors = 1
let python_highlight_doctests = 1
let python_highlight_all = 1
let python_print_as_function = 1
autocmd FileType python set omnifunc=pythoncomplete#Complete
augroup filetype
au! BufRead,BufNewFile *.proto set filetype=proto
au! BufRead,BufNewFile *.txt,*.INFO,*.ERROR,*.WARNING set filetype=python
au! BufRead,BufNewFile CMakeLists.txt set filetype=cmake
au! BufRead,BufNewFile *.rs set filetype=rust
au! BufRead,BufNewFile SConstruct,SConscript set filetype=python
augroup end
"switch h, cc
noremap <leader>av :AV<CR>
set ic
set incsearch
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
"自动加载~/tags下的文件
execute "set tags+=" . system("ls -l ~/tags/ | grep -v ^total | awk 'BEGIN{a=\"\"}{if (a != \"\") a = a \",\"; a=a \"~/tags/\" $NF} END{print a}'")
" https://agentzh.org/misc/.vimrc
"自动补全配置
" As-you-type autocomplete
"set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
set completeopt=menu,menuone,preview,noselect,noinsert
let g:ale_completion_enabled = 1
let g:ale_fixers = { 'rust': ['rustfmt', 'trim_whitespace', 'remove_trailing_lines'] }
autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" "回车即选中当前项
"上下左右键的行为 会显示其他信息
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
"youcompleteme 默认tab s-tab 和自动补全冲突
"let g:ycm_key_list_select_completion=['<c-]>']
let g:ycm_key_list_select_completion = ['<Down>']
"let g:ycm_key_list_previous_completion=['<c-[>']
let g:ycm_key_list_previous_completion = ['<Up>']
let g:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示
let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 基于标签引擎
let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "force recomile with syntastic
"nnoremap <leader>lo :lopen<CR> "open locationlist
"nnoremap <leader>lc :lclose<CR> "close locationlist
inoremap <leader><leader> <C-x><C-o>
"在注释输入中也能补全
let g:ycm_complete_in_comments = 1
"在字符串输入中也能补全
let g:ycm_complete_in_strings = 1
"注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 0
nnoremap <leader>jl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>jf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处
let Tlist_Ctags_Cmd='ctags'
let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_WinWidt =28 "设置taglist的宽度
let Tlist_Exit_OnlyWindow=1 "如果taglist窗口是最后一个窗口,则退出vim
"let Tlist_Use_Right_Window=1 "在右侧窗口中显示taglist窗口
let Tlist_Use_Left_Windo =1 "在左侧窗口中显示taglist窗口
" Ctrlp setting
let g:ctrlp_map = '<space>m'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux"
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' " MacOSX/Linux
"set wildignore+=*tmp*,*.swp,*.zip,*.exe " Windows
"let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
"let g:ctrlp_custom_ignore = {
" \ 'dir': '\v[\/]\.(git|hg|svn)$',
" \ 'file': '\v\.(exe|so|dll)$',
" \ 'link': 'some_bad_symbolic_links',
" \} " Windows
nmap <C-i> :Files<CR>
nmap <C-h> :Buffers<CR>
nmap <C-k> :RG<CR>
let g:fzf_action = { 'ctrl-e': 'edit' }
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " Linux/MacOSX
"set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
"vim orgmode
packloadall
silent! hellptags ALL
let g:org_agenda_files=['~/self/org/orgmode.org']
let g:org_todo_keywords=['TODO', 'FEEDBACK', 'VERIFY', '|', 'DONE', 'DELEGATED']
syntax on
let g:oceanic_next_terminal_bold = 1
let g:oceanic_next_terminal_italic = 1
"for rust start
let g:rustfmt_autosave = 1
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nmap <silent> gf <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
inoremap <silent><expr> <c-@> coc#refresh()
" Use K to show documentation in preview window
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Highlight the symbol and its references when holding the cursor
autocmd CursorHold * silent call CocActionAsync('highlight')
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
"for rust end
let g:fzf_layout = { 'down': '40%' }
colorscheme OceanicNext
colorscheme Hydrangea
colorscheme molokai
set updatetime=300 "每300秒 git检查一次"
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '-'
let g:gitgutter_sign_removed = '*'
let g:gitgutter_sign_removed_first_line = '_'
let g:gitgutter_sign_removed_above_and_below = '>'
let g:gitgutter_sign_modified_removed = '<'
syntax enable
filetype plugin indent on
nmap <C-m> <Cmd>CocCommand explorer<CR>
hi CocMenuSel guifg=#cccccc guibg=#2a3d75
if has("termguicolors")
" enable true color
set termguicolors
endif