reovim-driver-syntax 0.14.4

Syntax highlighting driver for reovim (trait definitions only)
Documentation

Syntax highlighting driver for reovim.

IMPORTANT: This crate defines ONLY the trait interface for syntax highlighting. It does NOT depend on tree-sitter or any parsing library. Those are implementation details of language modules (server/modules/treesitter-*/).

Design Philosophy

This crate follows the Linux kernel "mechanism vs policy" principle:

  • Driver provides MECHANISM: The [HighlightCategory] type and [Annotation] struct define HOW highlights are represented (open, string-based categories).
  • Modules provide POLICY: Language modules decide WHAT categories to emit.

Architecture

server/lib/drivers/syntax/             <-- HighlightCategory, Annotation, SyntaxDriver
       ^
       |  implements
       |
server/lib/drivers/syntax-treesitter/  <-- Tree-sitter based implementations

Components

  • [SyntaxDriver] - Main parsing and highlighting interface
  • [SyntaxDriverFactory] - Creates drivers for languages
  • [LanguageRegistry] - Language detection and metadata
  • [SyntaxCache] - Highlight result caching
  • [HighlightCategory] - Open string-based highlight categories
  • [Annotation] - A highlighted byte range with category and kind
  • [SyntaxEdit] - Edit description for incremental parsing
  • [FoldRange], [FoldKind] - Foldable code regions
  • [Injection] - Embedded language regions
  • [LanguageInfo], [CommentTokens] - Language metadata

Example

use reovim_driver_syntax::*;

// Factory creates drivers for supported languages
let factory: Box<dyn SyntaxDriverFactory> = get_factory();

// Create driver for Rust
let mut driver = factory.create("rust").unwrap();

// Parse content
driver.parse("fn main() { println!(\"Hello\"); }");

// Get highlights for rendering
let highlights = driver.highlights(0..100);
for ann in highlights {
    println!("{:?}: {}", ann.byte_range(), ann.category.as_str());
}

NO tree-sitter dependency!

This crate must NOT depend on tree-sitter or any parsing library. Tree-sitter is an implementation detail of language modules.