masoud
masoud

Reputation: 56479

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

I have to develop my project in text-mode debian linux. I'm using Vim and I installed the clang_completion plugin on it. I made .clang_completion file in root of my project :

-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?

Upvotes: 7

Views: 810

Answers (2)

nonameentername
nonameentername

Reputation: 434

I found the easiest way to get clang_complete to work is to use the provided cc_args.py file.

when compiling a project use clang_complete/bin/cc_args.py instead of gcc/g++

This will generate the correct .clang_complete file with all libraries and dependencies. Provided the clang_complete source directory in your home folder.

Example Makefile:

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

all:
    $(CXX) main.cpp

Upvotes: 2

Vincenzo Pii
Vincenzo Pii

Reputation: 19805

I've successfully used the clang_complete plugin in the past (now I just use cscope and ctags, which I consider enough).

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.

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).

Hope this helps.

Upvotes: 0

Related Questions