diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/grammar_manifest.zig | 8 | ||||
| -rw-r--r-- | core/syntax.zig | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/core/grammar_manifest.zig b/core/grammar_manifest.zig index b4ff30b9..b0ce146c 100644 --- a/core/grammar_manifest.zig +++ b/core/grammar_manifest.zig @@ -17,6 +17,12 @@ pub const Grammar = struct { query: []const u8 = "queries/highlights.scm", /// Patterns appended to the highlights query before it is filtered. highlights_extra: []const u8 = "", + /// The grammars it cannot work without, compiled in with it when a + /// package names it alone (build.zig's `languages`). Only markdown has + /// one: its inline grammar. A fence's or a raw block's language + /// (markdown's, typst's) is coloured when it is in the build and left + /// plain when it is not. + needs: []const []const u8 = &.{}, }; pub const all = [_]Grammar{ @@ -38,7 +44,7 @@ pub const all = [_]Grammar{ .{ .name = "json", .dep = "ts_json", .exts = &.{".json"}, .tier = .full }, .{ .name = "kotlin", .dep = "ts_kotlin", .exts = &.{ ".kt", ".kts" }, .tier = .full, .scanner = true }, .{ .name = "ocaml", .dep = "ts_ocaml", .exts = &.{ ".ml", ".mli" }, .tier = .full, .src = "grammars/ocaml/src", .scanner = true }, - .{ .name = "markdown", .dep = "ts_markdown", .exts = &.{ ".md", ".markdown" }, .tier = .full, .src = "tree-sitter-markdown/src", .scanner = true, .query = "tree-sitter-markdown/queries/highlights.scm" }, + .{ .name = "markdown", .dep = "ts_markdown", .exts = &.{ ".md", ".markdown" }, .tier = .full, .src = "tree-sitter-markdown/src", .scanner = true, .query = "tree-sitter-markdown/queries/highlights.scm", .needs = &.{"markdown_inline"} }, // Second grammar off the SAME dep: the split_parser markdown repo ships a // block parser and an inline parser, and bold/italic/code-span live only in // the inline one. `.exts` is empty because no filename ever selects it — the diff --git a/core/syntax.zig b/core/syntax.zig index 00ee497f..1bb8fb52 100644 --- a/core/syntax.zig +++ b/core/syntax.zig @@ -37,11 +37,10 @@ const Spec = struct { capture_styles: [256]u8 = undefined, }; +/// A grammar is in the build when the build gave its queries (build/core.zig +/// `treeSitter`): a tier's set, or the languages a package named. fn grammarSelected(comptime g: grammar_manifest.Grammar) bool { - return switch (g.tier) { - .minimal => minimal_grammars, - .full => full_grammars, - }; + return @hasDecl(ts_queries, g.name ++ "_highlights"); } fn specCount() comptime_int { |
