editor-core-sublime
editor-core-sublime provides a lightweight .sublime-syntax syntax highlighting + folding
engine for editor-core.
It is intended for headless/editor-kernel usage: it produces style intervals and fold regions that
can be applied to an EditorStateManager without requiring any particular UI.
Features
- Load and compile Sublime Text YAML-based
.sublime-syntaxdefinitions. - Supports common Sublime features used for highlighting and folding:
- contexts, includes, meta scopes
- basic inheritance via
extends - multi-line context folding
- Highlight documents into:
- style intervals (
Interval, in character offsets) - fold regions (
FoldRegion, in logical line ranges)
- style intervals (
- Stable mapping between Sublime scopes and editor
StyleIds viaSublimeScopeMapper. SublimeProcessorimplementseditor_core::processing::DocumentProcessorand emitsProcessingEditupdates (StyleLayerId::SUBLIME_SYNTAX+ folding edits).
Design overview
This crate keeps the output format aligned with editor-core:
- All interval offsets are character offsets (not byte offsets).
- Highlighting produces a “derived state” patch (
ProcessingEdit) that the host applies to the editor state manager. - Folding regions can optionally preserve user-collapsed state across re-highlighting passes.
The low-level engine is exposed via highlight_document, and the high-level integration via
SublimeProcessor.
Quick start
Add the dependency
[]
= "0.1"
= "0.1"
Highlight and apply derived state
use EditorStateManager;
use DocumentProcessor;
use ;
let mut state = new;
// Load a syntax (from YAML, from file, or from a reference via search paths).
let mut set = new;
let syntax = set.load_from_str.unwrap;
let mut processor = new;
let edits = processor.process.unwrap;
state.apply_processing_edits;
// Render using `state.get_viewport_content_styled(...)`.
Notes
.sublime-syntaxis a large format; this crate focuses on the subset needed for practical headless highlighting/folding.- Use
SublimeScopeMapperto mapStyleIdvalues back to scopes for theming.