Clangd LSP
/install clangd-lsp
clangd LSP
C/C++ language server integration providing comprehensive code intelligence through clangd (part of LLVM).
Capabilities
- Code intelligence: Autocomplete, go-to-definition, find references
- Error detection: Real-time diagnostics for compilation errors
- Formatting: Code formatting with clang-format
- Refactoring: Rename symbols, extract function
- Supported extensions:
.c,.h,.cpp,.cc,.cxx,.hpp,.hxx,.C,.H
Installation
Via Homebrew (macOS)
brew install llvm
# Add to PATH
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
Via package manager (Linux)
# Ubuntu/Debian
sudo apt install clangd
# Fedora
sudo dnf install clang-tools-extra
# Arch Linux
sudo pacman -S clang
Windows
winget install LLVM.LLVM
Or download from LLVM releases.
Verify installation:
clangd --version
Usage
The language server runs automatically in LSP-compatible editors. For manual operations:
Compile
gcc file.c -o output # C
g++ file.cpp -o output # C++
clang file.c -o output # with clang
Format code
clang-format -i file.cpp
Static analysis
clang-tidy file.cpp -- -std=c++17
Configuration
Create .clangd in project root:
CompileFlags:
Add: [-std=c++17, -Wall, -Wextra]
Remove: [-W*]
Diagnostics:
UnusedIncludes: Strict
MissingIncludes: Strict
Or compile_commands.json for complex projects:
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
# or
bear -- make
Integration Pattern
When editing C/C++ code:
- clangd uses
compile_commands.jsonfor project understanding - Run
clang-formatto format code - Use
clang-tidyfor static analysis - Compile with warnings enabled (
-Wall -Wextra)
Common Flags
Compile flags:
-std=c++17- C++17 standard-Wall -Wextra- Enable warnings-O2- Optimization level-g- Debug symbols-I\x3Cpath>- Include path-L\x3Cpath>- Library path
clang-tidy checks:
clang-tidy file.cpp --checks='*' --
clang-tidy file.cpp --fix -- # Auto-fix
More Information
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install clangd-lsp - After installation, invoke the skill by name or use
/clangd-lsp - Provide required inputs per the skill's parameter spec and get structured output
What is Clangd LSP?
C/C++ language server (clangd) providing code intelligence, diagnostics, and formatting for .c, .h, .cpp, .cc, .cxx, .hpp, .hxx files. Use when working with C or C++ code that needs autocomplete, go-to-definition, find references, error detection, or refactoring support. It is an AI Agent Skill for Claude Code / OpenClaw, with 1226 downloads so far.
How do I install Clangd LSP?
Run "/install clangd-lsp" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Clangd LSP free?
Yes, Clangd LSP is completely free (open-source). You can download, install and use it at no cost.
Which platforms does Clangd LSP support?
Clangd LSP is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Clangd LSP?
It is built and maintained by bowen31337 (@bowen31337); the current version is v1.0.0.