Re: [vim ] YouCompleteMe 寫C++自動補全問題

作者: ptkt (阿呆)   2015-05-07 08:22:16
※ 引述《BCRK7 (K7)》之銘言:
: 最近在設定Vim的Plugin,
: 我想用它來寫C++程式,於是安裝了YouCompleteMe這個Plugin。
: 但我發現我不懂怎麼寫.ycm_extra_conf.py,於是就用別人寫好的。
: 但我想要include <iostream> ,
: 我希望我輸入 #include <i 時,他會有個 <iostream> 的選項讓我選。
: 結果他出來的選項都是一些不重要的東西。
: http://imgur.com/a1cb90T
: 請問有辦法讓他偵測我的library嗎?
: 我的.ycm_extra_conf.py
: https://github.com/Kai7/.vim/blob/master/.ycm_extra_conf.py
: 另外,我在看YouCompleteMe的文件時,有句話我不懂他的意思。
: YCM looks for a .ycm_extra_conf.py file in the directory of the opened file or in any directory above it in the hierarchy (recursively)
: 我把他理解成,假設我在 /home/user/cpp/ 底下寫 hello.cpp 時,他會先找 /home/user/cpp/ 底下有沒有.ycm_extra_conf.py,
: 沒有的話再往上找 /home/user ... 以此類推。
如果您寫的project很大的話, YouCompleteMe有支援 Clang's Compil
ationDatabase system, 可以在.ycm_extra_conf.py file裡面設定compil
e_commands.json file的路徑, 至於要如何產生compile_commands.json,
要看您project使用的build system, 如果是用CMake,那麼在在build的時候
可以加上-DCMAKE_EXPORT_COMPILE_COMMANDS=ON這個參數來產生, 如果是用
其它build system, 則可以使用Bear(https://github.com/rizsotto/Bear)
這個工具來產生, 要是您不想用compile_commands.json, 也有YCM-Genera
tor(https://github.com/rdnetto/YCM-Generator)這個工具來幫您自動產
生.ycm_extra_conf.py.
以上說的這些在YouCompleteMe的github裡的README.md也有提到, 有不
清楚的地方可以去上面看一下.
作者: Arton0306 (Ar藤)   2015-05-11 00:11:00
推bear 好用!

Links booklink

Contact Us: admin [ a t ] ucptt.com