Expand description
Renderer-agnostic syntax-highlighting pipeline for the hjkl editor stack.
Owns a SyntaxWorker background thread (holding the Highlighter
and retained tree_sitter::Tree) plus a main-thread RenderCache of
(source, row_starts). Call
SyntaxLayer::set_language_for_path after opening a file, then
SyntaxLayer::apply_edits for each frame’s queued
hjkl_engine::ContentEdit batch and SyntaxLayer::submit_render
to enqueue a parse + viewport-scoped highlight on the worker. Drain
results via SyntaxLayer::take_all_results each frame and route them
to the correct per-slot cache field.
§Design
Output is renderer-agnostic: RenderOutput::spans carries
(byte_start, byte_end, StyleSpec) triples rather than
renderer-specific style types. A TUI adapter ([hjkl-syntax-tui]) maps
these to ratatui::style::Style; a future GUI adapter will map them to
cosmic_text attributes.
Structs§
- Color
- Resolved RGBA color (all channels 0–255).
- Diag
Sign - A single diagnostic sign emitted from the syntax pipeline.
- Modifiers
- Per-character text modifiers.
- Perf
Breakdown - Per-call sub-step timings exposed to apps’
:perfoverlay. Recorded on the worker side and shipped back insideRenderOutput. - Render
Output - Per-frame output of the syntax worker.
- Style
Spec - Foreground, background, and modifier flags for a syntax or UI element.
- Syntax
Layer - Per-App syntax highlighting layer. Multiplexes per-buffer state (helix-style): each open buffer carries its own retained tree (worker-side) plus source-cache and edit queue (here). One worker thread serves all buffers.
- Syntax
Worker - Background worker that owns the
Highlighterand the retained tree-sitterTree. Communicates with the main thread via aMutex<Pending>+Condvarfor submits, and an mpsc channel for rendered output.
Enums§
- Load
Event - Event emitted by
SyntaxLayer::poll_pending_loadsfor each handle that resolved during the tick. - Load
Event Kind - Exhaustive view of a
LoadEventfor use inSyntaxLayer::dispatch_load_eventcallbacks. - Parse
Kind - Discriminates the purpose of a parse request / result so the App can route it to the correct per-slot cache field.
- Parse
Kind Kind - Exhaustive view of a
ParseKindfor use inSyntaxLayer::dispatch_parse_kindcallbacks. - SetLanguage
Outcome - Outcome of
SyntaxLayer::set_language_for_path.
Functions§
- build_
by_ row - Resolve flat highlight spans into a per-row span table sized to
row_count. Pulled out so the worker can call it in isolation and tests can exercise it without a running thread. - layer_
with_ theme - Build a
SyntaxLayerusing the given theme + language directory.
Type Aliases§
- Buffer
Id - Stable identifier for an open buffer. Assigned by the App; carried through every syntax-pipeline message so the worker can multiplex per-buffer tree state.