wiki:Clangd

Version 4 (modified by Brandon, 6 months ago) (diff)

--

Clangd

clangd is language server designed to provide features like autocomplete, go to definition, and refactoring to a wide range of editors.

clangd autocomplete

Getting clangd

macOS

clangd will be installed by default with Xcode.

Linux and Windows

Instructions to obtain clangd can be found at https://clangd.llvm.org/installation

Setting up clangd

Generate compile_command.json

macOS

clangd relies on compile_commands.json file to work, which can be generated on macOS by running

make r EXPORT_COMPILE_COMMANDS=YES
generate-compile-commands WebKitBuild/Release

I would recommend running this command each time you pull the latest code.

If you add or remove files during development, recompile with make r EXPORT_COMPILE_COMMANDS=YES and rerun generate-compile-commands WebKitBuild/Release.

Linux and Windows

For other platforms using cmake, generating compile_commands.json can be accomplished by running

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

Configure your editor

Every editor will have slightly different method to setup clangd.

The clangd website provides an excellent setup guide for most popular editors.

Editors Links
BBEdit https://www.barebones.com/support/bbedit/lsp-notes.html
Clion https://www.jetbrains.com/help/clion/settings-languages-cpp-clangd.html
Emacs https://clangd.llvm.org/installation#editor-plugins
Vim https://clangd.llvm.org/installation#editor-plugins
VSCode https://clangd.llvm.org/installation#editor-plugins
Sublime Text https://clangd.llvm.org/installation#editor-plugins

Attachments (1)

Download all attachments as: .zip