https://www.youtube.com/watch?v=2gIyu09UEC8
To have autocomplete etc you need a compile_commands.json file, which can be created by the following command (source)
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ONor alternatively adding this in your CMakeList.txt
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)It will end up in the build directory. For this to be seen by vscode (sometimes), you need to add a file in your .vscode called c_cpp_properties.json which points to this json file.
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}If clangd does not work
Specify path in .vscode/settings.json
{
"clangd.path": "/usr/bin/clangd-XX"
}