Open lee-shun opened 2 years ago
And, I have already checked the issue #239 , but I do think that could help me .....
@lee-shun
You can put the generated compile_commands.json
at ~/catkin_ws
(means ~/catkin_ws/compile_commands.json
) and, put .ccls-root
file ~/catkin_ws/.ccls-root
(means execute touch ~/catkin_ws/.ccls-root
).
Is there some env variables or marcos can be set to spcify the ccls-root
and the relative path of compile_commands.json
?
@Sologala after you execute source <your_workspace>/devel/setup.bash
execute the function below
catkin_generate_compile_commands_json(){
echo Generating workspace compile_commands.json...
local catkin_ws=$(echo $CMAKE_PREFIX_PATH | cut -d: -f1)/..
local old_dir=$(pwd)
cd ${catkin_ws}
if [ -e compile_commands.json ]; then
rm compile_commands.json
fi
concatenated="compile_commands.json"
echo "[" > $concatenated
first=1
for d in build/*
do
f="$d/compile_commands.json"
if test -f "$f"; then
if [ $first -eq 0 ]; then
echo "," >> $concatenated
fi
cat $f | sed '1d;$d' >> $concatenated
fi
first=0
done
echo "]" >> $concatenated
cd $old_dir
}
then execute touch <your_workspace>/.ccls-root
Observed behavior
compile_commands.json
generated bycatkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=1
under the~/catkin_ws/build
path. I copy thecompile_commands.json
into the `src/Onborad-SDK-ROS', which is basically a ros package.ros/ros.h
anddji_osdk_ros/commom_type.h
coc-clang
works well.(But, I like ccls more!)Expected behavior
ros::...
namespace should be properly found.Steps to reproduce
catkin_ws
and cd into the~catkin_ws/src
, clone the[
Onborad-SDK-ROS'](https://github.com/dji-sdk/Onboard-SDK-ROS)` in src.cd ~/catkin_ws
andcatkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=1
. copy thecompile_commands.json
into theOnborad-SDK-ROS
. Then config the nvim with coc.nvim like the config below.Onborad-SDK-ROS/src/dji_osdk_ros/flight_control_node.cpp
you will see something llike this:the
ros::
namespace are defined in the#include <ros/ros.h>
, and thenamespace dji_osdk_ros
is defined in the#include <dji_osdk_ros/commom_type.h>
like the arrows in the upper picture.System information
git describe --tags --long
): 0.20210330