Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Zed 6 min read Deep dive mediumAdept

Zed Has Rainbow Brackets

Zed 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.

Assumes: tree-sitter queriestext editor architecture

Related posts

  • Enabling low-latency, syntax-aware editing using Tree-sitter

    Zed mediumAdept

    Zed 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 easyNovice

    Weekly 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.

  • Extensible Language Support in Zed - Part 1

    Zed mediumAdept

    Zed loads third-party Tree-sitter grammars as WebAssembly modules using a hybrid design. Native code consumes the parser's static parse tables after they are copied out of wasm linear memory, while only the lexing functions, including hand-written external scanners, run inside Wasmtime. This avoids depending on the user's C compiler and keeps buggy scanners from crashing the editor. It also avoids copying large syntax trees out of wasm memory on every keystroke. A new `WasmStore` API lets wasm-loaded languages behave identically to native ones, and a bundled mini-libc with a bump allocator that is reset each parse makes scanner memory leaks impossible.

  • Zed Weekly: #18

    Zed easyNovice

    Zed's semantic index now batches embedding requests by token count rather than span count, cutting OpenAI requests and improving throughput and consistency. A new embeddings cache skips re-embedding unchanged tree-sitter spans and reduces incremental indexing tokens by about 75%. The first inline AI assistant has merged. Other updates: Tailwind completions using multiple language servers per file, automatic Python virtualenv activation in v0.102, reconnection handling for collaborative channel notes, rust-analyzer inlay hint fixes, and progress on replace-in-buffer search.

  • Zed Weekly: #21

    Zed easyNovice

    Weekly team update from the Zed editor team. It covers initial Prettier integration and better LSP server log display, a storybook CLI for rendering new GPUI UI components in isolation, and Vim mode's command palette shipping to preview. Julia explains why vertical cursor movement drifts with mixed scripts, multi-codepoint graphemes like ZWJ emoji, and proportional fonts, and proposes tracking an intended pixel x-position resolved like a mouse click, which costs more compute. Other items include ClickHouse dashboard query optimization (minutes to under 10 seconds), the Semantic Index shipping to stable, cross-project following for channel notes, and CRDT Lamport-timestamp-based change notifications.

The quest for software engineering knowledge.

Look:
Layout: