nvim-treesitter/runtime/queries/ecma
Benny Powers 605ba7428f fix(injections): use string_fragment for template literal injections
Template literal injection queries previously captured the entire
`template_string` node with `injection.include-children`, which caused
template substitutions (e.g. `${expr}`) to be included in the injected
language's parse input. This broke highlighting in cases like:

    html`<p class="static ${classMap({ dynamic })} after"></p>`

where the HTML parser's attribute_value node would span across the
template substitution gap, and the lit-html `${` injection query
(in html_tags) would match the buffer text at that range, injecting
JS at the wrong offset.

Two fixes:

1. ecma/injections.scm: capture `string_fragment` nodes instead of
   `template_string`, and use `injection.combined` to merge them. This
   aligns with upstream tree-sitter-javascript's approach. The `#offset!`
   directives are removed since `string_fragment` already excludes the
   backticks.

2. html_tags/injections.scm: anchor the lit-html `${` pattern with `^`
   so it only matches attribute values that *start* with `${`, not
   attribute values whose buffer text happens to contain `${` in the
   middle (which occurs when the attribute_value node spans a template
   substitution gap).

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 22:04:12 +03:00
..
folds.scm feat!: drop modules, general refactor and cleanup 2025-05-12 18:43:40 +02:00
highlights.scm feat!: drop modules, general refactor and cleanup 2025-05-12 18:43:40 +02:00
indents.scm fix(c, ecma): remove invalid predicate parameters 2025-07-22 09:52:32 +02:00
injections.scm fix(injections): use string_fragment for template literal injections 2026-03-28 22:04:12 +03:00
locals.scm feat(ecma): variable definition from object destructure with alias 2026-02-27 09:00:07 +01:00