JS tagged template SQL highlighting

I was delighted to see that any js tagged template literal tagged with html or css enabled proper html or css highlighting on the contents of the template string the other day.

I was wondering if sub-syntax highlighting could also be enabled for SQL tagged template literals.

Ideally this could work with any sub-syntax based on the name of the template tag function, but I understand it’s probably difficult to generalize the concept outside of a few common language embeds. Sublime Text has a plugin that allows for customization of sub-syntax highlighters in case prior art is helpful: GitHub - Thom1729/Sublime-JS-Custom: Customizable JavaScript syntax highlighting for Sublime Text.

Support for doing what you are proposing (generalized template includes) is already present in Nova. However, the SQL syntax in Nova is not a tree-sitter grammar, and the two types of grammars in Nova cannot be intermixed. If and when that grammar is migrated to tree-sitter, template tags for SQL should just start working immediately.

1 Like