diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2025-07-26 10:41:35 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2025-07-26 10:41:35 +0800 |
| commit | dfb947732c2c57ff16c6e037f7aeda1844628368 (patch) | |
| tree | fe00fd299a8457b24edfb6004def5c36e95e542d /vim/init/plugins.vim | |
| parent | 8200dad3ce2685238f44f6f0371fb6d865122dea (diff) | |
Update
Diffstat (limited to 'vim/init/plugins.vim')
| -rw-r--r-- | vim/init/plugins.vim | 708 |
1 files changed, 3 insertions, 705 deletions
diff --git a/vim/init/plugins.vim b/vim/init/plugins.vim index d8b1307..a96c14d 100644 --- a/vim/init/plugins.vim +++ b/vim/init/plugins.vim | |||
| @@ -10,710 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | call plug#begin('~/.vim/plugged') | 11 | call plug#begin('~/.vim/plugged') |
| 12 | 12 | ||
| 13 | """""""""""""""""""""""""""""" | 13 | Plug 'junegunn/fzf.vim' |
| 14 | " => Set statusline | 14 | nnoremap <leader>sf :Files<CR> |
| 15 | """""""""""""""""""""""""""""" | 15 | nnoremap <leader>sg :GFiles<CR> |
| 16 | Plug 'itchyny/lightline.vim' | ||
| 17 | let g:lightline = { 'colorscheme': 'wombat' } | ||
| 18 | |||
| 19 | """""""""""""""""""""""""""""" | ||
| 20 | " => MRU plugin | ||
| 21 | """""""""""""""""""""""""""""" | ||
| 22 | Plug 'yegappan/mru' | ||
| 23 | let MRU_Max_Entries = 400 | ||
| 24 | nnoremap <leader>f :MRU<CR> | ||
| 25 | |||
| 26 | """""""""""""""""""""""""""""" | ||
| 27 | " => Goyo for focus | ||
| 28 | """""""""""""""""""""""""""""" | ||
| 29 | Plug 'junegunn/goyo.vim' | ||
| 30 | nnoremap <silent> <leader>z :Goyo<CR> | ||
| 31 | |||
| 32 | let g:goyo_width = 80 | ||
| 33 | let g:goyo_height = "85%" | ||
| 34 | let g:goyo_linenr = 0 | ||
| 35 | |||
| 36 | |||
| 37 | function! s:goyo_enter() | ||
| 38 | let b:quitting = 0 | ||
| 39 | let b:quitting_bang = 0 | ||
| 40 | autocmd QuitPre <buffer> let b:quitting = 1 | ||
| 41 | cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q! | ||
| 42 | endfunction | ||
| 43 | |||
| 44 | function! s:goyo_leave() | ||
| 45 | " Quit Vim if this is the only remaining buffer | ||
| 46 | if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 | ||
| 47 | if b:quitting_bang | ||
| 48 | qa! | ||
| 49 | else | ||
| 50 | qa | ||
| 51 | endif | ||
| 52 | endif | ||
| 53 | endfunction | ||
| 54 | |||
| 55 | autocmd! User GoyoEnter call <SID>goyo_enter() | ||
| 56 | autocmd! User GoyoLeave call <SID>goyo_leave() | ||
| 57 | |||
| 58 | |||
| 59 | """""""""""""""""""""""""""""" | ||
| 60 | " => bufExplorer plugin | ||
| 61 | """""""""""""""""""""""""""""" | ||
| 62 | Plug 'jlanzarotta/bufexplorer' | ||
| 63 | let g:bufExplorerDefaultHelp=0 | ||
| 64 | let g:bufExplorerShowRelativePath=1 | ||
| 65 | let g:bufExplorerFindActive=1 | ||
| 66 | let g:bufExplorerSortBy='name' | ||
| 67 | map <leader>q ::BufExplorer<CR> | ||
| 68 | map <leader>Q ::BufExplorerVerticalSplit<CR> | ||
| 69 | |||
| 70 | |||
| 71 | """""""""""""""""""""""""""""" | ||
| 72 | " => Auto set tabline (tal) | ||
| 73 | """""""""""""""""""""""""""""" | ||
| 74 | Plug 'webdevel/tabulous' | ||
| 75 | |||
| 76 | |||
| 77 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 78 | " => Nerd Tree | ||
| 79 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 80 | Plug 'preservim/nerdtree' | ||
| 81 | let g:NERDTreeWinPos = "left" | ||
| 82 | let NERDTreeShowHidden=0 | ||
| 83 | let NERDTreeQuitOnOpen=1 | ||
| 84 | let NERDTreeIgnore = ['\.pyc$', '__pycache__'] | ||
| 85 | let g:NERDTreeWinSize=35 | ||
| 86 | map <C-n> :NERDTreeToggle<cr> | ||
| 87 | map <leader>nb :NERDTreeFromBookmark<Space> | ||
| 88 | map <leader>nf :NERDTreeFind<cr> | ||
| 89 | |||
| 90 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 91 | " => vim-surrounded | ||
| 92 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 93 | Plug 'tpope/vim-surround' | ||
| 94 | vmap [ S[ | ||
| 95 | |||
| 96 | |||
| 97 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 98 | " => Markdown | ||
| 99 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 100 | Plug 'godlygeek/tabular' | ||
| 101 | Plug 'preservim/vim-markdown' | ||
| 102 | |||
| 103 | |||
| 104 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 105 | " => ALE (Asynchronous Lint Engine) | ||
| 106 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
| 107 | Plug 'dense-analysis/ale' | ||
| 108 | let g:ale_sign_column_always = 1 | ||
| 109 | let g:ale_sign_error = '>>' | ||
| 110 | let g:ale_sign_warning = '--' | ||
| 111 | |||
| 112 | " show errors or warnings in my statusline | ||
| 113 | let g:airline#extensions#ale#enabled = 1 | ||
| 114 | |||
| 115 | " use quickfix list instead of the loclist | ||
| 116 | let g:ale_set_loclist = 0 | ||
| 117 | let g:ale_set_quickfix = 1 | ||
| 118 | |||
| 119 | |||
| 120 | ""---------------------------------------------------------------------- | ||
| 121 | "" 默认情况下的分组,可以再前面覆盖之 | ||
| 122 | ""---------------------------------------------------------------------- | ||
| 123 | "if !exists('g:bundle_group') | ||
| 124 | " let g:bundle_group = ['basic', 'tags', 'enhanced', 'filetypes', 'textobj'] | ||
| 125 | " let g:bundle_group += ['tags', 'airline', 'nerdtree', 'ale', 'echodoc'] | ||
| 126 | " let g:bundle_group += ['leaderf'] | ||
| 127 | "endif | ||
| 128 | " | ||
| 129 | " | ||
| 130 | ""---------------------------------------------------------------------- | ||
| 131 | "" 计算当前 vim-init 的子路径 | ||
| 132 | ""---------------------------------------------------------------------- | ||
| 133 | "let s:home = fnamemodify(resolve(expand('<sfile>:p')), ':h:h') | ||
| 134 | " | ||
| 135 | "function! s:path(path) | ||
| 136 | " let path = expand(s:home . '/' . a:path ) | ||
| 137 | " return substitute(path, '\\', '/', 'g') | ||
| 138 | "endfunc | ||
| 139 | " | ||
| 140 | " | ||
| 141 | ""---------------------------------------------------------------------- | ||
| 142 | "" 在 ~/.vim/bundles 下安装插件 | ||
| 143 | ""---------------------------------------------------------------------- | ||
| 144 | "call plug#begin(get(g:, 'bundle_home', '~/.vim/bundles')) | ||
| 145 | " | ||
| 146 | " | ||
| 147 | ""---------------------------------------------------------------------- | ||
| 148 | "" 默认插件 | ||
| 149 | ""---------------------------------------------------------------------- | ||
| 150 | " | ||
| 151 | "" 全文快速移动,<leader><leader>f{char} 即可触发 | ||
| 152 | "Plug 'easymotion/vim-easymotion' | ||
| 153 | " | ||
| 154 | "" 文件浏览器,代替 netrw | ||
| 155 | "Plug 'justinmk/vim-dirvish' | ||
| 156 | " | ||
| 157 | "" 表格对齐,使用命令 Tabularize | ||
| 158 | "Plug 'godlygeek/tabular', { 'on': 'Tabularize' } | ||
| 159 | " | ||
| 160 | "" Diff 增强,支持 histogram / patience 等更科学的 diff 算法 | ||
| 161 | "Plug 'chrisbra/vim-diff-enhanced' | ||
| 162 | " | ||
| 163 | " | ||
| 164 | ""---------------------------------------------------------------------- | ||
| 165 | "" Dirvish 设置:自动排序并隐藏文件,同时定位到相关文件 | ||
| 166 | "" 这个排序函数可以将目录排在前面,文件排在后面,并且按照字母顺序排序 | ||
| 167 | "" 比默认的纯按照字母排序更友好点。 | ||
| 168 | ""---------------------------------------------------------------------- | ||
| 169 | "function! s:setup_dirvish() | ||
| 170 | " if &buftype != 'nofile' && &filetype != 'dirvish' | ||
| 171 | " return | ||
| 172 | " endif | ||
| 173 | " if has('nvim') | ||
| 174 | " return | ||
| 175 | " endif | ||
| 176 | " " 取得光标所在行的文本(当前选中的文件名) | ||
| 177 | " let text = getline('.') | ||
| 178 | " if ! get(g:, 'dirvish_hide_visible', 0) | ||
| 179 | " exec 'silent keeppatterns g@\v[\/]\.[^\/]+[\/]?$@d _' | ||
| 180 | " endif | ||
| 181 | " " 排序文件名 | ||
| 182 | " exec 'sort ,^.*[\/],' | ||
| 183 | " let name = '^' . escape(text, '.*[]~\') . '[/*|@=|\\*]\=\%($\|\s\+\)' | ||
| 184 | " " 定位到之前光标处的文件 | ||
| 185 | " call search(name, 'wc') | ||
| 186 | " noremap <silent><buffer> ~ :Dirvish ~<cr> | ||
| 187 | " noremap <buffer> % :e % | ||
| 188 | "endfunc | ||
| 189 | " | ||
| 190 | "augroup MyPluginSetup | ||
| 191 | " autocmd! | ||
| 192 | " autocmd FileType dirvish call s:setup_dirvish() | ||
| 193 | "augroup END | ||
| 194 | " | ||
| 195 | " | ||
| 196 | ""---------------------------------------------------------------------- | ||
| 197 | "" 基础插件 | ||
| 198 | ""---------------------------------------------------------------------- | ||
| 199 | "if index(g:bundle_group, 'basic') >= 0 | ||
| 200 | " | ||
| 201 | " " 展示开始画面,显示最近编辑过的文件 | ||
| 202 | " Plug 'mhinz/vim-startify' | ||
| 203 | " | ||
| 204 | " " 一次性安装一大堆 colorscheme | ||
| 205 | " Plug 'flazz/vim-colorschemes' | ||
| 206 | " | ||
| 207 | " " 支持库,给其他插件用的函数库 | ||
| 208 | " Plug 'xolox/vim-misc' | ||
| 209 | " | ||
| 210 | " " 用于在侧边符号栏显示 marks (ma-mz 记录的位置) | ||
| 211 | " Plug 'kshenoy/vim-signature' | ||
| 212 | " | ||
| 213 | " " 用于在侧边符号栏显示 git/svn 的 diff | ||
| 214 | " Plug 'mhinz/vim-signify' | ||
| 215 | " | ||
| 216 | " " 根据 quickfix 中匹配到的错误信息,高亮对应文件的错误行 | ||
| 217 | " " 使用 :RemoveErrorMarkers 命令或者 <space>ha 清除错误 | ||
| 218 | " Plug 'mh21/errormarker.vim' | ||
| 219 | " | ||
| 220 | " " 使用 ALT+e 会在不同窗口/标签上显示 A/B/C 等编号,然后字母直接跳转 | ||
| 221 | " Plug 't9md/vim-choosewin' | ||
| 222 | " | ||
| 223 | " " 提供基于 TAGS 的定义预览,函数参数预览,quickfix 预览 | ||
| 224 | " Plug 'skywind3000/vim-preview' | ||
| 225 | " | ||
| 226 | " " Git 支持 | ||
| 227 | " Plug 'tpope/vim-fugitive' | ||
| 228 | " | ||
| 229 | " " 使用 ALT+E 来选择窗口 | ||
| 230 | " nmap <m-e> <Plug>(choosewin) | ||
| 231 | " | ||
| 232 | " " 默认不显示 startify | ||
| 233 | " let g:startify_disable_at_vimenter = 1 | ||
| 234 | " let g:startify_session_dir = '~/.vim/session' | ||
| 235 | " | ||
| 236 | " " 使用 <space>ha 清除 errormarker 标注的错误 | ||
| 237 | " noremap <silent><space>ha :RemoveErrorMarkers<cr> | ||
| 238 | " | ||
| 239 | " " signify 调优 | ||
| 240 | " let g:signify_vcs_list = ['git', 'svn'] | ||
| 241 | " let g:signify_sign_add = '+' | ||
| 242 | " let g:signify_sign_delete = '_' | ||
| 243 | " let g:signify_sign_delete_first_line = '‾' | ||
| 244 | " let g:signify_sign_change = '~' | ||
| 245 | " let g:signify_sign_changedelete = g:signify_sign_change | ||
| 246 | " | ||
| 247 | " " git 仓库使用 histogram 算法进行 diff | ||
| 248 | " let g:signify_vcs_cmds = { | ||
| 249 | " \ 'git': 'git diff --no-color --diff-algorithm=histogram --no-ext-diff -U0 -- %f', | ||
| 250 | " \} | ||
| 251 | "endif | ||
| 252 | " | ||
| 253 | " | ||
| 254 | ""---------------------------------------------------------------------- | ||
| 255 | "" 增强插件 | ||
| 256 | ""---------------------------------------------------------------------- | ||
| 257 | "if index(g:bundle_group, 'enhanced') >= 0 | ||
| 258 | " | ||
| 259 | " " 用 v 选中一个区域后,ALT_+/- 按分隔符扩大/缩小选区 | ||
| 260 | " Plug 'terryma/vim-expand-region' | ||
| 261 | " | ||
| 262 | " " 快速文件搜索 | ||
| 263 | " Plug 'junegunn/fzf' | ||
| 264 | " | ||
| 265 | " " 给不同语言提供字典补全,插入模式下 c-x c-k 触发 | ||
| 266 | " Plug 'asins/vim-dict' | ||
| 267 | " | ||
| 268 | " " 使用 :FlyGrep 命令进行实时 grep | ||
| 269 | " Plug 'wsdjeg/FlyGrep.vim' | ||
| 270 | " | ||
| 271 | " " 使用 :CtrlSF 命令进行模仿 sublime 的 grep | ||
| 272 | " Plug 'dyng/ctrlsf.vim' | ||
| 273 | " | ||
| 274 | " " 配对括号和引号自动补全 | ||
| 275 | " Plug 'Raimondi/delimitMate' | ||
| 276 | " | ||
| 277 | " " 提供 gist 接口 | ||
| 278 | " Plug 'lambdalisue/vim-gista', { 'on': 'Gista' } | ||
| 279 | " | ||
| 280 | " " ALT_+/- 用于按分隔符扩大缩小 v 选区 | ||
| 281 | " map <m-=> <Plug>(expand_region_expand) | ||
| 282 | " map <m--> <Plug>(expand_region_shrink) | ||
| 283 | "endif | ||
| 284 | " | ||
| 285 | " | ||
| 286 | ""---------------------------------------------------------------------- | ||
| 287 | "" 自动生成 ctags/gtags,并提供自动索引功能 | ||
| 288 | "" 不在 git/svn 内的项目,需要在项目根目录 touch 一个空的 .root 文件 | ||
| 289 | "" See https://zhuanlan.zhihu.com/p/36279445 | ||
| 290 | ""---------------------------------------------------------------------- | ||
| 291 | "if index(g:bundle_group, 'tags') >= 0 | ||
| 292 | " | ||
| 293 | " " 提供 ctags/gtags 后台数据库自动更新功能 | ||
| 294 | " Plug 'ludovicchabant/vim-gutentags' | ||
| 295 | " | ||
| 296 | " " 提供 GscopeFind 命令并自动处理好 gtags 数据库切换 | ||
| 297 | " " 支持光标移动到符号名上:<leader>cg 查看定义,<leader>cs 查看引用 | ||
| 298 | " Plug 'skywind3000/gutentags_plus' | ||
| 299 | " | ||
| 300 | " " 设定项目目录标志:除了 .git/.svn 外,还有 .root 文件 | ||
| 301 | " let g:gutentags_project_root = ['.root'] | ||
| 302 | " let g:gutentags_ctags_tagfile = '.tags' | ||
| 303 | " | ||
| 304 | " " 默认生成的数据文件集中到 ~/.cache/tags 避免污染项目目录,好清理 | ||
| 305 | " let g:gutentags_cache_dir = expand('~/.cache/tags') | ||
| 306 | " | ||
| 307 | " " 默认禁用自动生成 | ||
| 308 | " let g:gutentags_modules = [] | ||
| 309 | " | ||
| 310 | " " 如果有 ctags 可执行就允许动态生成 ctags 文件 | ||
| 311 | " if executable('ctags') | ||
| 312 | " let g:gutentags_modules += ['ctags'] | ||
| 313 | " endif | ||
| 314 | " | ||
| 315 | " " 如果有 gtags 可执行就允许动态生成 gtags 数据库 | ||
| 316 | " if executable('gtags') && executable('gtags-cscope') | ||
| 317 | " let g:gutentags_modules += ['gtags_cscope'] | ||
| 318 | " endif | ||
| 319 | " | ||
| 320 | " " 设置 ctags 的参数 | ||
| 321 | " let g:gutentags_ctags_extra_args = [] | ||
| 322 | " let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q'] | ||
| 323 | " let g:gutentags_ctags_extra_args += ['--c++-kinds=+px'] | ||
| 324 | " let g:gutentags_ctags_extra_args += ['--c-kinds=+px'] | ||
| 325 | " | ||
| 326 | " " 使用 universal-ctags 的话需要下面这行,请反注释 | ||
| 327 | " " let g:gutentags_ctags_extra_args += ['--output-format=e-ctags'] | ||
| 328 | " | ||
| 329 | " " 禁止 gutentags 自动链接 gtags 数据库 | ||
| 330 | " let g:gutentags_auto_add_gtags_cscope = 0 | ||
| 331 | "endif | ||
| 332 | " | ||
| 333 | " | ||
| 334 | ""---------------------------------------------------------------------- | ||
| 335 | "" 文本对象:textobj 全家桶 | ||
| 336 | ""---------------------------------------------------------------------- | ||
| 337 | "if index(g:bundle_group, 'textobj') >= 0 | ||
| 338 | " | ||
| 339 | " " 基础插件:提供让用户方便的自定义文本对象的接口 | ||
| 340 | " Plug 'kana/vim-textobj-user' | ||
| 341 | " | ||
| 342 | " " indent 文本对象:ii/ai 表示当前缩进,vii 选中当缩进,cii 改写缩进 | ||
| 343 | " Plug 'kana/vim-textobj-indent' | ||
| 344 | " | ||
| 345 | " " 语法文本对象:iy/ay 基于语法的文本对象 | ||
| 346 | " Plug 'kana/vim-textobj-syntax' | ||
| 347 | " | ||
| 348 | " " 函数文本对象:if/af 支持 c/c++/vim/java | ||
| 349 | " Plug 'kana/vim-textobj-function', { 'for':['c', 'cpp', 'vim', 'java'] } | ||
| 350 | " | ||
| 351 | " " 参数文本对象:i,/a, 包括参数或者列表元素 | ||
| 352 | " Plug 'sgur/vim-textobj-parameter' | ||
| 353 | " | ||
| 354 | " " 提供 python 相关文本对象,if/af 表示函数,ic/ac 表示类 | ||
| 355 | " Plug 'bps/vim-textobj-python', {'for': 'python'} | ||
| 356 | " | ||
| 357 | " " 提供 uri/url 的文本对象,iu/au 表示 | ||
| 358 | " Plug 'jceb/vim-textobj-uri' | ||
| 359 | "endif | ||
| 360 | " | ||
| 361 | " | ||
| 362 | ""---------------------------------------------------------------------- | ||
| 363 | "" 文件类型扩展 | ||
| 364 | ""---------------------------------------------------------------------- | ||
| 365 | "if index(g:bundle_group, 'filetypes') >= 0 | ||
| 366 | " | ||
| 367 | " " powershell 脚本文件的语法高亮 | ||
| 368 | " Plug 'pprovost/vim-ps1', { 'for': 'ps1' } | ||
| 369 | " | ||
| 370 | " " lua 语法高亮增强 | ||
| 371 | " Plug 'tbastos/vim-lua', { 'for': 'lua' } | ||
| 372 | " | ||
| 373 | " " C++ 语法高亮增强,支持 11/14/17 标准 | ||
| 374 | " Plug 'octol/vim-cpp-enhanced-highlight', { 'for': ['c', 'cpp'] } | ||
| 375 | " | ||
| 376 | " " 额外语法文件 | ||
| 377 | " Plug 'justinmk/vim-syntax-extra', { 'for': ['c', 'bison', 'flex', 'cpp'] } | ||
| 378 | " | ||
| 379 | " " python 语法文件增强 | ||
| 380 | " Plug 'vim-python/python-syntax', { 'for': ['python'] } | ||
| 381 | " | ||
| 382 | " " rust 语法增强 | ||
| 383 | " Plug 'rust-lang/rust.vim', { 'for': 'rust' } | ||
| 384 | " | ||
| 385 | " " vim org-mode | ||
| 386 | " Plug 'jceb/vim-orgmode', { 'for': 'org' } | ||
| 387 | "endif | ||
| 388 | " | ||
| 389 | " | ||
| 390 | ""---------------------------------------------------------------------- | ||
| 391 | "" airline | ||
| 392 | ""---------------------------------------------------------------------- | ||
| 393 | "if index(g:bundle_group, 'airline') >= 0 | ||
| 394 | " Plug 'vim-airline/vim-airline' | ||
| 395 | " Plug 'vim-airline/vim-airline-themes' | ||
| 396 | " let g:airline_left_sep = '' | ||
| 397 | " let g:airline_left_alt_sep = '' | ||
| 398 | " let g:airline_right_sep = '' | ||
| 399 | " let g:airline_right_alt_sep = '' | ||
| 400 | " let g:airline_powerline_fonts = 0 | ||
| 401 | " let g:airline_exclude_preview = 1 | ||
| 402 | " let g:airline_section_b = '%n' | ||
| 403 | " let g:airline_theme='deus' | ||
| 404 | " let g:airline#extensions#branch#enabled = 0 | ||
| 405 | " let g:airline#extensions#syntastic#enabled = 0 | ||
| 406 | " let g:airline#extensions#fugitiveline#enabled = 0 | ||
| 407 | " let g:airline#extensions#csv#enabled = 0 | ||
| 408 | " let g:airline#extensions#vimagit#enabled = 0 | ||
| 409 | "endif | ||
| 410 | " | ||
| 411 | " | ||
| 412 | ""---------------------------------------------------------------------- | ||
| 413 | "" NERDTree | ||
| 414 | ""---------------------------------------------------------------------- | ||
| 415 | "if index(g:bundle_group, 'nerdtree') >= 0 | ||
| 416 | " Plug 'scrooloose/nerdtree', {'on': ['NERDTree', 'NERDTreeFocus', 'NERDTreeToggle', 'NERDTreeCWD', 'NERDTreeFind'] } | ||
| 417 | " Plug 'tiagofumo/vim-nerdtree-syntax-highlight' | ||
| 418 | " let g:NERDTreeMinimalUI = 1 | ||
| 419 | " let g:NERDTreeDirArrows = 1 | ||
| 420 | " let g:NERDTreeHijackNetrw = 0 | ||
| 421 | " noremap <space>nn :NERDTree<cr> | ||
| 422 | " noremap <space>no :NERDTreeFocus<cr> | ||
| 423 | " noremap <space>nm :NERDTreeMirror<cr> | ||
| 424 | " noremap <space>nt :NERDTreeToggle<cr> | ||
| 425 | "endif | ||
| 426 | " | ||
| 427 | " | ||
| 428 | ""---------------------------------------------------------------------- | ||
| 429 | "" LanguageTool 语法检查 | ||
| 430 | ""---------------------------------------------------------------------- | ||
| 431 | "if index(g:bundle_group, 'grammer') >= 0 | ||
| 432 | " Plug 'rhysd/vim-grammarous' | ||
| 433 | " noremap <space>rg :GrammarousCheck --lang=en-US --no-move-to-first-error --no-preview<cr> | ||
| 434 | " map <space>rr <Plug>(grammarous-open-info-window) | ||
| 435 | " map <space>rv <Plug>(grammarous-move-to-info-window) | ||
| 436 | " map <space>rs <Plug>(grammarous-reset) | ||
| 437 | " map <space>rx <Plug>(grammarous-close-info-window) | ||
| 438 | " map <space>rm <Plug>(grammarous-remove-error) | ||
| 439 | " map <space>rd <Plug>(grammarous-disable-rule) | ||
| 440 | " map <space>rn <Plug>(grammarous-move-to-next-error) | ||
| 441 | " map <space>rp <Plug>(grammarous-move-to-previous-error) | ||
| 442 | "endif | ||
| 443 | " | ||
| 444 | " | ||
| 445 | ""---------------------------------------------------------------------- | ||
| 446 | "" ale:动态语法检查 | ||
| 447 | ""---------------------------------------------------------------------- | ||
| 448 | "if index(g:bundle_group, 'ale') >= 0 | ||
| 449 | " Plug 'w0rp/ale' | ||
| 450 | " | ||
| 451 | " " 设定延迟和提示信息 | ||
| 452 | " let g:ale_completion_delay = 500 | ||
| 453 | " let g:ale_echo_delay = 20 | ||
| 454 | " let g:ale_lint_delay = 500 | ||
| 455 | " let g:ale_echo_msg_format = '[%linter%] %code: %%s' | ||
| 456 | " | ||
| 457 | " " 设定检测的时机:normal 模式文字改变,或者离开 insert模式 | ||
| 458 | " " 禁用默认 INSERT 模式下改变文字也触发的设置,太频繁外,还会让补全窗闪烁 | ||
| 459 | " let g:ale_lint_on_text_changed = 'normal' | ||
| 460 | " let g:ale_lint_on_insert_leave = 1 | ||
| 461 | " | ||
| 462 | " " 在 linux/mac 下降低语法检查程序的进程优先级(不要卡到前台进程) | ||
| 463 | " if has('win32') == 0 && has('win64') == 0 && has('win32unix') == 0 | ||
| 464 | " let g:ale_command_wrapper = 'nice -n5' | ||
| 465 | " endif | ||
| 466 | " | ||
| 467 | " " 允许 airline 集成 | ||
| 468 | " let g:airline#extensions#ale#enabled = 1 | ||
| 469 | " | ||
| 470 | " " 编辑不同文件类型需要的语法检查器 | ||
| 471 | " let g:ale_linters = { | ||
| 472 | " \ 'c': ['gcc', 'cppcheck'], | ||
| 473 | " \ 'cpp': ['gcc', 'cppcheck'], | ||
| 474 | " \ 'python': ['flake8', 'pylint'], | ||
| 475 | " \ 'lua': ['luac'], | ||
| 476 | " \ 'go': ['go build', 'gofmt'], | ||
| 477 | " \ 'java': ['javac'], | ||
| 478 | " \ 'javascript': ['eslint'], | ||
| 479 | " \ } | ||
| 480 | " | ||
| 481 | " | ||
| 482 | " " 获取 pylint, flake8 的配置文件,在 vim-init/tools/conf 下面 | ||
| 483 | " function s:lintcfg(name) | ||
| 484 | " let conf = s:path('tools/conf/') | ||
| 485 | " let path1 = conf . a:name | ||
| 486 | " let path2 = expand('~/.vim/linter/'. a:name) | ||
| 487 | " if filereadable(path2) | ||
| 488 | " return path2 | ||
| 489 | " endif | ||
| 490 | " return shellescape(filereadable(path2)? path2 : path1) | ||
| 491 | " endfunc | ||
| 492 | " | ||
| 493 | " " 设置 flake8/pylint 的参数 | ||
| 494 | " let g:ale_python_flake8_options = '--conf='.s:lintcfg('flake8.conf') | ||
| 495 | " let g:ale_python_pylint_options = '--rcfile='.s:lintcfg('pylint.conf') | ||
| 496 | " let g:ale_python_pylint_options .= ' --disable=W' | ||
| 497 | " let g:ale_c_gcc_options = '-Wall -O2 -std=c99' | ||
| 498 | " let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14' | ||
| 499 | " let g:ale_c_cppcheck_options = '' | ||
| 500 | " let g:ale_cpp_cppcheck_options = '' | ||
| 501 | " | ||
| 502 | " let g:ale_linters.text = ['textlint', 'write-good', 'languagetool'] | ||
| 503 | " | ||
| 504 | " " 如果没有 gcc 只有 clang 时(FreeBSD) | ||
| 505 | " if executable('gcc') == 0 && executable('clang') | ||
| 506 | " let g:ale_linters.c += ['clang'] | ||
| 507 | " let g:ale_linters.cpp += ['clang'] | ||
| 508 | " endif | ||
| 509 | "endif | ||
| 510 | " | ||
| 511 | " | ||
| 512 | ""---------------------------------------------------------------------- | ||
| 513 | "" echodoc:搭配 YCM/deoplete 在底部显示函数参数 | ||
| 514 | ""---------------------------------------------------------------------- | ||
| 515 | "if index(g:bundle_group, 'echodoc') >= 0 | ||
| 516 | " Plug 'Shougo/echodoc.vim' | ||
| 517 | " set noshowmode | ||
| 518 | " let g:echodoc#enable_at_startup = 1 | ||
| 519 | "endif | ||
| 520 | " | ||
| 521 | " | ||
| 522 | ""---------------------------------------------------------------------- | ||
| 523 | "" LeaderF:CtrlP / FZF 的超级代替者,文件模糊匹配,tags/函数名 选择 | ||
| 524 | ""---------------------------------------------------------------------- | ||
| 525 | "if index(g:bundle_group, 'leaderf') >= 0 | ||
| 526 | " " 如果 vim 支持 python 则启用 Leaderf | ||
| 527 | " if has('python') || has('python3') | ||
| 528 | " Plug 'Yggdroot/LeaderF' | ||
| 529 | " | ||
| 530 | " " CTRL+p 打开文件模糊匹配 | ||
| 531 | " let g:Lf_ShortcutF = '<c-p>' | ||
| 532 | " | ||
| 533 | " " ALT+n 打开 buffer 模糊匹配 | ||
| 534 | " let g:Lf_ShortcutB = '<m-n>' | ||
| 535 | " | ||
| 536 | " " CTRL+n 打开最近使用的文件 MRU,进行模糊匹配 | ||
| 537 | " noremap <c-n> :LeaderfMru<cr> | ||
| 538 | " | ||
| 539 | " " ALT+p 打开函数列表,按 i 进入模糊匹配,ESC 退出 | ||
| 540 | " noremap <m-p> :LeaderfFunction!<cr> | ||
| 541 | " | ||
| 542 | " " ALT+SHIFT+p 打开 tag 列表,i 进入模糊匹配,ESC退出 | ||
| 543 | " noremap <m-P> :LeaderfBufTag!<cr> | ||
| 544 | " | ||
| 545 | " " ALT+n 打开 buffer 列表进行模糊匹配 | ||
| 546 | " noremap <m-n> :LeaderfBuffer<cr> | ||
| 547 | " | ||
| 548 | " " ALT+m 全局 tags 模糊匹配 | ||
| 549 | " noremap <m-m> :LeaderfTag<cr> | ||
| 550 | " | ||
| 551 | " " 最大历史文件保存 2048 个 | ||
| 552 | " let g:Lf_MruMaxFiles = 2048 | ||
| 553 | " | ||
| 554 | " " ui 定制 | ||
| 555 | " let g:Lf_StlSeparator = { 'left': '', 'right': '', 'font': '' } | ||
| 556 | " | ||
| 557 | " " 如何识别项目目录,从当前文件目录向父目录递归知道碰到下面的文件/目录 | ||
| 558 | " let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git'] | ||
| 559 | " let g:Lf_WorkingDirectoryMode = 'Ac' | ||
| 560 | " let g:Lf_WindowHeight = 0.30 | ||
| 561 | " let g:Lf_CacheDirectory = expand('~/.vim/cache') | ||
| 562 | " | ||
| 563 | " " 显示绝对路径 | ||
| 564 | " let g:Lf_ShowRelativePath = 0 | ||
| 565 | " | ||
| 566 | " " 隐藏帮助 | ||
| 567 | " let g:Lf_HideHelp = 1 | ||
| 568 | " | ||
| 569 | " " 模糊匹配忽略扩展名 | ||
| 570 | " let g:Lf_WildIgnore = { | ||
| 571 | " \ 'dir': ['.svn','.git','.hg'], | ||
| 572 | " \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]'] | ||
| 573 | " \ } | ||
| 574 | " | ||
| 575 | " " MRU 文件忽略扩展名 | ||
| 576 | " let g:Lf_MruFileExclude = ['*.so', '*.exe', '*.py[co]', '*.sw?', '~$*', '*.bak', '*.tmp', '*.dll'] | ||
| 577 | " let g:Lf_StlColorscheme = 'powerline' | ||
| 578 | " | ||
| 579 | " " 禁用 function/buftag 的预览功能,可以手动用 p 预览 | ||
| 580 | " let g:Lf_PreviewResult = {'Function':0, 'BufTag':0} | ||
| 581 | " | ||
| 582 | " " 使用 ESC 键可以直接退出 leaderf 的 normal 模式 | ||
| 583 | " let g:Lf_NormalMap = { | ||
| 584 | " \ "File": [["<ESC>", ':exec g:Lf_py "fileExplManager.quit()"<CR>']], | ||
| 585 | " \ "Buffer": [["<ESC>", ':exec g:Lf_py "bufExplManager.quit()"<cr>']], | ||
| 586 | " \ "Mru": [["<ESC>", ':exec g:Lf_py "mruExplManager.quit()"<cr>']], | ||
| 587 | " \ "Tag": [["<ESC>", ':exec g:Lf_py "tagExplManager.quit()"<cr>']], | ||
| 588 | " \ "BufTag": [["<ESC>", ':exec g:Lf_py "bufTagExplManager.quit()"<cr>']], | ||
| 589 | " \ "Function": [["<ESC>", ':exec g:Lf_py "functionExplManager.quit()"<cr>']], | ||
| 590 | " \ } | ||
| 591 | " | ||
| 592 | " else | ||
| 593 | " " 不支持 python ,使用 CtrlP 代替 | ||
| 594 | " Plug 'ctrlpvim/ctrlp.vim' | ||
| 595 | " | ||
| 596 | " " 显示函数列表的扩展插件 | ||
| 597 | " Plug 'tacahiroy/ctrlp-funky' | ||
| 598 | " | ||
| 599 | " " 忽略默认键位 | ||
| 600 | " let g:ctrlp_map = '' | ||
| 601 | " | ||
| 602 | " " 模糊匹配忽略 | ||
| 603 | " let g:ctrlp_custom_ignore = { | ||
| 604 | " \ 'dir': '\v[\/]\.(git|hg|svn)$', | ||
| 605 | " \ 'file': '\v\.(exe|so|dll|mp3|wav|sdf|suo|mht)$', | ||
| 606 | " \ 'link': 'some_bad_symbolic_links', | ||
| 607 | " \ } | ||
| 608 | " | ||
| 609 | " " 项目标志 | ||
| 610 | " let g:ctrlp_root_markers = ['.project', '.root', '.svn', '.git'] | ||
| 611 | " let g:ctrlp_working_path = 0 | ||
| 612 | " | ||
| 613 | " " CTRL+p 打开文件模糊匹配 | ||
| 614 | " noremap <c-p> :CtrlP<cr> | ||
| 615 | " | ||
| 616 | " " CTRL+n 打开最近访问过的文件的匹配 | ||
| 617 | " noremap <c-n> :CtrlPMRUFiles<cr> | ||
| 618 | " | ||
| 619 | " " ALT+p 显示当前文件的函数列表 | ||
| 620 | " noremap <m-p> :CtrlPFunky<cr> | ||
| 621 | " | ||
| 622 | " " ALT+n 匹配 buffer | ||
| 623 | " noremap <m-n> :CtrlPBuffer<cr> | ||
| 624 | " endif | ||
| 625 | "endif | ||
| 626 | " | ||
| 627 | " | ||
| 628 | ""---------------------------------------------------------------------- | ||
| 629 | "" 结束插件安装 | ||
| 630 | ""---------------------------------------------------------------------- | ||
| 631 | "call plug#end() | ||
| 632 | " | ||
| 633 | " | ||
| 634 | " | ||
| 635 | ""---------------------------------------------------------------------- | ||
| 636 | "" YouCompleteMe 默认设置:YCM 需要你另外手动编译安装 | ||
| 637 | ""---------------------------------------------------------------------- | ||
| 638 | " | ||
| 639 | "" 禁用预览功能:扰乱视听 | ||
| 640 | "let g:ycm_add_preview_to_completeopt = 0 | ||
| 641 | " | ||
| 642 | "" 禁用诊断功能:我们用前面更好用的 ALE 代替 | ||
| 643 | "let g:ycm_show_diagnostics_ui = 0 | ||
| 644 | "let g:ycm_server_log_level = 'info' | ||
| 645 | "let g:ycm_min_num_identifier_candidate_chars = 2 | ||
| 646 | "let g:ycm_collect_identifiers_from_comments_and_strings = 1 | ||
| 647 | "let g:ycm_complete_in_strings=1 | ||
| 648 | "let g:ycm_key_invoke_completion = '<c-z>' | ||
| 649 | "set completeopt=menu,menuone,noselect | ||
| 650 | " | ||
| 651 | "" noremap <c-z> <NOP> | ||
| 652 | " | ||
| 653 | "" 两个字符自动触发语义补全 | ||
| 654 | "let g:ycm_semantic_triggers = { | ||
| 655 | " \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'], | ||
| 656 | " \ 'cs,lua,javascript': ['re!\w{2}'], | ||
| 657 | " \ } | ||
| 658 | " | ||
| 659 | " | ||
| 660 | ""---------------------------------------------------------------------- | ||
| 661 | "" Ycm 白名单(非名单内文件不启用 YCM),避免打开个 1MB 的 txt 分析半天 | ||
| 662 | ""---------------------------------------------------------------------- | ||
| 663 | "let g:ycm_filetype_whitelist = { | ||
| 664 | " \ "c":1, | ||
| 665 | " \ "cpp":1, | ||
| 666 | " \ "objc":1, | ||
| 667 | " \ "objcpp":1, | ||
| 668 | " \ "python":1, | ||
| 669 | " \ "java":1, | ||
| 670 | " \ "javascript":1, | ||
| 671 | " \ "coffee":1, | ||
| 672 | " \ "vim":1, | ||
| 673 | " \ "go":1, | ||
| 674 | " \ "cs":1, | ||
| 675 | " \ "lua":1, | ||
| 676 | " \ "perl":1, | ||
| 677 | " \ "perl6":1, | ||
| 678 | " \ "php":1, | ||
| 679 | " \ "ruby":1, | ||
| 680 | " \ "rust":1, | ||
| 681 | " \ "erlang":1, | ||
| 682 | " \ "asm":1, | ||
| 683 | " \ "nasm":1, | ||
| 684 | " \ "masm":1, | ||
| 685 | " \ "tasm":1, | ||
| 686 | " \ "asm68k":1, | ||
| 687 | " \ "asmh8300":1, | ||
| 688 | " \ "asciidoc":1, | ||
| 689 | " \ "basic":1, | ||
| 690 | " \ "vb":1, | ||
| 691 | " \ "make":1, | ||
| 692 | " \ "cmake":1, | ||
| 693 | " \ "html":1, | ||
| 694 | " \ "css":1, | ||
| 695 | " \ "less":1, | ||
| 696 | " \ "json":1, | ||
| 697 | " \ "cson":1, | ||
| 698 | " \ "typedscript":1, | ||
| 699 | " \ "haskell":1, | ||
| 700 | " \ "lhaskell":1, | ||
| 701 | " \ "lisp":1, | ||
| 702 | " \ "scheme":1, | ||
| 703 | " \ "sdl":1, | ||
| 704 | " \ "sh":1, | ||
| 705 | " \ "zsh":1, | ||
| 706 | " \ "bash":1, | ||
| 707 | " \ "man":1, | ||
| 708 | " \ "markdown":1, | ||
| 709 | " \ "matlab":1, | ||
| 710 | " \ "maxima":1, | ||
| 711 | " \ "dosini":1, | ||
| 712 | " \ "conf":1, | ||
| 713 | " \ "config":1, | ||
| 714 | " \ "zimbu":1, | ||
| 715 | " \ "ps1":1, | ||
| 716 | " \ } | ||
| 717 | |||
| 718 | 16 | ||
| 719 | call plug#end() | 17 | call plug#end() |