ccls icon indicating copy to clipboard operation
ccls copied to clipboard

CCLS not reading project root .ccls file

Open Moggel12 opened this issue 3 years ago • 7 comments

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

  • ccls version (git describe --tags --long): 0.20210330-5 (installed via pacman)
  • clang version: 13.0.1
  • OS: Arch linux
  • Editor: vim
  • Language client (and version): coc.nvim

Moggel12 avatar Mar 10 '22 07:03 Moggel12

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

philippludwig avatar Mar 10 '22 10:03 philippludwig

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?

Moggel12 avatar Mar 13 '22 10:03 Moggel12

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 avatar Mar 14 '22 12:03 philippludwig

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

philippludwig avatar Mar 20 '22 19:03 philippludwig

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

JDuchniewicz avatar Apr 28 '22 15:04 JDuchniewicz

@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 avatar Feb 01 '24 08:02 fkerle

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

fkerle avatar Feb 01 '24 08:02 fkerle