pub fn load_file(path: impl AsRef<Path>) -> Result<SyntaxDefinition, Error>Expand description
Reads and translates a .tmLanguage.json grammar from an arbitrary
local file at runtime — the “load a custom grammar the user dropped in,
no bundling required” case from the project’s Goal.
The result is a plain SyntaxDefinition; add it to a
syntect::parsing::SyntaxSetBuilder (alongside any other syntaxes)
and call .build() the same way you would for a hand-written
.sublime-syntax file — this crate doesn’t wrap that step, since
syntect’s own builder already does it well.
For the build-time-bundling case (Goal item 3’s “convert once, ship a
generated .sublime-syntax”), either save to_sublime_syntax_yaml’s
output as a .sublime-syntax file directly, or build a syntect::parsing::SyntaxSet
once from this function’s output and cache it with
syntect::dumps::dump_to_file/syntect::dumps::from_dump_file — both
already handle any Serialize/DeserializeOwned type, SyntaxSet
included, so no wrapper is needed here either.