ccls icon indicating copy to clipboard operation
ccls copied to clipboard

Absolute path is added to workspace path when searching for definition

Open idrilirdi opened this issue 3 years ago • 1 comments

Observed behavior

I use neovim with coc.nvim. My project uses parts from another of my projects that is installed in /usr/local/include. When using "go to definition" it works correctly if that definition is inside my project. If the definition is in the other library, it takes me to a non-existing file because the path returned by ccls isn't the correct one.

My compile_commands.json file is quite big but looks like this for each .cpp file:

{ "directory": "/home/igeer/WOLF/wolf/imu/build/test", "command": "/usr/bin/c++ -DCERES_EXPORT_INTERNAL_SYMBOLS -DGFLAGS_IS_A_DLL=0 -I/home/igeer/WOLF/wolf/imu/include -I/home/igeer/WOLF/wolf/imu/build/conf -I/usr/local/include/iri-algorithms/wolf/plugin_core -isystem /usr/local/include/eigen3 -I/home/igeer/WOLF/wolf/imu/build/test/gtest/src/googletest/googletest/include -isystem /usr/local/include -std=c++14 -Werror=all -Werror=extra -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -O3 -D_REENTRANT -std=gnu++14 -o CMakeFiles/gtest_processor_imu2d_with_gravity.dir/gtest_processor_imu2d_with_gravity.cpp.o -c /home/igeer/WOLF/wolf/imu/test/gtest_processor_imu2d_with_gravity.cpp", "file": "/home/igeer/WOLF/wolf/imu/test/gtest_processor_imu2d_with_gravity.cpp" }

My .ccls file is:

%compile_commands.json %cpp -std=c++14 %h -x %h c++-header

The trace from coc when calling for the definition is the following:

[Trace - 3:39:05 PM] Received response 'textDocument/definition - (4)' in 0ms.
Result: [ { "uri": "file:///home/igeer/WOLF/wolf/imu//usr/local/include/iri-algorithms/wolf/plugin_core/core/common/wolf.h", "range": {
"start": { "line": 225,
"character": 0 }, "end": { "line": 225,
"character": 26 } } } ]

The workspace where .ccls and compile_commands.json are is /home/igeer/WOLF/wolf/imu/

Expected behavior

Instead of "uri": "file:///home/igeer/WOLF/wolf/imu//usr/local/include/iri-algorithms/wolf/plugin_core/core/common/wolf.h" what should be returned is "uri": "file://usr/local/include/iri-algorithms/wolf/plugin_core/core/common/wolf.h" so that neovim can open the correct file.

I'm sure this has to be a problem with my configuration, how do I fix it?

System information

  • ccls version (git describe --tags --long): 0.20210330-6-g5a48e6c4
  • clang version: 6.0.0-1ubuntu2
  • OS: Ubuntu 18.04
  • Editor: NVIM v0.6.1
  • Language client (and version): Coc.nvim 0.0.80-eb01206e30

idrilirdi avatar Jan 28 '22 15:01 idrilirdi

I have same problem -isystem is added relative to project path again neovim and coc.nvim

phush0 avatar Feb 10 '22 09:02 phush0