Clangd
lastmod 2024-10-24created 2020-04-236 edits
clangd understands your C++ code and adds smart features to your editor: code completion, compile errors, go-to-definition and more.
clangd is a language server that can work with many editors via a plugin.
clangd is based on the Clang C++ compiler, and is part of the LLVM project.
How to install
macOS
The output is as follows:
==> Downloading https://homebrew.bintray.com/bottles/llvm-10.0.1.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/e3ec9fda84756750ac0b5620ff34da04ba5035c8276af1bebfe76e012bb0b14a?response-content-disposition=attachment%3Bfilename%3D%22llvm-10.0.1.catalina.bott
######################################################################## 100.0%
==> Pouring llvm-10.0.1.catalina.bottle.tar.gz
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.profile
For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
==> Summary
🍺 /usr/local/Cellar/llvm/10.0.1: 7,029 files, 1GB
For the installed executables, either add /usr/local/opt/llvm/bin to your PATH as written above, or create symbolic links for only the files you need.
Project setup
If your project builds with CMake, it can generate this file. You should enable it with:
compile_commands.json will be written to your build directory. If your build directory is $SRC or $SRC/build, clangd will find it. Otherwise, symlink or copy it to $SRC, the root of your source tree.