add the following lines to /etc/apt/sources.list
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main
# deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-15 mainAnd then run this in the command line
$ sudo apt update && sudo apt install -y \
clangd-15 \
clang-15 \
clang-format-15 \
libomp-15-devThe following lines is to change the default clang++, clang, clang-format, clangd
$ sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100 \
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100 \
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100 \
sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-15 100curr_ws=${HOME}/catkin_ws
catkin config --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1 # to generate compile_commands.json in all projects
jq -s 'map(.[])' ${curr_ws}/**/compile_commands.json > ${curr_ws}/compile_commands.json # To merge compile_commands.json on every projects to 1 fileYou can add the above command like (
Lines 95 to 99 in 4b91348
Install Clangd VSCode Extension
Copy this file to ~/.config/clangd/config.yaml
And add --enable--config in the ~/.config/Code/User/settings.json's clangd.arguments, for example:
{
"clangd.arguments": ["--print-options", "--background-index", "--malloc-trim", "--header-insertion=never", "--header-insertion-decorators", "--all-scopes-completion", "--completion-style=detailed", "--enable-config"]
}