V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
zerh925
V2EX  ›  程序员

YouCompleteMe 添加头文件路径

  •  
  •   zerh925 · Oct 16, 2015 · 3901 views
    This topic created in 3859 days ago, the information mentioned may be changed or developed.

    怎么配置.ycm_extra_conf.py 呢?
    我添加了这么一句:

    ‘-I'
    ’../include'
    '-I'
    '../inc'
    '-isystem'
    '/usr/include'
    '-isystem'
    '/usr/local/system/
    

    分别添加标准库和自己项目中的同级 include/inc 文件夹,还是不行。

    Supplement 1  ·  Oct 16, 2015

    [SOLVED]
    useful links:
    https://groups.google.com/forum/#!topic/ycm-users/u6ImGNWQol8
    https://github.com/Valloric/YouCompleteMe/issues/303
    http://stackoverflow.com/questions/24438211/youcompleteme-header-files

    在~/.ycm_extra_conf.py 中添加了:

    ‘-isystem ’, '/usr/include',
    '-isystem', '/usr/local/include',
    

    然后单个的项目拷贝这份.ycm_extra_conf.py 到项目根目录,添加

    ’-I', 'include',
    '-I', 'inc',
    

    或者其他头文件存放的位置。
    注意不要设置

    let g:global_ycm_extra_conf='~/.ycm_extra_conf.py'
    

    设置了这个就会优先使用这个配置文件,但是这个配置文件是没有你自己添加的头文件目录的,
    让 YCM 每次启动都在项目目录中去找.ycm_extra_conf.py 。

    Supplement 2  ·  Oct 16, 2015
    由 @skydiver 指正:
    全局配置文件不会覆盖项目的配置文件,项目中的优先级比全局的高。
    所以可以放心在 vimrc 中设置全局配置文件。
    6 replies    2015-10-17 19:08:49 +08:00
    fengjianxinghun
        1
    fengjianxinghun  
       Oct 16, 2015
    不错。。做个记号
    skydiver
        2
    skydiver  
       Oct 16, 2015
    你没发现你的单引号写错了么,写成弯引号了。

    另外设置全局的 extra_conf 并不会妨碍加载项目的配置文件,所以你说不要设置这一段是错的
    zerh925
        3
    zerh925  
    OP
       Oct 16, 2015
    @skydiver 那个单引号是帖子编辑的时候手误。
    但是你说的全局 extra_conf 确实不会影响本地项目的配置文件。是我说错了。
    谢谢指正。
    stillness
        4
    stillness  
       Oct 16, 2015
    可以试试这个 https://github.com/rdnetto/YCM-Generator
    从项目的 makefile 这些东西生成一个 .ycm_extra_conf.py
    Supported build systems:

    make
    cmake
    qmake
    autotools
    pzhjie
        5
    pzhjie  
       Oct 16, 2015
    @nirocfz 你用过吗,好用不
    stillness
        6
    stillness  
       Oct 17, 2015
    @pzhjie 读开源项目代码的时候用,自己写代码的时候,用不用无所谓了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   850 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 20:32 · PVG 04:32 · LAX 13:32 · JFK 16:32
    ♥ Do have faith in what you're doing.