forked from helix-editor/helix
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HEEx is a templating engine on top of Elixir's EEx templating language specific to HTML that is included in Phoenix.LiveView (though I think the plan is to eventually include it in base Phoenix). It's a superset of EEx with some additional features like components and slots. The injections don't work perfectly because the Elixir grammar is newline sensitive (the _terminator rule). See elixir-lang/tree-sitter-elixir#24 for more information.
- Loading branch information
1 parent
1aa51d2
commit e446391
Showing
5 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
; https://github.com/connorlay/tree-sitter-heex/blob/592e22292a367312c35e13de7fdb888f029981d6/queries/highlights.scm | ||
; HEEx delimiters | ||
[ | ||
"<!" | ||
"<!--" | ||
"<" | ||
"<%!--" | ||
"<%#" | ||
">" | ||
"</" | ||
"--%>" | ||
"-->" | ||
"/>" | ||
"{" | ||
"}" | ||
; These could be `@keyword`s but the closing `>` wouldn't be highlighted | ||
; as `@keyword` | ||
"<:" | ||
"</:" | ||
] @punctuation.bracket | ||
|
||
; Non-comment or tag delimiters | ||
[ | ||
"<%" | ||
"<%=" | ||
"<%%=" | ||
"%>" | ||
] @keyword | ||
|
||
; HEEx operators are highlighted as such | ||
"=" @operator | ||
|
||
; HEEx inherits the DOCTYPE tag from HTML | ||
(doctype) @constant | ||
|
||
; HEEx comments are highlighted as such | ||
(comment) @comment | ||
|
||
; HEEx tags are highlighted as HTML | ||
(tag_name) @tag | ||
|
||
; HEEx slots are highlighted as atoms (symbols) | ||
(slot_name) @string.special.symbol | ||
|
||
; HEEx attributes are highlighted as HTML attributes | ||
(attribute_name) @attribute | ||
[ | ||
(attribute_value) | ||
(quoted_attribute_value) | ||
] @string | ||
|
||
; HEEx components are highlighted as Elixir modules and functions | ||
(component_name | ||
[ | ||
(module) @module | ||
(function) @function | ||
"." @punctuation.delimiter | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
; https://github.com/connorlay/tree-sitter-heex/blob/592e22292a367312c35e13de7fdb888f029981d6/queries/injections.scm | ||
; 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 %> | ||
; <p>hello, tree-sitter!</p> | ||
; <% end %> | ||
((directive (partial_expression_value) @injection.content) | ||
(#set! injection.language "elixir") | ||
(#set! injection.include-children) | ||
(#set! injection.combined)) | ||
|
||
; 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 | ||
; <link href={ Routes.static_path(..) } /> | ||
((expression (expression_value) @injection.content) | ||
(#set! injection.language "elixir")) |