This repository contains a Zed extension that wires Zed’s Language Server support to the
dprint CLI running in LSP mode.
The extension does not implement formatting itself. It launches dprint lsp (by default) and
lets Zed talk to it via the Language Server Protocol.
The language server id is dprint (as defined in extension.toml). Any Zed lsp configuration
you apply must be under:
lsp.dprint
When Zed asks the extension to start the language server, the extension resolves which dprint
executable to run in this order:
- Zed settings override: if you configured
lsp.dprint.binary.path, that path is used. - Workspace
node_modulesinstall: if your worktree indicates you usedprintandnode_modules/.bin/dprintexists, that path is used.- “Indicates you use
dprint” means:package.jsoncontainsdprintindependenciesordevDependencies, ordeno.jsoncontainsdprintinimports
- Be sure to run
npm installor equivalent to installdprintinnode_modules. As Zed extension host does not have the permission to check if a binary is there.
- “Indicates you use
- System
PATH: ifdprintis found viawhich, it’s used. - Auto-install fallback: if none of the above apply, the extension downloads the latest stable
release from
dprint/dprintGitHub releases and runs it.
Notes:
- The auto-installed binary is downloaded as a GitHub release zip appropriate for your OS + CPU architecture.
x86(32-bit) is not supported by the auto-installer; in that case you must provide adprintbinary yourself.
-
If you set
lsp.dprint.binary.arguments, those arguments are used. -
Otherwise the extension starts dprint with:
-
["lsp"]
So by default it runs:
dprint lsp
Zed will attempt to use this language server for the languages declared in extension.toml:
- JavaScript
- TypeScript
- TSX
- JSON
- JSONC
- Markdown
- TOML
- CSS
- SCSS
- LESS
- HTML
- Vue.js
- Svelte
- Astro
- Angular
- Twig
- GraphQL
- YAML
- PHP
- Python
Whether formatting works for a given file still depends on your dprint configuration and plugins.
When troubleshooting, explicitly point Zed at the binary and arguments you want.
Example settings.json:
{
"lsp": {
"dprint": {
"binary": {
"path": "/absolute/path/to/dprint",
"arguments": ["lsp"]
}
}
}
}If you omit arguments, the extension defaults to ["lsp"].
This extension currently does not add or forward custom LSP settings to dprint.
If you see examples referencing settings like config_path, require_config_file,
requireConfiguration, or configurationPath, those are not implemented by this codebase.
What actually happens today:
- The extension only provides Zed a command + args (and no extra environment variables).
dprintdiscovers configuration the same way it normally does when you run it (for example, by findingdprint.json/.dprint.jsonaccording todprint’s own rules).
If you need non-default config discovery behavior, you currently must accomplish that via:
- running
dprintfrom an environment where it can find the desired config, or - using a wrapper script/binary and configuring
lsp.dprint.binary.pathto point to that wrapper (advanced).
If the extension auto-installs dprint, it:
- checks the latest stable GitHub release from
dprint/dprint - downloads the matching zip asset for your platform
- removes older
dprint-*directories/files in the extension working directory - runs the downloaded
dprintbinary
This is meant as a convenience fallback so the extension can work even when dprint is not already
installed.
Most common causes:
- The configured binary isn’t executable or isn’t the
dprintyou expect. - The binary arguments aren’t correct (if you overrode them).
- You’re on 32-bit (
x86) and relying on auto-install (unsupported).
Quick checks:
- Run the exact command Zed would run (for example
dprint lsp) in a terminal. - Temporarily set
lsp.dprint.binary.pathto a known-gooddprintand keep arguments as["lsp"].
If the language server starts but formatting seems ineffective, validate your dprint configuration
and plugins by running dprint fmt manually in the same worktree and ensuring it produces the
expected output.
- Rust toolchain (stable is fine)
wasm32-wasip2target (Zed loads Rust extensions as WASM):
rustup target add wasm32-wasip2cargo check- Open Zed
- Run
zed: install dev extensions - Select the repository directory
- After changes: open
zed: extensions, find the extension, and click Rebuild
MIT