From 083aee08735fd5dcd02ef72d831b054244db73a4 Mon Sep 17 00:00:00 2001 From: Clay Date: Sun, 30 Jan 2022 16:15:24 -0800 Subject: Support HEEx slots --- lockfile.json | 2 +- queries/heex/folds.scm | 5 +++-- queries/heex/highlights.scm | 15 ++++++++++----- queries/heex/indents.scm | 17 +++++++++++++---- queries/heex/injections.scm | 1 + queries/heex/locals.scm | 10 ++++++---- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/lockfile.json b/lockfile.json index b6c8044a7..5cee2cd44 100644 --- a/lockfile.json +++ b/lockfile.json @@ -111,7 +111,7 @@ "revision": "3cb7fc28247efbcb2973b97e71c78838ad98a583" }, "heex": { - "revision": "d8b5b9f016cd3c7b0ee916cf031d9a2188c0fc44" + "revision": "592e22292a367312c35e13de7fdb888f029981d6" }, "hjson": { "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" diff --git a/queries/heex/folds.scm b/queries/heex/folds.scm index 414890e91..88d4f17ff 100644 --- a/queries/heex/folds.scm +++ b/queries/heex/folds.scm @@ -1,5 +1,6 @@ -; HEEx folds similar to HTML +; HEEx tags, components, and slots fold similar to HTML [ - (tag) (component) + (tag) + (slot) ] @fold diff --git a/queries/heex/highlights.scm b/queries/heex/highlights.scm index 611e637fb..7dd4dd6fd 100644 --- a/queries/heex/highlights.scm +++ b/queries/heex/highlights.scm @@ -1,4 +1,4 @@ -; HEEx tag and component delimiters +; HEEx delimiters [ "%>" "--%>" @@ -13,20 +13,19 @@ "<%%=" "<%=" "" "{" "}" ] @tag.delimiter -; HEEx operators +; HEEx operators are highlighted as such "=" @operator ; HEEx inherits the DOCTYPE tag from HTML (doctype) @constant -; HEEx tags are highlighted as HTML tags -(tag_name) @tag - ; HEEx comments are highlighted as such (comment) @comment @@ -36,6 +35,12 @@ ; Tree-sitter parser errors (ERROR) @error +; HEEx tags and slots are highlighted as HTML +[ + (tag_name) + (slot_name) +] @tag + ; HEEx attributes are highlighted as HTML attributes (attribute_name) @tag.attribute [ diff --git a/queries/heex/indents.scm b/queries/heex/indents.scm index e2a08713b..99fc693dc 100644 --- a/queries/heex/indents.scm +++ b/queries/heex/indents.scm @@ -1,11 +1,20 @@ -; HEEx indents like HTML +; HEEx tags, components, and slots indent like HTML [ (component) + (slot) (tag) ] @indent -; Dedent at the end of each tag +; Dedent at the end of each tag, component, and slot [ - (end_tag) (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 diff --git a/queries/heex/injections.scm b/queries/heex/injections.scm index af99e688e..fffd1dc53 100644 --- a/queries/heex/injections.scm +++ b/queries/heex/injections.scm @@ -7,4 +7,5 @@ ; HEEx Elixir expressions are always within a tag or component (expression (expression_value) @elixir) +; HEEx comments (comment) @comment diff --git a/queries/heex/locals.scm b/queries/heex/locals.scm index 3f99132e1..4371bc979 100644 --- a/queries/heex/locals.scm +++ b/queries/heex/locals.scm @@ -1,11 +1,13 @@ -; HEEx tags and components are references +; HEEx tags, components, and slots are references [ - (tag_name) (component_name) + (slot_name) + (tag_name) ] @reference -; Create a new scope within each HEEx tag or component +; Create a new scope within each HEEx tag, component, and slot [ - (tag) (component) + (slot) + (tag) ] @scope -- cgit v1.2.3-70-g09d2