summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClay <connorlay@pm.me>2022-01-23 18:09:29 -0800
committerChristian Clason <christian.clason@uni-due.de>2022-01-24 08:29:42 +0100
commit9e90866bcea3e392126c4eb90fde56b1c0b56b69 (patch)
tree1b8c9cd0c572a51316be366536dca06f021fe2ce
parentc7d5ba7212d0e1d38e2b714eabe4452a80dfe945 (diff)
Upgrade to HEEx parser 0.3.0
-rw-r--r--queries/heex/highlights.scm46
-rw-r--r--queries/heex/indents.scm2
-rw-r--r--queries/heex/injections.scm14
-rw-r--r--queries/heex/locals.scm11
4 files changed, 51 insertions, 22 deletions
diff --git a/queries/heex/highlights.scm b/queries/heex/highlights.scm
index c69e3d53..611e637f 100644
--- a/queries/heex/highlights.scm
+++ b/queries/heex/highlights.scm
@@ -1,16 +1,13 @@
-(text) @text
-(comment) @comment
-(doctype) @constant
-
-; HEEx attributes are highlighted as HTML attributes
-(attribute_name) @tag.attribute
-(quoted_attribute_value) @string
-
+; HEEx tag and component delimiters
[
"%>"
+ "--%>"
+ "-->"
"/>"
"<!"
+ "<!--"
"<"
+ "<%!--"
"<%"
"<%#"
"<%%="
@@ -21,13 +18,34 @@
"}"
] @tag.delimiter
-[
- "="
-] @operator
+; HEEx operators
+"=" @operator
+
+; HEEx inherits the DOCTYPE tag from HTML
+(doctype) @constant
-; HEEx tags are highlighted as HTML
+; HEEx tags are highlighted as HTML tags
(tag_name) @tag
-; HEEx components are highlighted as types (Elixir modules)
-(component_name) @type
+; HEEx comments are highlighted as such
+(comment) @comment
+
+; HEEx text content is treated as markup
+(text) @text
+
+; Tree-sitter parser errors
+(ERROR) @error
+
+; HEEx attributes are highlighted as HTML attributes
+(attribute_name) @tag.attribute
+[
+ (attribute_value)
+ (quoted_attribute_value)
+] @string
+; HEEx components are highlighted as modules and function calls
+(component_name [
+ (module) @type
+ (function) @function
+ "." @punctuation.delimiter
+])
diff --git a/queries/heex/indents.scm b/queries/heex/indents.scm
index 02771b01..e2a08713 100644
--- a/queries/heex/indents.scm
+++ b/queries/heex/indents.scm
@@ -1,4 +1,4 @@
-; HEEx indents like HTML
+; HEEx indents like HTML
[
(component)
(tag)
diff --git a/queries/heex/injections.scm b/queries/heex/injections.scm
index ab7a3c87..af99e688 100644
--- a/queries/heex/injections.scm
+++ b/queries/heex/injections.scm
@@ -1,10 +1,10 @@
-; TODO: once @combined is fixed for all modules, replace this with the two queries below
-(expression_value) @elixir
+; HEEx directives can span multiple interpolated lines of Elixir
+(directive [
+ (expression_value)
+ (partial_expression_value)
+] @elixir @combined)
-; Directives are combined to support do blocks
-; (directive (expression_value) @elixir @combined)
-
-; Expressions are not combined, as they exist separately from do blocks
-; (expression (expression_value) @elixir)
+; HEEx Elixir expressions are always within a tag or component
+(expression (expression_value) @elixir)
(comment) @comment
diff --git a/queries/heex/locals.scm b/queries/heex/locals.scm
new file mode 100644
index 00000000..3f99132e
--- /dev/null
+++ b/queries/heex/locals.scm
@@ -0,0 +1,11 @@
+; HEEx tags and components are references
+[
+ (tag_name)
+ (component_name)
+] @reference
+
+; Create a new scope within each HEEx tag or component
+[
+ (tag)
+ (component)
+] @scope