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