简体   繁体   English

包含标准头后,Vim代码完成不起作用

[英]Vim code completion doesn't work after including a standard header

I have to develop my project in text-mode debian linux. 我必须在文本模式debian linux中开发我的项目。 I'm using Vim and I installed the clang_completion plugin on it. 我正在使用Vim,我在其上安装了clang_completion插件。 I made .clang_completion file in root of my project : 我在项目的根目录中创建了.clang_completion文件:

-I.
-I/usr/include
-I/usr/include/c++/4.6

When I write a program like below, the completion works fine. 当我写下面的程序时,完成工作正常。

//#include <stdio.h>
int main()
{
  struct A
  {
    int x, y;
  };

  A a;
  a. // After putting dot, the suggestion popup appears

  return 0;
}

However, after removing the comment of first line, it doesn't work! 但是,删除第一行的注释后,它不起作用! How can I overcome this issue? 我怎样才能克服这个问题?

I found the easiest way to get clang_complete to work is to use the provided cc_args.py file. 我发现让clang_complete工作的最简单方法是使用提供的cc_args.py文件。

when compiling a project use clang_complete/bin/cc_args.py instead of gcc/g++ 编译项目时使用clang_complete / bin / cc_args.py而不是gcc / g ++

This will generate the correct .clang_complete file with all libraries and dependencies. 这将生成包含所有库和依赖项的正确.clang_complete文件。 Provided the clang_complete source directory in your home folder. 在主文件夹中提供了clang_complete源目录。

Example Makefile: 示例Makefile:

CXX=$(HOME)/clang_complete/bin/cc_args.py g++

all:
    $(CXX) main.cpp

I've successfully used the clang_complete plugin in the past (now I just use cscope and ctags, which I consider enough). 我过去成功使用过clang_complete插件(现在我只使用cscope和ctags,我认为足够了)。

Including external headers worked fine in my configuration, but, as the clang complete plugin page specifies, the file in which to put include paths (or any other flag you may want to pass to the clang compiler), must be named .clang_complete and not .clang_completion . 包含外部头文件在我的配置中运行正常,但是,正如clang完整插件页面指定的那样,放置包含路径的文件(或者您可能希望传递给clang编译器的任何其他标志)必须命名为.clang_complete而不是.clang_completion

Also, I used to put the options on a single line, just as I was going to pass the plain content of the .clang_complete file as a command line option (don't know if separating lines with \\ will work). 此外,我曾经把选项放在一行,就像我要将.clang_complete文件的普通内容作为命令行选项传递一样(不知道用\\将分隔行是否有效)。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM