← Back to Payloads
Dev Tools2026-04-27

clangd: The LSP Server That Finally Makes C++ Bearable

C++ IntelliSense used to mean waiting two minutes for your IDE to index your codebase, then watching it eat 4GB of RAM. clangd changes the math — real-time diagnostics, accurate goto-definition, and compile-speed feedback without the bloat.
Quick Access
Install command
$ mrt install clangd
Browse related skills
clangd: The LSP Server That Finally Makes C++ Bearable

TL;DR

clangd speaks the Language Server Protocol — which means it works inside VS Code, Neovim, Emacs, Helix, or any LSP-aware editor. You get cross-references, diagnostics, and code completion at the speed of a compiler backend, not a separate indexer.

The 10-Second Pitch

  • **Instant diagnostics** — clangd runs as a separate process, so it never blocks your editor even on million-line codebases
  • **Semantic highlighting** — variable types get colour-coded without any configuration
  • **Find references and goto-definition** — works across translation units, not just within one file
  • **Compile flags inference** — reads your compile_flags.txt or compile_commands.json automatically; no config files needed
  • **Integrates with any LSP client** — VS Code (clangd extension), Neovim (nvim-lspconfig), Emacs (eglot or lsp-mode)

Setup in 3 Steps

1. **Install clangd.** On macOS: `brew install llvm`. On Ubuntu/Debian: `apt install clangd`. On Windows: use LLVM's pre-built binaries. Make sure clangd is in your $PATH.

2. **Generate a compile commands file.** If you use CMake: `cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .`. For Meson: `meson setup build --wipe && meson compile -C build`.

3. **Point your editor at clangd.** In VS Code, install the clangd extension. In Neovim:

require('lspconfig').clangd.setup({

cmd = { 'clangd', '--background-index' },

root_dir = root_pattern('compile_commands.json', '.clangd'),

})

**Prompt to test it:**

Use clangd to find all references to the ConnectionPool class in this codebase and explain what it is used for.

What You Actually Get

clangd is built on Clang's AST — the same compiler infrastructure your project actually uses. That means:

  • **Type-aware completions** — not just textual prefix matching but actual type-based suggestions
  • **Inline error messages** — the same diagnostics your make or cmake would produce, surfaced live in your editor
  • **Code actions** — auto-apply fixes for const-ify variables, add missing includes, simplify templates

The background indexer builds a persistent index across sessions. First run on a large project takes a few minutes. After that, jumps to symbol are instant.

Pros / Cons

ProsCons
Real-time diagnostics without blockingInitial index build takes time on large codebases
Type-aware completions far superior to word-basedRequires compile_commands.json for full accuracy
Works across translation unitsLess polished than Rider or Visual Studio for C++

Verdict

clangd is not a replacement for a full IDE — if you need a debugger with a GUI, use CLion or Rider. But for editing C++ in a fast, lightweight environment, clangd is the best LSP server available. It works inside every major editor, requires minimal configuration, and gives you compiler-quality code intelligence. If you are writing C++ without clangd, you are making your life harder than it needs to be.

Free, open source, vendor-neutralNo GUI debugger integration