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

|
1 install
| (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.

Features

  1. Automatic Generation: One-click generation of compile_commands.json using compiledb command
  2. Configurable: Customize the compilation database generation command
  3. Smart Configuration: Load global variables from .config file and add them to .clangd as compiler defines
  4. Customizable Template: Modify the default .clangd configuration template in VSCode settings
  5. Background Indexing: Optimized for performance with background indexing and multiple workers
  6. Real-time Monitoring: Auto-update .clangd configuration when .config or config.* files change
  7. Conditional Branch Support: Correctly parse Makefile-style conditional branches in configuration files
  8. Variable Resolution: Resolve Makefile-style variable references (e.g., $(VAR_NAME))
  9. Duplicate Macro Prevention: Avoid duplicate macro definitions in generated configuration
  10. Webview Sidebar: Real-time status display and quick access to functionality

Requirements

  • VSCode 1.60.0 or higher
  • compiledb tool installed (pip install compiledb)

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 npm install and vsce package to build the extension

Usage

  1. Open your C/C++ project in VSCode
  2. Press Ctrl+Shift+P to open the Command Palette
  3. Type "Generate Clangd Configuration" and select the command
  4. The extension will:
    • Generate compile_commands.json using the configured command
    • Load global variables from .config file (if exists)
    • Generate .clangd configuration file with merged settings

Configuration

You can customize the extension behavior in VSCode settings:

clangd-autoconfig.compiledbCommand

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

clangd-autoconfig.defaultClangdConfig

Default .clangd configuration template. Modify this to change the default settings.

Example:

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

How It Works

  1. Generate compile_commands.json: Executes the configured compiledb command in the workspace root
  2. Load .config Variables: Parses .config file for variable definitions (e.g., VARIABLE=value)
  3. Generate .clangd: Creates a YAML configuration file with:
    • Default settings from the template
    • Global variables from .config as -D compiler defines

Troubleshooting

  • compiledb not found: Install it using pip install compiledb
  • Permission denied: Ensure VSCode has write access to the workspace directory
  • Config file not loaded: Check that .config exists in the workspace root with valid variable definitions

License

MIT

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