> ## Documentation Index
> Fetch the complete documentation index at: https://aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring the IDE or editor

> Configure C/C++ editors for Bazel using clangd and the hedron compile-commands-extractor, enabling completion, diagnostics, and jump-to-definition.

LLVM provides a Language Server for C++. This is a program that runs as a daemon, providing editor features like error highlighting, jump-to-definition, and code completion. It’s a lot more productive to see these as you type, rather than having to do a bazel build.

[https://clangd.llvm.org/](https://clangd.llvm.org/) is the program we want.

`clangd` relies on something called a “Compilation Database” so it understands the dependency graph, such as the location on disk of some header files used in a compile step. See [https://clangd.llvm.org/config#compilationdatabase](https://clangd.llvm.org/config#compilationdatabase)

We need to transform Bazel’s action graph (the build steps it would perform) into a compilation database. There is a tool available to do this: [https://github.com/hedronvision/bazel-compile-commands-extractor](https://github.com/hedronvision/bazel-compile-commands-extractor) which is already installed in our MODULE.bazel file.

There are a few ways to configure and run the compile-commands-extractor. The simplest way works for our small example, which is to run it with the default Bazel flags over all targets in our repository:

```bash theme={null}
%  bazel run @hedron_compile_commands//:refresh_all
```

We also need `clangd` installed and integrated with the editor. Instructions vary by editor. For example with Visual Studio Code, after adding the [extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) we see auto-completion in our `magic.c` file, and can jump-to-definition on symbols in that file, including to `stdlib.h` .

<img src="https://mintcdn.com/aspectbuild/gtqBKXWWd-jWHweY/learning/bazel-104/completion.png?fit=max&auto=format&n=gtqBKXWWd-jWHweY&q=85&s=0ddb270d4dea06b9d20f19bb83005bea" alt="Screenshot 2025-06-04 at 2.59.25 PM.png" width="1878" height="986" data-path="learning/bazel-104/completion.png" />

Note that there are yellow squiggles from clang-tidy warnings. These drive the developer to improve the code. We’ll produce these later with Bazel as well, for display in the code review.
