Expand description
Battery registry: optional, feature-gated editor batteries (see it for the contract and checklist for adding new batteries). Battery registry: optional, feature-gated editor batteries.
Each battery is a self-contained language or behavior pack built only on
the public core API (SyntaxHighlighter, EditorHook, HighlightTag,
ConcealedLine, …) — the same surface external users get. Batteries emit
only existing HighlightTag variants (never add new ones per battery) and
never require twrite-gpui-side code; they wire up via set_highlighter /
add_hook, as demonstrated by examples/vim.rs.
§Adding a battery <name>
- Create
batteries/<name>.rs(promote tobatteries/<name>/mod.rswhen it outgrows one file) with a fixed template:Config(plainClonedata +Default),Highlighter(new+with_config),Hook(new+with_config). Hook-only batteries omit the highlighter. - Declare the feature in
twrite-core/Cargo.toml(<name> = [...], withdep:<parser-crate>only if the battery needs a parser dependency). - Register the one-line path shim in
super::lib(seemarkdownthere): the public path staystwrite_core::<name>regardless of file layout. - Re-export from the
twritefacade astwrite::<name>behind the same feature name, so users writetwrite = { features = ["<name>"] }. - Add colocated unit tests in the battery module and an
examples/<name>.rsdemo (withrequired-featuresonly if the demo needs the battery).