chusiang / vimrc

vimrc of chusiang
MIT License
46 stars 16 forks source link

改用 YCM + Ultisnips 的自動補齊機制 #21

Closed chusiang closed 7 years ago

chusiang commented 8 years ago

原先用的自動補齊 (auto-complete) 套件 vim-snipmate (vim-addon-mw-utils, tlib_vim, vim-snippets) 已有些不敷使用,故預計換成 YouCompleteMe + UltiSnips 的架構。

但由於 YouCompleteMe + UltiSnips 不適合部署至 server 上,故應另開個 branch 保持其輕量性。

Setup

  1. Install YouCompleteMe with NeoBundle.
  2. Complete it !

    cd ~/.vim/bundle/YouCompleteMe
    ./install.py --clang-completer

    Reference

chusiang commented 8 years ago

應把 workstation (Desktop) 與 lighting (server) 的版本拆開,有很多 plugin 跟設定是只有在 workstation 才需要用到的。

  1. fork 成另一份給 lighting 使用。
  2. 在 build script 裡塞變數和判斷式來切換使用環境。
chusiang commented 8 years ago

先附上相關的 vimrc。

" ## YouCompleteMe (code-completion)
NeoBundle 'Valloric/YouCompleteMe'
let g:ycm_filetype_blacklist = {
      \ 'tagbar' : 1,
      \ 'qf' : 1,
      \ 'notes' : 1,
      \ 'markdown' : 1,
      \ 'unite' : 1,
      \ 'text' : 1,
      \ 'vimwiki' : 1,
      \ 'gitcommit' : 1,
      \}
let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py"

" ## Ultisnips (auto-complete)
NeoBundle 'sirver/ultisnips'
let g:UltiSnipsSnippetDirectories=["UltiSnips", "ultisnips_my"]

" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"

" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger="<c-tab>"
let g:UltiSnipsListSnippets="<c-s-tab>"

NeoBundle 'honza/vim-snippets'
chusiang commented 8 years ago

使用操作差異:

  1. 在 vim-snipmate 只需按下 <Tab> 即可自動補齊,但現在需改用 <Ctrl> + <Tab>
  2. YCM 被觸發時,可以 ...
    1. 使用 <Ctrl> + n, <Ctrl> + p 來上下移動項目 (item)。
    2. 使用 <Ctrl> + <Shift> + <Tab> 列出所有的 Snippets,並使用數字 (1, 2, 3 ...) 來選取。
aminzai commented 8 years ago

Mac上用YCM可能會炸
https://github.com/Valloric/ycmd/issues/411

chusiang commented 8 years ago

炸了我就切回 vim-snipmate 模式囉,話說為了提升點功力卻要付出愈來愈多的代價了。XD

chusiang commented 8 years ago

換了 YCM 後,在 OSX 10.11 上就不會遇到與嘸蝦米輸入法自動補上奇怪字完的衝突問題,待 lighting 的版本整理好即可關閉此 issue。

chusiang commented 8 years ago

在 console 裡使用 Vim 遇上 YouCompleteMe unavailable: requires Vim 7.3.584+ 問題,可以試著用別名來設 vi。

$ vi ~/.bashrc
...
alias vi='vim'
chusiang commented 7 years ago

Finish it at 82993d6, and I will release it at v3.0.0.

chusiang commented 7 years ago

Before build the YCM on CentOS 7, we need install some packages.

  1. cmake
  2. ctags
  3. gcc
  4. gcc-c++
  5. git
  6. python-devel