clangd
If you are familiar with IntelliSense (which is installed by default in Visual Studio and Visual Studio Code), clangd is the same kind of thing, but better (less laggy, more complete). It will provide autocompletion, suggestions, detect bugs, etc.
- First, install the clangd extension: vscode-clangd.
- It should then prompt you to disable IntelliSense: say yes. If you miss that step, go in the Settings, search for
C_Cpp.intelliSenseEngine
and set it toDisabled
. - It should then prompt you to download the actual language server: say yes. If it doesn't show up, then CTRL+SHIFT+P and run
clangd: Download language server
. If it is unable to download it, you can download it manually here. - Now go to your Settings (CTRL+,), search for
clangd arguments
and add--compile-commands-dir=${workspaceFolder}/build
- Now install Ninja. Then, go back to your settings and set
Cmake: Generator
toNinja
. - You might need to close VS Code, delete your
build
folder (if it exists), and open VS Code again.
You should now be good to go! (If VSCode is not able to provide autocompletion, then something went wrong during the installation of clangd.)
tip
clangd adds these things called Inlay Hints
:
If you don't want them you can disable them in your VS Code settings: