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

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

Blog post from Zed

Post Details
Company
Zed
Date Published
Author
Max Brunsfeld
Word Count
2,276
Language
English
Hacker News Points
-
Summary

Zed is a code editor designed to enhance programming flow by focusing on understanding code at a syntactic level, rather than merely its text representation. It employs the Language Server Protocol for standard language intelligence and uses Tree-sitter, an open-source parsing framework, to manage code parsing efficiently even when the code is temporarily invalid. Tree-sitter generates concrete syntax trees (CSTs) that maintain token location information, which Zed utilizes for syntax-aware features such as syntax-aware selection, multi-cursor editing, and precise syntax highlighting. Zed also supports tree queries for code analysis and symbol outlines for improved navigation, which are implemented using Tree-sitter queries for consistency across languages. Further, the editor handles auto-indentation and manages multi-language documents by injecting language rules within syntax trees. The infrastructure supporting Zed allows for rapid updates and responsive performance, contributing to a superior code-editing experience that aligns with the developer's logical thought processes.