Support HEEx slots

This commit is contained in:
Clay 2022-01-30 16:15:24 -08:00 committed by Stephan Seitz
parent efedf3510a
commit 083aee0873
6 changed files with 34 additions and 16 deletions

View file

@ -111,7 +111,7 @@
"revision": "3cb7fc28247efbcb2973b97e71c78838ad98a583" "revision": "3cb7fc28247efbcb2973b97e71c78838ad98a583"
}, },
"heex": { "heex": {
"revision": "d8b5b9f016cd3c7b0ee916cf031d9a2188c0fc44" "revision": "592e22292a367312c35e13de7fdb888f029981d6"
}, },
"hjson": { "hjson": {
"revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0"

View file

@ -1,5 +1,6 @@
; HEEx folds similar to HTML ; HEEx tags, components, and slots fold similar to HTML
[ [
(tag)
(component) (component)
(tag)
(slot)
] @fold ] @fold

View file

@ -1,4 +1,4 @@
; HEEx tag and component delimiters ; HEEx delimiters
[ [
"%>" "%>"
"--%>" "--%>"
@ -13,20 +13,19 @@
"<%%=" "<%%="
"<%=" "<%="
"</" "</"
"</:"
"<:"
">" ">"
"{" "{"
"}" "}"
] @tag.delimiter ] @tag.delimiter
; HEEx operators ; HEEx operators are highlighted as such
"=" @operator "=" @operator
; HEEx inherits the DOCTYPE tag from HTML ; HEEx inherits the DOCTYPE tag from HTML
(doctype) @constant (doctype) @constant
; HEEx tags are highlighted as HTML tags
(tag_name) @tag
; HEEx comments are highlighted as such ; HEEx comments are highlighted as such
(comment) @comment (comment) @comment
@ -36,6 +35,12 @@
; Tree-sitter parser errors ; Tree-sitter parser errors
(ERROR) @error (ERROR) @error
; HEEx tags and slots are highlighted as HTML
[
(tag_name)
(slot_name)
] @tag
; HEEx attributes are highlighted as HTML attributes ; HEEx attributes are highlighted as HTML attributes
(attribute_name) @tag.attribute (attribute_name) @tag.attribute
[ [

View file

@ -1,11 +1,20 @@
; HEEx indents like HTML ; HEEx tags, components, and slots indent like HTML
[ [
(component) (component)
(slot)
(tag) (tag)
] @indent ] @indent
; Dedent at the end of each tag ; Dedent at the end of each tag, component, and slot
[ [
(end_tag)
(end_component) (end_component)
] @branch (end_slot)
(end_tag)
] @branch @dedent
; Self-closing tags and components should not change
; indentation level of sibling nodes
[
(self_closing_component)
(self_closing_tag)
] @auto

View file

@ -7,4 +7,5 @@
; HEEx Elixir expressions are always within a tag or component ; HEEx Elixir expressions are always within a tag or component
(expression (expression_value) @elixir) (expression (expression_value) @elixir)
; HEEx comments
(comment) @comment (comment) @comment

View file

@ -1,11 +1,13 @@
; HEEx tags and components are references ; HEEx tags, components, and slots are references
[ [
(tag_name)
(component_name) (component_name)
(slot_name)
(tag_name)
] @reference ] @reference
; Create a new scope within each HEEx tag or component ; Create a new scope within each HEEx tag, component, and slot
[ [
(tag)
(component) (component)
(slot)
(tag)
] @scope ] @scope