Syntax-Aware Task Spawning With Tree-Sitter
Zed Tasks run shell commands from the editor using variables such as $ZED_SYMBOL (filled from Tree-sitter with the enclosing symbol), $ZED_FILE and $ZED_SELECTED_TEXT. Tasks can be defined in project or global tasks.json templates, bound to keys, and rerun with reevaluate_context so variables pick up the current selection or file. Language extensions can ship runnables.scm Tree-sitter queries that tag syntax nodes such as test functions. Zed matches those tags against the tags on task definitions and places clickable play buttons in the gutter to run them.
Related posts
- Enabling low-latency, syntax-aware editing using Tree-sitter
Zed mediumAdeptZed builds its syntax-aware features on Tree-sitter, a GLR-based incremental parsing framework with error recovery that produces concrete syntax trees. Syntax-aware selection uses the CST directly. Highlighting, symbol outlines, auto-indentation and language injections are each driven by declarative Tree-sitter queries, which compile to state machines matched in a single depth-first walk, so adding a language needs only a grammar and query files. Injected trees, such as JavaScript inside HTML or Rust macro arguments, are kept in a copy-on-write B-tree called a sum tree, which lets edits be re-parsed incrementally on a background thread while the main thread keeps reading the previous snapshot.
- Zed Weekly: #17
Zed easyNoviceWeekly team update from the Zed editor team covering AI features, channels, language support and UI work. Highlights include an inline assistant that needed a custom incremental diff algorithm to apply GPT's token-by-token stream as edit hunks, an eager/lazy operation queue for the semantic index, and per-language and per-syntax-scope word-character configuration so PHP `$` variables and kebab-case Tailwind classes inside JSX autocomplete correctly. Other items cover vim relative line numbers and `.` repeat, collaborative markdown channel notes, Taffy-based layout with Tailwind-style Rust helpers, inlay hint resolve work that could shrink rust-analyzer responses by over 50%, and a version-string sorting bug that appeared when versions rolled from 0.99 to 0.100.
- Zed Has Rainbow Brackets
Zed mediumAdeptZed implements rainbow brackets without language servers or a persistent syntax tree by running each language's tree-sitter brackets.scm queries over independent 50-row chunks and coloring pairs by nesting depth across 7 cycling theme accent colors. Chunks may occasionally be off by one color at boundaries, a tradeoff accepted to avoid maintaining global bracket state. Results are cached on the buffer rather than the ephemeral editor, versioned with clock::Global, invalidated eagerly on edits and re-queried lazily only for visible ranges. Upstream tree-sitter changes that limit query search ranges keep performance acceptable, and a visual test notation annotates each bracket with its color index.
- Building a Text Editor in the Times of AI
Zed easyNoviceZed's co-founders Nathan, Max and Antonio describe how they use AI for programming. They prefer chat-style assistants with stronger models over Copilot's per-keystroke completions, and say supplying the right context is the main obstacle in a large Rust codebase. Zed's inline assist renders LLM output as live edits using a streaming diff based on a modified Needleman-Wunsch algorithm, with a cost function that favours insertions and deletions and a small lookahead. They adopted this after function-calling approaches failed to produce reliable precise edit locations. The conversation also covers plans for AI features in Zed.
- Copilot x Zed
Zed mediumAdeptGitHub Copilot is now available in Zed v0.82, integrated by reusing the undocumented, minified Copilot LSP server shipped in the Neovim plugin, which Zed's built-in LSP support could drive directly. Supporting it required a new modal UI for Copilot's device-code OAuth flow and a 'suggestions' layer in Zed's DisplayMap that splices styled multi-line text into the buffer alongside folding and wrapping, covered by randomized testing. To keep it from being intrusive, Zed added per-language disable settings and a 75ms debounce, and gives the language's real LSP autocomplete priority over Copilot on conflicts.