Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Clangd Auto ConfigNew to Visual Studio Code? Get it now.
Clangd Auto Config

Clangd Auto Config

clangd-autoconfig

|
100 installs
| (0) | Free
Automatically generate compile_commands.json and .clangd configuration files for C/C++ projects
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Clangd Auto Config Extension

A VSCode extension that automatically generates compile_commands.json and .clangd configuration files for C/C++ projects, and intelligently filters out unused source files to help Clangd focus on analyzing the actual compiled code.

Features

  1. 🚀 One-Click Compilation DB Generation: Run compiledb -n make (configurable) to generate compile_commands.json
  2. 🔍 Auto-Resolve Implicit #include "xxx.c" Files: Automatically detect and inject compile records for hidden .c files that are #include-ed by other source files
  3. ⚙️ One-Click .clangd Generation: Convert the VSCode settings template into a .clangd YAML configuration file
  4. 🧹 Smart File Filtering: Automatically hide un-compiled .c/.h files via files.exclude based on compile_commands.json
  5. 🛡️ Whitelist Protection: tools, scripts, lib, python, doc, and other folders are never hidden by default
  6. 🎯 Header Exclusive Filtering: When enabled, only selected .h files in a directory are kept visible; all others are hidden
  7. 📋 Custom Glob Exclude Rules: Support additional file exclusion via glob patterns (equivalent to regex)
  8. 📦 Webview Sidebar Panel: GUI with real-time status display and one-click operations
  9. 📌 Standalone Filter Command: Run source file filtering independently without regenerating the compilation database

Requirements

  • VSCode 1.60.0 or higher
  • compiledb tool installed (pip install compiledb)
  • The project must be buildable with make (or a custom build command)

Installation

  1. Clone or download this extension
  2. Open VSCode and go to Extensions view
  3. Click ··· → Install from VSIX... and select the extension package
  4. Or run vsce package in the extension directory to build it yourself

Usage

Method 1: Sidebar (Recommended)

  1. Click the Clangd Config icon 🚀 in the VSCode activity bar
  2. Configure parameters in the sidebar panel:
    • Make subdirectory: Relative path if make should run in a subdirectory
    • Custom Glob excludes: Additional file patterns to exclude (one per line)
    • Enable header exclusive filtering: Check, then pick the .h files you want to keep
  3. Click 💾 Save Config to save filter rules
  4. Click 🚀 Generate Config to run the full pipeline

Method 2: Command Palette

Press Ctrl+Shift+P and run one of these commands:

Command Description
Clangd: 生成配置并过滤工程 Full pipeline: compile DB → resolve implicit .c → generate .clangd → filter files
Clangd: 手动执行源码过滤 Run file filtering only (based on existing compile_commands.json)

Configuration

Search for clangd-autoconfig in VSCode settings:

clangd-autoconfig.compiledbCommand

Command to generate compile_commands.json. Default: compiledb -n make

clangd-autoconfig.makeDirectory

Make subdirectory (relative to workspace root). Default: "" (empty = run at workspace root)

clangd-autoconfig.whitelistFolders

Whitelisted folders that will never be hidden. Default: ["tools", "scripts", "lib", "python", "doc", ".vscode", ".git", "out"]

clangd-autoconfig.customGlobExcludes

Custom glob exclude patterns (equivalent to regex). Default: []

clangd-autoconfig.enableHeaderExclusive

Enable header exclusive filtering mode. Default: false

clangd-autoconfig.activeHeaderFiles

List of active header file paths to keep. Default: []

clangd-autoconfig.defaultClangdConfig

Default .clangd configuration template.

Example:

{
    "clangd-autoconfig.defaultClangdConfig": {
        "CompileFlags": {
            "InheritFromEnvironment": false,
            "Add": ["-std=c++17"]
        },
        "Index": {
            "Background": "Build",
            "BackgroundWorkers": 8
        },
        "General": {
            "MemoryUsage": "1000MB"
        }
    }
}

How It Works

Full Pipeline (generateConfig)

compiledb -n make  →  compile_commands.json
         │
         ├─ Scan #include "xxx.c" → inject compile records for hidden .c files
         │
         ├─ Generate .clangd (YAML format from settings template)
         │
         └─ Traverse workspace, analyze against compile_commands.json:
              ├─ Compiled .c/.cpp → keep visible
              ├─ Un-compiled .c/.cpp → hide via files.exclude
              ├─ Header directories → smart detection via -I/-isystem paths
              └─ Whitelist folders → always keep visible

File Filtering Logic

  • Whitelist first: Whitelisted folders and their contents are never hidden
  • Implicit .c patching: When #include "foo.c" is found but foo.c is not in the compile DB, the parent file's compile command is cloned and injected
  • Header exclusive mode: When enabled, unselected .h files in the same directory as selected ones are hidden
  • Custom Globs: Supports any glob pattern that VSCode files.exclude accepts

Technical Highlights

  • Pure Node.js: No external dependencies, low overhead
  • Native VSCode API: Uses files.exclude workspace setting — no actual filesystem changes
  • Webview Panel: Adapts to VSCode theme (dark/light)
  • Incremental Updates: Preserves existing files.exclude rules, only appends new ones

Troubleshooting

  • compiledb not found: Install it with pip install compiledb
  • Permission denied: Make sure VSCode has write access to the workspace directory
  • compile_commands.json not generated: Verify make runs successfully in your project directory
  • Files not hidden: Check whitelist settings — remove folders from whitelist if you want them filtered
  • Hidden files still shown: files.exclude only hides files in the VSCode UI; it does not affect compilation

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft