Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 51 additions & 11 deletions languages/heex/injections.scm
Original file line number Diff line number Diff line change
@@ -1,13 +1,53 @@
(
(directive
[
(partial_expression_value)
(expression_value)
(ending_expression_value)
] @injection.content)
; Expressions are HTML-aware interpolations of Elixir code like
; `<link href={ Routes.static_path(..) } />`
;
; Note that we include children because `expression_value` nodes may consist
; of multiple nodes when the value contains `{` and `}`
(expression
(expression_value) @injection.content
(#set! injection.language "elixir")
(#set! injection.combined)
)
(#set! injection.include-children))

((expression (expression_value) @injection.content)
(#set! injection.language "elixir"))
; Directives are standalone tags like '<%= @x %>'
;
; Directives with `partial_expression_value` and `ending_expression_value`
; nodes are Elixir code that is part of an expression that spans multiple
; `directive` nodes, so they must be combined. For example:
; <%= if true do %>
; <p>hello, tree-sitter!</p>
; <% end %>
(directive
[
(partial_expression_value)
(ending_expression_value)
] @injection.content
(#set! injection.language "elixir")
(#set! injection.include-children)
(#set! injection.combined))

; Directives with `expression_value` nodes do not need to be combined.
; For example:
; <body>
; <%= @inner_content %>
; </body>
(directive
(expression_value) @injection.content
(#set! injection.language "elixir"))

; Syntax highlight for `style="..."` attributes
(attribute
(attribute_name) @_attribute_name
(quoted_attribute_value (attribute_value) @injection.content)
(#eq? @_attribute_name "style")
(#set! injection.language "css"))

; Syntax highlight for `onEVENT="..."` attributes
(attribute
(attribute_name) @_attribute_name
(quoted_attribute_value (attribute_value) @injection.content)
(#match? @_attribute_name "^on[a-z]+$")
(#set! injection.language "javascript"))

; Comment parsing languages support
((comment) @injection.content
(#set! injection.language "comment"))