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
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install clangd-lsp - 安装完成后,直接呼叫该 Skill 的名称或使用
/clangd-lsp触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
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. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1226 次。
如何安装 Clangd LSP?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install clangd-lsp」即可一键安装,无需额外配置。
Clangd LSP 是免费的吗?
是的,Clangd LSP 完全免费(开源免费),可自由下载、安装和使用。
Clangd LSP 支持哪些平台?
Clangd LSP 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Clangd LSP?
由 bowen31337(@bowen31337)开发并维护,当前版本 v1.0.0。