MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.73k stars 254 forks source link

CCLS not reading project root .ccls file #872

Open Moggel12 opened 2 years ago

Moggel12 commented 2 years ago

Observed behavior

In my C++ project structure I have an inc directory as well as a src directory. Whenever I (in src/*.cpp ) try to include files that reside in the inc directory I get a "file not found error" from ccls.

My .ccls file is setup very basic for now:

clang++
%cpp -std=c++17
-Iinc
-fsanitize=leak
-fsanitize=address
-fsanitize=undefined

Further, using C++17 extensions will also give warnings, even though cpp files should be parsed with -std=c++17.

Im sorry if this is not a bug, but I have not found any documentation stating why the setup above should not work.

Expected behavior

My custom headers, inc/*.hpp, should be included.

Steps to reproduce

Create a C++ project with a src and inc folder. Put a header file in the inc directory and a cpp file in the src directory. Then use the .ccls file mentioned earlier.

System information

philippludwig commented 2 years ago

Same problem here, running clang 13.0.1 with nvim 0.6.1 on Gentoo; this issue started recently.

Moggel12 commented 2 years ago

Same problem here, running clang 13.0.1 with nvim 0.6.1 on Gentoo; this issue started recently.

Did you also install via a package manager? Or did you compile directly from the git repo?

philippludwig commented 2 years ago

I tried both, sadly it does not make a difference. Also I tried downgrading to clang 13.0.0, this did not help either.

philippludwig commented 2 years ago

After recompiling ccls manually from the repository, everything works fine. So at least for Gentoo it seems to be a packaging issue.

JDuchniewicz commented 2 years ago

Seconding that, I had to rebuild ccls from source on Arch Linux. Version 13.0.1.

fkerle commented 7 months ago

@Moggel12 did you have a look in the ccls-log and check what it thinks the workspace folder: ... was?

depending on your language client, it may choose the workspace directory on a number of factors (special files, settings, ...) you may need to set this appropriately.

AFAIK for coc: rootPatterns https://github.com/neoclide/coc.nvim/issues/341#issuecomment-455264153

(I use languageclient-neovim, there it's let g:LanguageClient_rootMarkers = ['.ccls-root', '.languageclient-root'])

fkerle commented 7 months ago

@MaskRay i've struggling with the workspace directory location myself, as it is not mentions in the documentation for the .ccls file. It would be a time saver, if you included some hint about this in the wiki?

.ccls file is read from the workspace directory. This is set by the language client in your IDE!
coc.vim: rootPatterns
LanguageClient-neovim: g:LanguageClient_rootMarkers
...