Home / Companies / Zed / Blog / Post Details
Content Deep Dive

Zed Has Rainbow Brackets

Blog post from Zed

Post Details
Company
Zed
Date Published
Author
Kirill Bulatov
Word Count
1,687
Language
English
Hacker News Points
-
Summary

Zed has introduced a highly requested feature called rainbow brackets, which aids developers in visually distinguishing nested code blocks by coloring brackets at different nesting levels. This feature, available on the stable release, was built using Zed's architecture that primarily leverages tree-sitter and language servers but differs from other implementations like VS Code by not storing entire syntax trees in memory. Instead, Zed uses a chunk-based approach, dividing buffers into non-overlapping 50-row segments, allowing efficient bracket colorization without maintaining global bracket state. This design decision ensures that bracket data is stored in buffers rather than ephemeral editors, with queries only executed when needed. The feature also allows customization via theme overrides and per-language settings. The implementation involved significant testing, visual notation for bracket coloring, and performance optimizations to ensure efficiency even with complex grammars. Future enhancements may include extending this concept to HTML and JSX tag pairs and refining the feature based on user feedback.