Skip to main content

Crate reovim_driver_syntax

Crate reovim_driver_syntax 

Source
Expand description

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

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

Re-exports§

pub use bracket::BracketConfig;
pub use bracket::BracketConfigStore;
pub use bracket::BracketPair;
pub use decoration::DecorationCapture;
pub use decoration::DecorationRule;
pub use decoration::apply_rules;
pub use indent::IndentConfig;
pub use indent::IndentConfigStore;
pub use textobject::TextObjectKind;
pub use textobject::TextObjectRange;
pub use textobject::TextObjectScope;
pub use state::SyntaxSessionState;

Modules§

bracket
Bracket configuration types and store for language-aware bracket pairing.
decoration
Decoration types for the syntax driver layer.
indent
Indent configuration types and store for language-aware indent guides.
state
Per-session syntax driver storage.
textobject
Semantic text object types for treesitter-based code navigation.

Structs§

Annotation
A single annotation on a buffer range.
CommentTokens
Comment syntax for a language.
CompositeFactory
A factory that aggregates multiple SyntaxDriverFactory instances.
ContextHierarchy
Hierarchy of enclosing scopes at a cursor position.
DefaultLanguageRegistry
Concrete implementation of LanguageRegistry built from LanguageInfo entries.
FoldRange
A foldable range in the buffer.
HighlightCategory
Interned string-based highlight category.
Injection
An injection point for embedded languages.
LanguageInfo
Information about a supported language.
LanguageInfoStore
Store for language info registered by modules during init.
ScopeRange
A scope boundary range in the buffer.
SyntaxEdit
Edit information for incremental parsing.
SyntaxFactoryStore
Store for syntax driver factories registered by modules during init.

Enums§

FoldKind
Kind of fold (what construct it represents).
ModuleError
Errors that can occur during module operations.
ScopeKind
Kind of scope (what construct it represents).
SyntaxContext
Syntax context at a byte position.

Traits§

LanguageRegistry
Registry for language metadata and detection.
SyntaxCache
Cache for annotation results.
SyntaxDriver
Main parsing interface for syntax highlighting.
SyntaxDriverFactory
Factory for creating syntax drivers.

Functions§

language_id_from_path
Detect language ID from a file path’s extension.