Koi Editor Uses Handwritten Lexers for Faster Syntax Highlighting and Folding
Koi Editor takes a direct approach to syntax highlighting by using small, language-specific handwritten lexers instead of declarative grammar systems or syntax trees used by editors like Sublime Text and Zed. Each lexer is purpose-built code that decides how text should be styled and folded without a generic engine in between. This design also enables syntax-aware folding, allowing code blocks to remain foldable even when indentation alone cannot determine structure. In performance benchmarks, Koi was able to apply syntax highlighting to files with millions of lines, while Sublime Text and Zed reportedly became unusable at much smaller scales. The developer attributes this efficiency to the lexers doing minimal work per token, tracking only token type, carry-forward state, and fold level.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in