-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc_current_but_exist_bug
418 lines (365 loc) · 16.4 KB
/
.vimrc_current_but_exist_bug
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
set nocompatible " be iMproved, required
filetype off " required
" 管理插件的工具
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'rking/ag.vim' " 对于vimgrep 的 搜索优化
Plugin 'frazrepo/vim-rainbow' " 都是彩虹屁
Plugin 'kien/rainbow_parentheses.vim' " 花里胡哨的彩虹括号 -- 先试试看
Plugin 'tomasr/molokai' " 目前个人喜欢的配色
Plugin 'davidhalter/jedi-vim' " 忘记这玩意干啥了
Plugin 'flazz/vim-colorschemes' " 应该是和代码配色相关的?
Plugin 'scrooloose/nerdtree' " 文件树, 用于浏览当前目录
Plugin 'tpope/vim-commentary' " 辅助快速注释用的
Plugin 'mzlogin/vim-markdown-toc' " 主要是在markdown里面生成目录的
Plugin 'ianva/vim-youdao-translater' " 利用有道云实现翻译
Plugin 'ervandew/supertab' " 比<C+n> 强一些
" Plugin 'esukram/taglist-vim' " 用于浏览函数的
Plugin 'vim-scripts/taglist.vim' " 用于浏览函数的
Plugin 'tpope/vim-fugitive' " 主要是用于看了哪些修改下的跳转, 在使用Git的时候
Plugin 'airblade/vim-gitgutter' " 主要用于直接查看做了哪些修改使用
"Plugin 'scrooloose/syntastic' " 语法检测,尚未配置成功
"Plugin 'ludovicchabant/vim-gutentags' " 用于自动生成ctags的工具, 需要相应的配置
"Plugin 'dense-analysis/ale' " 自动检查语法的工具, 不太好用
Plugin 'itchyny/vim-cursorword' " 显示同一个出现的同一个单词
"Plugin 'lervag/vimtex' " 使用vim来写LaTex -- 试试, 不好用就删除
call vundle#end()
filetype plugin indent on
let g:molokai_original = 1
let g:ackprg = 'ag --vimgrep'
map <C-n> :NERDTreeToggle<CR>
colorscheme molokai
" set tab replace c-n
set wildmenu
set wildmode=full
set completeopt=menu,menuone,preview
inoremap <Tab> <C-n>
" end set
set nobackup
set autowrite
set ruler
set magic
set noswapfile
set hlsearch
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936oset langmenu=zh_CN.UTF-8
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set laststatus=2
set cmdheight=2
set viminfo+=!
set showcmd
set nu
syntax enable
se noro
set nomore
" 与设置缩进4个空格相关
set tabstop=4
set shiftwidth=4
set ts=4 " 设置tab键为4个空格
set softtabstop=4
set expandtab
" set autoindent
" 结束设置缩进4个空格
set incsearch " 可以开启增量搜索,使得在搜索时可以实时匹配输入的字符,按 :set noincsearch 可以关闭增量搜索。
au BufWinLeave * silent mkview
au BufWinEnter * silent loadview
autocmd BufNewFile,BufRead *.md source ~/.vim/forLatex.vim "给自己网站加公式的时候用上的
autocmd BufNewFile,BufRead *.html source ~/.vim/forHtml.vim "给自己网站写时间线的时候用上的
autocmd BufNewFile,BufRead *.tex source ~/.vim/forEquation.vim "给LaTex用的
" 设置 gD 查找函数的最初定义位置
nnoremap <leader>gd :call GotoDef()<CR>
function! GotoDef()
let l:save_cursor = getpos(".")
execute "normal! gD"
if col(".") == 1 && getline(".") =~# '\v\s*<\w+>'
execute "normal! \<C-w>\<C-]>"
endif
if line(".") == 1 && col(".") == 1
execute "normal! \<C-w>T"
endif
call setpos(".", l:save_cursor)
endfunction
" 在整个文件夹中查找函数定义
" set path+=**
" inoremap <expr> <Tab> MyCompletionFunction(getline('.'), '', col('.'))
" autocmd BufNewFile,BufRead *.cpp source ~/.vim/mycompletions.vim
" 设置 ctags
let Tlist_Ctags_Cmd="/opt/homebrew/bin/ctags"
set tags=../*/tags,./*/tags,./tags,./../tags,./../../tags " 没有开启gutentags 前的配置
" set tags=/Users/zhangxiaolong/.cache/tags/*.tags
" set tags=./.tags;,.tags
let Tlist_Show_One_File=1 " 给taglist设置的, 不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow=1 " 同上,如果taglist窗口是最后一个窗口,则退出vim
" let Tlist_Use_Right_Window=1 "同上, 在右侧窗口中显示taglist窗口, 默认为左侧, 我还是比较喜欢左侧的
" 针对花里胡哨的彩虹括号
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" 利用有道云在线实现翻译的一些配置
vnoremap <silent> <C-T> :<C-u>Ydv<CR>
nnoremap <silent> <C-T> :<C-u>Ydc<CR>
noremap <leader>yd :<C-u>Yde<CR>
" set signcolumn=number "在使用vim-gitgutter同时显示修改以及行号所使用, 要求vim版本在8.0以上
" " 配置vim-gutentags -- 暂时不进行配置
" " gutentags 搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归
" let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']
" " 所生成的数据文件的名称
" let g:gutentags_ctags_tagfile = 'tags'
" " 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录
" let s:vim_tags = expand('~/.cache/tags')
" let g:gutentags_cache_dir = s:vim_tags
" " 配置 ctags 的参数
" let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
" let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
" let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
" 检测 ~/.cache/tags 不存在就新建
" if !isdirectory(s:vim_tags)
" silent! call mkdir(s:vim_tags, 'p')
" endif
" 补全python代码, 效果目前不太好,暂时不用
"===============================Jedi==================================
if has('python3')
let g:loaded_youcompleteme = 1 " 判断如果是python3的话,就禁用ycmd。
let g:jedi#force_py_version = 3
let g:pymode_python = 'python3'
endif
"===============================Jedi===================================
" 用于语法检测
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
"
" 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
"
" YouCompleteMe options
"
let g:ycm_register_as_syntastic_checker = 1 "default 1
let g:Show_diagnostics_ui = 1 "default 1
"will put icons in Vim's gutter on lines that have a diagnostic set.
"Turning this off will also turn off the YcmErrorLine and YcmWarningLine
"highlighting
let g:ycm_enable_diagnostic_signs = 1
let g:ycm_enable_diagnostic_highlighting = 0
let g:ycm_always_populate_location_list = 1 "default 0
let g:ycm_open_loclist_on_ycm_diags = 1 "default 1
let g:ycm_complete_in_strings = 1 "default 1
let g:ycm_collect_identifiers_from_tags_files = 0 "default 0
let g:ycm_path_to_python_interpreter = '' "default ''
let g:ycm_server_use_vim_stdout = 0 "default 0 (logging to console)
let g:ycm_server_log_level = 'info' "default info
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' "where to search for .ycm_extra_conf.py if not found
let g:ycm_confirm_extra_conf = 1
let g:ycm_goto_buffer_command = 'same-buffer' "[ 'same-buffer', 'horizontal-split', 'vertical-split', 'new-tab' ]
let g:ycm_filetype_whitelist = { '*': 1 }
let g:ycm_key_invoke_completion = '<C-Space>'
let g:ycm_add_preview_to_completeopt = 0
let g:ycm_show_diagnostics_ui = 0
let g:ycm_server_log_level = 'info'
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_collect_identifiers_from_comments_and_strings = 1
set completeopt=menu,menuone
let g:ycm_semantic_triggers = {
\ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
\ 'cs,lua,javascript': ['re!\w{2}'],
\ }
" end YCM config
" 每行超过100个字符用下划线提示
au BufRead,BufNewFile *.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.hs,*.vim 2match Underlined /.\%101v/
" 用于快速注释的配置
autocmd FileType apache setlocal commentstring=#\ %s
" 更加智能的当前行高亮
autocmd InsertLeave,WinEnter * set cursorline
autocmd InsertEnter,WinLeave * set nocursorline
function! AddTitle() " 增加个人信息
call append(0, "/********************************************************")
call append(1, "* Author : zhangxiaolong")
call append(2, "* Email : [email protected]")
call append(3, "* Last modified : ".strftime("%Y-%m-%d %H:%M"))
call append(4, "* Filename : ".expand("%:t"))
call append(5, "* Description : ")
call append(6, "*************")
endfunction
" 打开文件时恢复光标位置
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" 与vimTex 相关配置
" let g:vimtex_view_method = 'zathura'
" let g:vimtex_view_method = 'TeXShop'
" " Or with a generic interface:
" let g:vimtex_view_general_viewer = 'okular'
" let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
" strongly recommended, you probably don't need to configure anything. If you
" want another compiler backend, you can change it as follows. The list of
" supported backends and further explanation is provided in the documentation,
" see ":help vimtex-compiler".
let g:vimtex_compiler_method = 'latexrun'
" Most VimTeX mappings rely on localleader and this can be changed with the
" following line. The default is usually fine and is the symbol "\".
let maplocalleader = ","
let g:vimtex_compiler_latexmk_engines = {
\ '_' : '-pdf',
\ 'pdflatex' : '-pdf',
\ 'dvipdfex' : '-pdfdvi',
\ 'lualatex' : '-lualatex',
\ 'xelatex' : '-xelatex',
\ 'context (pdftex)' : '-pdf -pdflatex=texexec',
\ 'context (luatex)' : '-pdf -pdflatex=context',
\ 'context (xetex)' : '-pdf -pdflatex=''texexec --xtx''',
\}
"这里是设置latexmk工具的可选参数
let g:vimtex_compiler_latexmk = {
\ 'build_dir' : '',
\ 'callback' : 1,
\ 'continuous' : 1,
\ 'executable' : 'latexmk',
\ 'hooks' : [],
\ 'options' : [
\ '-verbose',
\ '-file-line-error',
\ '-shell-escape',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
" 自定义latex编译
function! TexRun()
if &filetype == 'tex'
execute "rm *.log *.pdf *.atfi *.aux *.toc *.out"
let texFile=expand("%")
execute "!xelatex -interaction=nonstopmode -shell-escape ".texFile
" echo "current file name is:".texFile
endif
endfunction
"定义一些启动函数函数
autocmd BufNewFile *.sh exec ":call SlsqySH()"
autocmd BufNewFile *.cpp exec ":call SlsqyCPP()"
autocmd BufNewFile *.h exec ":call SlsqyCPP()"
autocmd BufNewFile *.hpp exec ":call SlsqyCPP()"
autocmd BufNewFile *.py exec ":call SlsqyPY()"
autocmd BufNewFile *.c exec ":call SlsqyC()"
autocmd BufNewFile *.tex exec ":call SlsqyTex()"
autocmd BufNewFile *.m exec ":call SlsqyOctave()"
autocmd BufNewFile *.uml exec ":call SlsqyUML()"
func SlsqySH()
call setline(1,"\#########################################################################")
call append(line("."), "\# FILE NAME: ".expand("%"))
call append(line(".")+1, "\# AUTHOR: lsqyRobot")
call append(line(".")+2, "\# MAIL: [email protected]")
call append(line(".")+3, "\# CREATED TIME: ".strftime("%c"))
call append(line(".")+4, "\#########################################################################")
call append(line(".")+5, "\#!/bin/zsh")
call append(line(".")+6, "")
autocmd BufNewFile * normal G
endfunc
func SlsqyCPP()
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: lsqyRobot")
call append(line(".")+2, " > Mail: [email protected] ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
call append(line(".")+6, "#include<iostream>")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
autocmd BufNewFile * normal G
endfunc
func SlsqyPY()
call setline(1, "''' ")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: lsqyRobot")
call append(line(".")+2, " > Mail: [email protected] ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, "'''")
call append(line(".")+5, "# -*- coding:utf-8 -*- ")
call append(line(".")+6, "")
autocmd BufNewFile * normal G
endfunc
func SlsqyC()
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: lsqyRobot")
call append(line(".")+2, " > Mail: [email protected] ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
autocmd BufNewFile * normal G
endfunc
func SlsqyTex()
call setline(1, "%*************************************************************************")
call append(line("."), "% > File Name: ".expand("%"))
call append(line(".")+1, "% > Author: lsqyRobot")
call append(line(".")+2, "% > Mail: [email protected] ")
call append(line(".")+3, "% > Created Time: ".strftime("%c"))
call append(line(".")+4, "%***********************************************************************/")
autocmd BufNewFile * normal G
endfunc
func SlsqyOctave()
call setline(1, "%*************************************************************************")
call append(line("."), "% > File Name: ".expand("%"))
call append(line(".")+1, "% > Author: lsqyRobot")
call append(line(".")+2, "% > Mail: [email protected] ")
call append(line(".")+3, "% > Created Time: ".strftime("%c"))
call append(line(".")+4, "%***********************************************************************/")
autocmd BufNewFile * normal G
endfunc
func SlsqyUML()
call setline(1, "/'************************************************************************")
call append(line("."), "% > File Name: ".expand("%"))
call append(line(".")+1, "% > Author: lsqyRobot")
call append(line(".")+2, "% > Mail: [email protected] ")
call append(line(".")+3, "% > Created Time: ".strftime("%c"))
call append(line(".")+4, "%**********************************************************************'/")
autocmd BufNewFile * normal G
endfunc
" " Begin gutentags configure " 目前发现不太好用,以后再试试
"
" " gutentags 搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归
" let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project']
"
" " 所生成的数据文件的名称
" let g:gutentags_ctags_tagfile = '.tags'
"
" " 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录
" let s:vim_tags = expand('~/.cache/tags')
" let g:gutentags_cache_dir = s:vim_tags
"
" " 配置 ctags 的参数
" let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
" let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
" let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
"
" " 检测 ~/.cache/tags 不存在就新建
" if !isdirectory(s:vim_tags)
" silent! call mkdir(s:vim_tags, 'p')
" endif
"
"
" " End gutentags configure