Add Basic Recognition for Jinja Blocks to Enable Injections
I'd like to request adding minimal support for Jinja templating syntax to the tree-sitter-sql grammar. A similar request was opened 3 years ago (#28), however, the suggestion to use injection queries does not work because the jinja blocks break the parser making it impossible for the injection queries to hook into, much less any highlighting or indentation of the actual sql.
I have already prepared changes to address this. They introduce 3 jinja blocks, 2 of which are just treated as extras. The goal is NOT to fully parse Jinja, but to prevent the SQL parser from breaking when encountering the jinja structures and add hook points for injection queries in templated SQL files (e.g., for dbt, airflow).
Jinja structures:
-
Jinja Comments:
{# ... #} -
Jinja Statements:
{% ... %} -
Jinja Expressions:
{{ ... }}
I will post a PR from my branch to this repo. I'm happy to discuss the implementation details, make any requested adjustments, and ensure this change aligns with the project's standards.