Generate queries a little better
This commit is contained in:
parent
51c4f14c26
commit
dbf893e48b
1 changed files with 6 additions and 2 deletions
|
|
@ -319,8 +319,12 @@ def emit_tree_sitter_queries(grammar: parser.Grammar, path: pathlib.Path | str):
|
|||
for rule in grammar.terminals():
|
||||
highlight = rule.meta.get("highlight")
|
||||
if isinstance(highlight, parser.HighlightMeta):
|
||||
queries.append(f"({terminal_name(rule)} @{highlight.scope})")
|
||||
queries.append(f"({terminal_name(rule)}) @{highlight.scope}")
|
||||
|
||||
path = pathlib.Path(path) / "highlight.scm"
|
||||
path = pathlib.Path(path) / "queries"
|
||||
if not path.exists():
|
||||
path.mkdir(parents=True)
|
||||
|
||||
path = path / "highlights.scm"
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write("\n\n".join(queries))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue