✓ Verified 💻 Development ✓ Enhanced Data

Clangd Lsp

C/C++ language server (clangd) providing code intelligence, diagnostics, and formatting for .c, .h,

Rating
4.4 (148 reviews)
Downloads
18,725 downloads
Version
1.0.0

Overview

C/C++ language server (clangd) providing code intelligence, diagnostics, and formatting for .c, .h, .cpp, .cc.

Complete Documentation

View Source →

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)

bash
brew install llvm
# Add to PATH
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"

Via package manager (Linux)

bash
# Ubuntu/Debian
sudo apt install clangd

# Fedora
sudo dnf install clang-tools-extra

# Arch Linux
sudo pacman -S clang

Windows

bash
winget install LLVM.LLVM

Or download from LLVM releases.

Verify installation:

bash
clangd --version

Usage

The language server runs automatically in LSP-compatible editors. For manual operations:

Compile

bash
gcc file.c -o output      # C
g++ file.cpp -o output    # C++
clang file.c -o output    # with clang

Format code

bash
clang-format -i file.cpp

Static analysis

bash
clang-tidy file.cpp -- -std=c++17

Configuration

Create .clangd in project root:

yaml
CompileFlags:
  Add: [-std=c++17, -Wall, -Wextra]
  Remove: [-W*]
Diagnostics:
  UnusedIncludes: Strict
  MissingIncludes: Strict

Or compile_commands.json for complex projects:

bash
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
# or
bear -- make

Integration Pattern

When editing C/C++ code:

  • clangd uses compile_commands.json for project understanding
  • Run clang-format to format code
  • Use clang-tidy for 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 - Include path
  • -L - Library path
clang-tidy checks:
bash
clang-tidy file.cpp --checks='*' --
clang-tidy file.cpp --fix --  # Auto-fix

More Information

Installation

Terminal bash

openclaw install clangd-lsp
    
Copied!

💻Code Examples

### Via Homebrew (macOS)

-via-homebrew-macos.sh
brew install llvm
# Add to PATH
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"

### Via package manager (Linux)

-via-package-manager-linux.sh
# Ubuntu/Debian
sudo apt install clangd

# Fedora
sudo dnf install clang-tools-extra

# Arch Linux
sudo pacman -S clang

### Compile

-compile.sh
gcc file.c -o output      # C
g++ file.cpp -o output    # C++
clang file.c -o output    # with clang

bear -- make

bear----make.txt
## Integration Pattern

When editing C/C++ code:
1. clangd uses `compile_commands.json` for project understanding
2. Run `clang-format` to format code
3. Use `clang-tidy` for static analysis
4. 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<path>` - Include path
- `-L<path>` - Library path

**clang-tidy checks:**
example.yml
CompileFlags:
  Add: [-std=c++17, -Wall, -Wextra]
  Remove: [-W*]
Diagnostics:
  UnusedIncludes: Strict
  MissingIncludes: Strict
example.sh
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
# or
bear -- make

⚙️Configuration Options

Option Type Default Description
DCMAKE_EXPORT_COMPILE_COMMANDSstringON-

Tags

#coding_agents-and-ides #code

Quick Info

Category Development
Model Claude 3.5
Complexity One-Click
Author bowen31337
Last Updated 3/10/2026
🚀
Optimized for
Claude 3.5
🧠

Ready to Install?

Get started with this skill in seconds

openclaw install clangd-lsp