DTS LSP Integration
This page explains how Zephyr Workbench integrates with the DeviceTree Language Server by Kyle Bonnici(DTS-LSP), what it does for you, and what to expect when working with .dts and .overlay files.
Overview
- Provides on-the-fly DTS language features (go-to, hover, diagnostics, formatting) by talking to the external
dts-lspVS Code extension. - Automatically creates and selects DTS contexts based on the file you open:
- Application overlays (
.overlay) use the app build directory’sbuild_info.ymlto derive include paths, bindings, the maindtsFile, overlays, and compile commands. - Workspace DeviceTree files (
.dtsin the Zephyr tree) use the Zephyr kernel tree to derive include and bindings paths.
- Application overlays (
- Keeps contexts in sync as files change and removes them when files close or are deleted.
How It Works
- On activation, the integration locates and activates the
dts-lspextension API. - It sets default server settings:
allowAdhocContexts: false(prevents server from creating implicit contexts)defaultShowFormattingErrorAsDiagnostics: false(reduces noise from formatting diagnostics)
- It listens to editor events and updates contexts as you open or focus
.overlayor.dtsfiles.
Application Overlay Contexts (*.overlay)

When an overlay is opened:
- The extension finds the parent Zephyr application folder and its active (or first) build configuration.
- It parses
<build_dir>/build_info.ymlto collect:include-dirs,bindings-dirs,files,user-filesandcompile_commands.json.
- It builds a DTS context payload and requests/activates it on the DTS server.
- If
build_info.ymlchanges, the extension removes the existing context first, then recreates it to avoid stale state.
What to expect
- The correct app DTS roots and bindings are used, including overlays and the main
dtsFile. - Formatting errors are not shown as diagnostics by default for a calmer experience.
Workspace DTS Contexts (zephyr/**/*.dts)

When a DTS file inside the Zephyr tree is opened:
- The extension detects the containing west workspace and Zephyr kernel directory.
- It constructs include paths from
zephyr/include,zephyr/include/zephyr,zephyr/dtsand common DTS subfolders. - It adds
zephyr/dts/bindingsfor bindings. - Vendor HAL roots: the workspace context unconditionally appends several vendor HAL roots found under
modules/hal(sibling ofzephyr). The integration keeps only those that actually exist on disk:modules/hal/adimodules/hal/atmelmodules/hal/microchipmodules/hal/nuvotonmodules/hal/gigadevicemodules/hal/stm32modules/hal/nxpmodules/hal/espressif
What to expect
- The current
.dtsfile is treated as thedtsFileof the context. - Include paths cover Zephyr core DTS folders plus the detected
modules/hal/...vendor roots present in your workspace. - Bindings are sourced from
zephyr/dts/bindingswhen present. - Contexts are recreated only when their meaningful signature changes (include paths, bindings,
dtsFile, overlays, compile commands), minimizing churn.
Working With .dtsi Files
.dtsiinclude files do not create their own full context. For include resolution and language features to work, keep the related parent.dtsfile open so its DTS context remains active in the environment.
Known Limitations / TODOs
- Vendor module detection is hard-coded. A future version should parse
west.ymland eachzephyr/module.ymlto auto-discoverdts_rootentries. .dtsifiles are intentionally skipped; the server relies on their parent.dtscontext.- For custom DTS-LSP configuration, you can always configure it manually inside
settings.jsonas mentioned in usage guide.
Troubleshooting
- Ensure the
KyleMicallefBonnici.dts-lspextension is installed and enabled. - If overlays don’t resolve correctly, run a build to ensure
build_info.ymlandcompile_commands.jsonexist. - If contexts appear stale after changing
build_info.yml, the integration removes and recreates the context automatically. If issues persist, close and reopen the file. - Restart VSCode