Skip to content

Commit

Permalink
fixup! lazy-load queries
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed May 9, 2024
1 parent 8a6147f commit 847e08f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions cli/src/generate/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@

from ._binding import language

# NOTE: uncomment these to include any queries that this grammar contains:

# HIGHLIGHTS_QUERY = _files(f"{__package__}.queries").joinpath("highlights.scm").read_text()
# INJECTIONS_QUERY = _files(f"{__package__}.queries").joinpath("injections.scm").read_text()
# LOCALS_QUERY = _files(f"{__package__}.queries").joinpath("locals.scm").read_text()
# TAGS_QUERY = _files(f"{__package__}.queries").joinpath("tags.scm").read_text()
def _get_query(name, file):
globals()[name] = _files(f"{__package__}.queries").joinpath(file).read_text()
return globals()[name]


def __getattr__(name):
# NOTE: uncomment these to include any queries that this grammar contains:

# if name == "HIGHLIGHTS_QUERY":
# return _get_query("HIGHLIGHTS_QUERY", "highlights.scm")
# if name == "INJECTIONS_QUERY":
# return _get_query("INJECTIONS_QUERY", "injections.scm")
# if name == "LOCALS_QUERY":
# return _get_query("LOCALS_QUERY", "locals.scm")
# if name == "TAGS_QUERY":
# return _get_query("TAGS_QUERY", "tags.scm")

raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


__all__ = [
"language",
Expand Down

0 comments on commit 847e08f

Please sign in to comment.