From 11d79aa0f731439f2cd05579a64ac13857002f16 Mon Sep 17 00:00:00 2001 From: dvic Date: Mon, 14 Aug 2023 20:59:27 +0200 Subject: Fix HEEx directive injections --- queries/heex/injections.scm | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/queries/heex/injections.scm b/queries/heex/injections.scm index 1aa822197..403697acb 100644 --- a/queries/heex/injections.scm +++ b/queries/heex/injections.scm @@ -1,14 +1,25 @@ -; HEEx directives can span multiple interpolated lines of Elixir -(directive [ - (expression_value) - (partial_expression_value) -] @injection.content +; directives are standalone tags like '<%= @x %>' +; +; partial_expression_values are elixir code that is part of an expression that +; spans multiple directive nodes, so they must be combined. For example: +; <%= if true do %> +;

hello, tree-sitter!

+; <% end %> +(directive + (partial_expression_value) @injection.content (#set! injection.language "elixir") - (#set! injection.combined)) + (#set! injection.include-children) + (#set! injection.combined)) -; HEEx Elixir expressions are always within a tag or component -(expression - (expression_value) @injection.content +; Regular expression_values do not need to be combined +((directive + (expression_value) @injection.content) + (#set! injection.language "elixir")) + +; expressions live within HTML tags, and do not need to be combined +; +(expression + (expression_value) @injection.content (#set! injection.language "elixir")) ; HEEx comments -- cgit v1.2.3-70-g09d2