Files
Build-System/docs/build-system/consumer/editors.md
T

7.1 KiB

title, description, section, badge, order, tags, updated
title description section badge order tags updated
Editors, Compilation Databases and Presets Publish compile_commands.json per profile, generate editor configs, consume the CMake File API shim, and import CMake presets Editors & Daemon IDE 1
compile_commands
clangd
vscode
zed
clion
cmake-file-api
presets
ide
2026-12-06

Editors, Compilation Databases and Presets

VBS never approximates commands from filenames or flags. The compilation database is projected from the same configured graph that execution uses, with physical paths rewritten to editable logical sources and immutable generated views. The description files themselves (build.cpp, build.profiles.cpp, build-support/) also appear as entries so clangd can complete and navigate the build description.

Compilation database model

project/
├── compile_commands.json             # managed alias, only if absent or VBS-owned
├── .vbs/editor_selection.json        # authoritative selection: ticket, profile, generation
└── build/
    ├── compile_commands.json         # active build-root alias (symlink/pointer)
    └── profiles/debug/
        ├── compile_commands.json     # the profile's selected database
        └── editor/
            ├── status.json           # generation status, diagnostic, entry count
            └── generations/<id>/compile_commands.json
  • A single-profile build publishes its generation and updates selection unless --editor-profile redirects it. A multi-profile build requires --editor-profile to choose which selected profile may publish.
  • Generation publication is atomic. Late completions compare a monotonic ticket and cannot overwrite a newer selection.
  • A failed configuration marks the profile stale or invalid. The last valid database stays identifiable instead of being replaced with fabricated commands.
  • A watcher refresh updates the already-selected profile but never steals selection.
  • An unrelated user-owned project-root compile_commands.json is preserved, never overwritten.
vbs compdb export --profile debug
vbs compdb use release
vbs compdb show
vbs compdb watch --profile debug

vbs compdb export evaluates the description, probes the toolchain, publishes the database and exits without compiling project targets. It does not select the profile on a fresh tree; run vbs compdb use PROFILE or a build to make it active. vbs compdb watch is metadata-only: it may rebuild local descriptions and run known native probes/scanners, but it never fetches packages, updates the lock, configures CMake/Meson or runs generators.

vbs ide generate and vbs ide query publish the profile database but select it only when no editor selection exists. If a different profile is already selected, their .clangd and editor settings point at that selected database; use vbs compdb use <profile> to switch.

Editor configuration

vbs ide generate --editor all
vbs ide generate --editor vscode
vbs ide generate --editor vscode --force
Editor Files written
clangd .clangd with GCC-16 flag sanitization and a compilation-database path
VS Code / Cursor .vscode/tasks.json, .vscode/launch.json, .vscode/settings.json
Zed .zed/tasks.json, .zed/debug.json
CLion .idea/customTargets.xml

The generated VS Code and Zed task sets include build, test, clean, install and package-installer entries. Launch/debug configurations are per runnable target. Existing files are skipped unless --force is given.

vbs ide query emits versioned JSON consumed by editor extensions:

{
  "schema_version": 1,
  "project_root": "/path/to/project",
  "build_root": "/path/to/project/build",
  "profile": "debug",
  "profile_identity": "…",
  "compiler_family": "gcc",
  "c_compiler": "/path/to/gcc",
  "cxx_compiler": "/path/to/g++",
  "sdk_include_dir": "/path/to/vbs/include",
  "compdb_path": "/path/to/project/build/compile_commands.json",
  "targets": [
    {
      "name": "app",
      "kind": "executable",
      "enabled": true,
      "is_executable": true,
      "is_test": false,
      "sources": ["src/main.cpp"],
      "primary_outputs": ["/path/to/project/build/profiles/debug/out/bin/app"],
      "runtime_shared_libraries": []
    }
  ]
}

vbs compdb-entries --file src/main.cpp --limit 20 returns bounded entries from the active database for plugins that do not want to parse the whole file. Limits and argument lengths are capped.

CMake File API shim

vbs ide generate regenerates a CMake File API reply tree:

build/.cmake/api/v1/reply/
├── index-<hash>.json
├── codemodel-v2-<hash>.json
├── cmakeFiles-v1-<hash>.json
├── toolchains-v1-<hash>.json
├── cache-v2-<hash>.json
├── directory-<hash>.json
└── target-<hash>.json

The codemodel includes target type, artifacts, nameOnDisk, sources and compile groups (language, command fragments, defines, includes). The full reply set lets CMake-aware IDEs such as CLion and VS Code CMake Tools read a VBS project without CMake being installed.

Import CMake presets

vbs presets
vbs presets --name linux-debug

vbs presets reads CMakePresets.json (or --file), resolves inherits as a string or array with cycle detection, expands ${sourceDir}, merges cacheVariables, and maps:

  • CMAKE_BUILD_TYPE → profile;
  • CMAKE_CXX_COMPILER → compiler override.

It lists the mapping or prints the equivalent vbs build command. It does not write a description file. For a generated scaffold, use vbs migrate.

Editor extensions

vbs ide plugin --editor vscode --output build/plugin
vbs ide plugin --editor vscode --output build/plugin --vsix build/vbs.vsix
vbs ide plugin --editor zed --output build/zed-plugin
vbs ide plugin --editor clion --output build/clion-plugin
  • VS Code assets include package.json with six commands, extension.js, a README, and a mock-tested test/extension.test.js. --vsix packages a real installable extension (ZIP with extension.vsixmanifest and [Content_Types].xml).
  • Zed assets include extension.toml, tasks.json and a README.
  • CLion assets include plugin.xml with Tools-menu actions, a Kotlin action source, build.gradle.kts and a README.

The generated extension runs vbs from PATH; set VBS_BIN when the binary is elsewhere. Published plugin repositories live at VbsVsCode, VbsZed and VbsCLion.

:::callout{type="info" title="Daemon-backed editors"} Editor extensions can avoid spawning a fresh vbs process per action by talking to the daemon. vbs daemon ide query|generate|poll|wait|status|configs, vbs daemon compdb export|use|entries|generations and vbs daemon target info|flags expose the same metadata over a local socket. See Editors and the daemon. :::

Next steps