Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not completing include directories set in .ccls #160

Closed
oblitum opened this issue Dec 13, 2018 · 14 comments
Closed

Not completing include directories set in .ccls #160

oblitum opened this issue Dec 13, 2018 · 14 comments
Labels
bug Something isn't working

Comments

@oblitum
Copy link

oblitum commented Dec 13, 2018

I'm using coc.nvim+ccls, it provides most headers for completion, but doesn't provide headers I set in .ccls flags, for example, I'm trying this:

%clang
-Wall
-Wextra
%c -std=gnu11
%cpp -pedantic
%cpp -std=c++17
%cpp -stdlib=libc++
%cpp -I/opt/src/GSL/include
%cpp -I/opt/src/range-v3/include

When I go about including #include <rang|>, I only get boost range headers from my system, even after #include <range/|>, simple no completion for range/v3. But code completion and diagnostics works for range-v3 symbols, just inclusion that fails.

@MaskRay
Copy link
Owner

MaskRay commented Dec 14, 2018

Are you using clang 7 or 8 (trunk)? If 7, can you check project.cc:190?

for (auto &E : HeaderOpts.UserEntries) {

@MaskRay
Copy link
Owner

MaskRay commented Dec 15, 2018

Close due to inactivity and I cannot reproduce.

@MaskRay MaskRay closed this as completed Dec 15, 2018
@MaskRay MaskRay added the question Further information is requested label Dec 15, 2018
@oblitum
Copy link
Author

oblitum commented Dec 15, 2018

Sorry, I didn't have time to test that suggestion yet (I just grab it from AUR). But I'd report it back.

@oblitum
Copy link
Author

oblitum commented Dec 15, 2018

Does it work for you with coc.nvim and like my testcase explains? Because just by using coc.nvim I can't make it work at all.

@MaskRay
Copy link
Owner

MaskRay commented Dec 16, 2018

I checked it with releases.llvm.org clang 7 not the AUR package.

@oblitum
Copy link
Author

oblitum commented Dec 16, 2018

I was referring to ccls from AUR, not clang. I mean, I'm just installing ccls by doing aurman -S ccls, not compiling it myself, for checking the snippet you pointed.

@oblitum oblitum mentioned this issue Dec 22, 2018
@oblitum
Copy link
Author

oblitum commented Dec 22, 2018

@MaskRay

Same .ccls:

%clang
-Wall
-Wextra
%c -std=gnu11
%cpp -pedantic
%cpp -std=c++17
%cpp -stdlib=libc++
%cpp -I/opt/src/GSL/include
%cpp -I/opt/src/range-v3/include

I've put the following:

    std::fstream f("/home/francisco/ccls-includes");
    for (auto &E : HeaderOpts.UserEntries) {
      std::string path =
          NormalizePath(ResolveIfRelative(entry.directory, E.Path));
      f << "user entry: " << E.Path << '\n';
      f << "normalized: " << path << '\n';
      f.flush();

ccls-includes:

user entry: /usr/local/include
normalized: /usr/local/include
user entry: lib/clang/7.0.1/include
normalized: /home/francisco/Projects/samples/c++/lib/clang/7.0.1/include
user entry: /include
normalized: /include
user entry: /usr/include
normalized: /usr/include

Notice how relative lib/clang/7.0.1/include became a bad normalized header and how there's no sign of /opt/src/ includes.

This is the result when using cmake generated compile_commands.json, no issues:

user entry: /home/francisco/ccls/src/ccls-project/src
normalized: /home/francisco/ccls/src/ccls-project/src
user entry: /home/francisco/ccls/src/ccls-project/third_party
normalized: /home/francisco/ccls/src/ccls-project/third_party
user entry: /home/francisco/ccls/src/ccls-project/third_party/rapidjson/include
normalized: /home/francisco/ccls/src/ccls-project/third_party/rapidjson/include
user entry: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1
normalized: /usr/include/c++/8.2.1
user entry: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/x86_64-pc-linux-gnu
normalized: /usr/include/c++/8.2.1/x86_64-pc-linux-gnu
user entry: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/backward
normalized: /usr/include/c++/8.2.1/backward
user entry: /usr/local/include
normalized: /usr/local/include
user entry: /usr/lib/clang/7.0.1/include
normalized: /usr/lib/clang/7.0.1/include
user entry: /include
normalized: /include
user entry: /usr/include
normalized: /usr/include

@oblitum
Copy link
Author

oblitum commented Dec 22, 2018

I'm using the project branch.

@MaskRay MaskRay reopened this Dec 22, 2018
@MaskRay
Copy link
Owner

MaskRay commented Dec 22, 2018

Can you try the project branch again?

The issue was that quote_dirs overrode angle_dirs so you don't get completion when < was used, " should work. The latest change unifies quote_dirs and angle_dirs to a single search_dir2kind.

@oblitum
Copy link
Author

oblitum commented Dec 22, 2018

@MaskRay I've checked, it's working now.

@MaskRay MaskRay added bug Something isn't working and removed question Further information is requested labels Dec 22, 2018
@MaskRay
Copy link
Owner

MaskRay commented Dec 22, 2018

Fixed by #171

@MaskRay MaskRay closed this as completed Dec 22, 2018
@oblitum
Copy link
Author

oblitum commented Dec 23, 2018

Hi @MaskRay, I got another issue after this fix, it's working great for the previous flags, but if I remove -stdlib=libc++ I stop getting include suggestions for <iostream> and other basic std headers.

~/P/s/c++ ❯❯❯ cat .ccls
%clang
-Wall
-Wextra
%c -std=gnu11
%cpp -pedantic
%cpp -std=c++17

@MaskRay
Copy link
Owner

MaskRay commented Dec 23, 2018

I got another issue after this fix, it's working great for the previous flags, but if I remove -stdlib=libc++ I stop getting include suggestions for <iostream> and other basic std header

Isn't it the opposite? Check what clang++ -fsyntax-only -v -xc++ /dev/null -stdlib=libc++ tells you, and also read #125 (comment)

-stdlib=platform (default) uses libstdc++ on most Linux, and libc++ on Mac OS X>=10.9, FreeBSD>=10, NetBSD>=7, ...

This works for me if I want to use libc++:

%clang
-ccc-install-dir
/home/user/llvm/Release/bin
-stdlib=libc++

@oblitum
Copy link
Author

oblitum commented Dec 23, 2018

No no, it's not the opposite, it's in fact what I've stated, with -stdlib=libc++ (which is in fact what I use in general while completing), it works. Removing just that line and leaving the rest like the cat above, I don't get completion for std headers anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants