Move language-specific debugging docs to the page for each language (#33692)

Release Notes:

- N/A
This commit is contained in:
Cole Miller
2025-07-01 20:02:12 +00:00
committed by GitHub
parent 0e2e5b8b0d
commit b7bfdd3383
13 changed files with 411 additions and 345 deletions
+23
View File
@@ -4,6 +4,7 @@ C support is available natively in Zed.
- Tree-sitter: [tree-sitter/tree-sitter-c](https://github.com/tree-sitter/tree-sitter-c)
- Language Server: [clangd/clangd](https://github.com/clangd/clangd)
- Debug Adapter: [CodeLLDB](https://github.com/vadimcn) (primary), [GDB](https://sourceware.org/gdb/) (secondary, not available on Apple silicon)
## Clangd: Force detect as C
@@ -61,3 +62,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
```
After building your project, CMake will generate the `compile_commands.json` file in the build directory and clangd will automatically pick it up.
## Debugging
You can use CodeLLDB or GDB to debug native binaries. (Make sure that your build process passes `-g` to the C compiler, so that debug information is included in the resulting binary.) See below for examples of debug configurations that you can add to `.zed/debug.json`.
### Build and Debug Binary
```json
[
{
"label": "Debug native binary",
"build": {
"command": "make",
"args": ["-j8"],
"cwd": "$ZED_WORKTREE_ROOT"
}
"program": "$ZED_WORKTREE_ROOT/build/prog",
"request": "launch",
"adapter": "CodeLLDB"
}
]
```
+22
View File
@@ -112,3 +112,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
```
After building your project, CMake will generate the `compile_commands.json` file in the build directory and clangd will automatically pick it up.
## Debugging
You can use CodeLLDB or GDB to debug native binaries. (Make sure that your build process passes `-g` to the C++ compiler, so that debug information is included in the resulting binary.) See below for examples of debug configurations that you can add to `.zed/debug.json`.
### Build and Debug Binary
```json
[
{
"label": "Debug native binary",
"build": {
"command": "make",
"args": ["-j8"],
"cwd": "$ZED_WORKTREE_ROOT"
}
"program": "$ZED_WORKTREE_ROOT/build/prog",
"request": "launch",
"adapter": "CodeLLDB"
}
]
```
+107
View File
@@ -4,6 +4,7 @@ Go support is available natively in Zed.
- Tree-sitter: [tree-sitter/tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go)
- Language Server: [golang/tools/tree/master/gopls](https://github.com/golang/tools/tree/master/gopls)
- Debug Adapter: [delve](https://github.com/go-delve/delve)
## Setup
@@ -72,6 +73,112 @@ to override these settings.
See [gopls inlayHints documentation](https://github.com/golang/tools/blob/master/gopls/doc/inlayHints.md) for more information.
## Debugging
Zed supports zero-configuration debugging of Go tests and entry points (`func main`). Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these preconfigured debug tasks.
For more control, you can add debug configurations to `.zed/debug.json`. See below for examples.
### Debug Go Packages
To debug a specific package, you can do so by setting the Delve mode to "debug". In this case "program" should be set to the package name.
```json
[
{
"label": "Go (Delve)",
"adapter": "Delve",
"program": "$ZED_FILE",
"request": "launch",
"mode": "debug"
},
{
"label": "Run server",
"adapter": "Delve",
"request": "launch",
"mode": "debug",
// For Delve, the program can be a package name
"program": "./cmd/server"
// "args": [],
// "buildFlags": [],
}
]
```
### Debug Go Tests
To debug the tests for a package, set the Delve mode to "test".
The "program" is still the package name, and you can use the "buildFlags" to do things like set tags, and the "args" to set args on the test binary. (See `go help testflags` for more information on doing that).
```json
[
{
"label": "Run integration tests",
"adapter": "Delve",
"request": "launch",
"mode": "test",
"program": ".",
"buildFlags": ["-tags", "integration"]
// To filter down to just the test your cursor is in:
// "args": ["-test.run", "$ZED_SYMBOL"]
}
]
```
### Build and debug separately
If you need to build your application with a specific command, you can use the "exec" mode of Delve. In this case "program" should point to an executable,
and the "build" command should build that.
```json
[
{
"label": "Debug Prebuilt Unit Tests",
"adapter": "Delve",
"request": "launch",
"mode": "exec",
"program": "${ZED_WORKTREE_ROOT}/__debug_unit",
"args": ["-test.v", "-test.run=${ZED_SYMBOL}"],
"build": {
"command": "go",
"args": [
"test",
"-c",
"-tags",
"unit",
"-gcflags\"all=-N -l\"",
"-o",
"__debug_unit",
"./pkg/..."
]
}
}
]
```
### Attaching to an existing instance of Delve
You might find yourself needing to connect to an existing instance of Delve that's not necessarily running on your machine; in such case, you can use `tcp_arguments` to instrument Zed's connection to Delve.
```json
[
{
"adapter": "Delve",
"label": "Connect to a running Delve instance",
"program": "/Users/zed/Projects/language_repositories/golang/hello/hello",
"cwd": "/Users/zed/Projects/language_repositories/golang/hello",
"args": [],
"env": {},
"request": "launch",
"mode": "exec",
"stopOnEntry": false,
"tcp_connection": { "host": "123.456.789.012", "port": 53412 }
}
]
```
In such case Zed won't spawn a new instance of Delve, as it opts to use an existing one. The consequence of this is that _there will be no terminal_ in Zed; you have to interact with the Delve instance directly, as it handles stdin/stdout of the debuggee.
## Go Mod
- Tree-sitter: [camdencheek/tree-sitter-go-mod](https://github.com/camdencheek/tree-sitter-go-mod)
+49
View File
@@ -4,6 +4,7 @@ JavaScript support is available natively in Zed.
- Tree-sitter: [tree-sitter/tree-sitter-javascript](https://github.com/tree-sitter/tree-sitter-javascript)
- Language Server: [typescript-language-server/typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)
- Debug Adapter: [vscode-js-debug](https://github.com/microsoft/vscode-js-debug)
## Code formatting
@@ -174,6 +175,54 @@ You can configure ESLint's `workingDirectory` setting:
}
```
## Debugging
Zed supports debugging JavaScript code out of the box.
The following can be debugged without writing additional configuration:
- Tasks from `package.json`
- Tests written using several popular frameworks (Jest, Mocha, Vitest, Jasmine)
Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these predefined debug tasks.
As for all languages, configurations from `.vscode/launch.json` are also available for debugging in Zed.
If your use-case isn't covered by any of these, you can take full control by adding debug configurations to `.zed/debug.json`. See below for example configurations.
### Debug the current file
```json
[
{
"adapter": "JavaScript",
"label": "Debug JS file",
"type": "node",
"request": "launch",
"program": "$ZED_FILE",
"skipFiles": ["<node_internals>/**"]
}
]
```
This implicitly runs the current file using `node`.
### Launch a web app in Chrome
```json
[
{
"adapter": "JavaScript",
"label": "Debug app in Chrome",
"type": "chrome",
"request": "launch",
"file": "$ZED_WORKTREE_ROOT/index.html",
"webRoot": "$ZED_WORKTREE_ROOT",
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"]
}
]
```
## See also
- [Yarn documentation](./yarn.md) for a walkthrough of configuring your project to use Yarn.
+65
View File
@@ -6,6 +6,7 @@ Python support is available natively in Zed.
- Language Servers:
- [microsoft/pyright](https://github.com/microsoft/pyright)
- [python-lsp/python-lsp-server](https://github.com/python-lsp/python-lsp-server) (PyLSP)
- Debug Adapter: [debugpy](https://github.com/microsoft/debugpy)
## Language Servers
@@ -125,3 +126,67 @@ A common tool for formatting Python code is [Ruff](https://docs.astral.sh/ruff/)
TBD: Expand Python Ruff docs.
TBD: Ruff pyproject.toml, ruff.toml docs. `ruff.configuration`.
-->
## Debugging
Zed supports zero-configuration debugging of Python module entry points and pytest tests.
Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list for the current project.
For greater control, you can add debug configurations to `.zed/debug.json`. See the examples below.
### Debug Active File
```json
[
{
"label": "Python Active File",
"adapter": "Debugpy",
"program": "$ZED_FILE",
"request": "launch"
}
]
```
### Flask App
For a common Flask Application with a file structure similar to the following:
```
.venv/
app/
init.py
main.py
routes.py
templates/
index.html
static/
style.css
requirements.txt
```
…the following configuration can be used:
```json
[
{
"label": "Python: Flask",
"adapter": "Debugpy",
"request": "launch",
"module": "app",
"cwd": "$ZED_WORKTREE_ROOT",
"env": {
"FLASK_APP": "app",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"--reload", // Enables Flask reloader that watches for file changes
"--debugger" // Enables Flask debugger
],
"autoReload": {
"enable": true
},
"jinja": true,
"justMyCode": true
}
]
```
+13 -12
View File
@@ -9,6 +9,7 @@ Ruby support is available through the [Ruby extension](https://github.com/zed-ex
- [ruby-lsp](https://github.com/Shopify/ruby-lsp)
- [solargraph](https://github.com/castwide/solargraph)
- [rubocop](https://github.com/rubocop/rubocop)
- Debug Adapter: [`rdbg`](https://github.com/ruby/debug)
The Ruby extension also provides support for ERB files.
@@ -43,15 +44,15 @@ For all supported Ruby language servers (`solargraph`, `ruby-lsp`, `rubocop`, `s
You can skip step 1 and force using the system executable by setting `use_bundler` to `false` in your settings:
```jsonc
```json
{
"lsp": {
"<SERVER_NAME>": {
"settings": {
"use_bundler": false,
},
},
},
"use_bundler": false
}
}
}
}
```
@@ -349,21 +350,21 @@ The Ruby extension provides a debug adapter for debugging Ruby code. Zed's name
#### Debug a Ruby script
```jsonc
```json
[
{
"label": "Debug current file",
"adapter": "rdbg",
"request": "launch",
"script": "$ZED_FILE",
"cwd": "$ZED_WORKTREE_ROOT",
},
"cwd": "$ZED_WORKTREE_ROOT"
}
]
```
#### Debug Rails server
```jsonc
```json
[
{
"label": "Debug Rails server",
@@ -373,8 +374,8 @@ The Ruby extension provides a debug adapter for debugging Ruby code. Zed's name
"args": ["server"],
"cwd": "$ZED_WORKTREE_ROOT",
"env": {
"RUBY_DEBUG_OPEN": "true",
},
},
"RUBY_DEBUG_OPEN": "true"
}
}
]
```
+45
View File
@@ -4,6 +4,7 @@ Rust support is available natively in Zed.
- Tree-sitter: [tree-sitter/tree-sitter-rust](https://github.com/tree-sitter/tree-sitter-rust)
- Language Server: [rust-lang/rust-analyzer](https://github.com/rust-lang/rust-analyzer)
- Debug Adapter: [CodeLLDB](https://github.com/vadimcn/codelldb) (primary), [GDB](https://sourceware.org/gdb/) (secondary, not available on Apple silicon)
<!--
TBD: Polish Rust Docs. Zed is a good rust editor, good Rust docs make it look like we care about Rust (we do!)
@@ -291,3 +292,47 @@ There's a way get custom completion items from rust-analyzer, that will transfor
}
}
```
## Debugging
Zed supports debugging Rust binaries and tests out of the box. Run {#action debugger::Start} ({#kb debugger::Start}) to launch one of these preconfigured debug tasks.
For more control, you can add debug configurations to `.zed/debug.json`. See the examples below.
### Build binary then debug
```json
[
{
"label": "Build & Debug native binary",
"build": {
"command": "cargo",
"args": ["build"]
},
"program": "$ZED_WORKTREE_ROOT/target/debug/binary",
// sourceLanguages is required for CodeLLDB (not GDB) when using Rust
"sourceLanguages": ["rust"],
"request": "launch",
"adapter": "CodeLLDB"
}
]
```
### Automatically locate a debug target based on build command
When you use `cargo build` or `cargo test` as the build command, Zed can infer the path to the output binary.
```json
[
{
"label": "Build & Debug native binary",
"adapter": "CodeLLDB"
"build": {
"command": "cargo",
"args": ["build"]
},
// sourceLanguages is required for CodeLLDB (not GDB) when using Rust
"sourceLanguages": ["rust"]
}
]
```
+38
View File
@@ -5,6 +5,7 @@ TypeScript and TSX support are available natively in Zed.
- Tree-sitter: [tree-sitter/tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript)
- Language Server: [yioneko/vtsls](https://github.com/yioneko/vtsls)
- Alternate Language Server: [typescript-language-server/typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)
- Debug Adapter: [vscode-js-debug](https://github.com/microsoft/vscode-js-debug)
<!--
TBD: Document the difference between Language servers
@@ -155,6 +156,43 @@ When using `vtsls`:
}
```
## Debugging
Zed supports debugging TypeScript code out of the box.
The following can be debugged without writing additional configuration:
- Tasks from `package.json`
- Tests written using several popular frameworks (Jest, Mocha, Vitest, Jasmine)
Run {#action debugger::Start} ({#kb debugger::Start}) to see a contextual list of these predefined debug tasks.
As for all languages, configurations from `.vscode/launch.json` are also available for debugging in Zed.
If your use-case isn't covered by any of these, you can take full control by adding debug configurations to `.zed/debug.json`. See below for example configurations.
### Attach debugger to a server running in web browser (`npx serve`)
Given an externally-ran web server (e.g., with `npx serve` or `npx live-server`) one can attach to it and open it with a browser.
```json
[
{
"label": "Launch Chrome (TypeScript)",
"adapter": "JavaScript",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5500",
"program": "$ZED_FILE",
"webRoot": "${ZED_WORKTREE_ROOT}",
"build": {
"command": "npx",
"args": ["tsc"]
},
"skipFiles": ["<node_internals>/**"]
}
]
```
## See also
- [Zed Yarn documentation](./yarn.md) for a walkthrough of configuring your project to use Yarn.