Add expression handling to heex-ts-mode
authorWilhelm Kirschbaum <wkirschbaum@gmail.com>
Mon, 30 Dec 2024 10:45:08 +0000 (12:45 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Fri, 3 Jan 2025 08:41:15 +0000 (09:41 +0100)
On the latest update of the grammar expressions were added and won't be
seen as directives anymore.

* lisp/progmodes/heex-ts-mode.el
(heex-ts--sexp-regexp): Match on expression as well.
(heex-ts--indent-rules): Indent on expression end.  (Bug#75191)
* test/lisp/progmodes/heex-ts-mode-resources/indent.erts: Add expression
indent test.

lisp/progmodes/heex-ts-mode.el
test/lisp/progmodes/heex-ts-mode-resources/indent.erts

index c8905afda5c91ca99aad8ad173d264883f337c04..e19349b3a0f350880a0c420b172316e06ab47d03 100644 (file)
@@ -54,7 +54,7 @@
 (defconst heex-ts--sexp-regexp
   (rx bol
       (or "directive" "tag" "component" "slot"
-          "attribute" "attribute_value" "quoted_attribute_value")
+          "attribute" "attribute_value" "quoted_attribute_value" "expression")
       eol))
 
 ;; There seems to be no parent directive block for tree-sitter-heex,
@@ -81,6 +81,7 @@
        ((node-is "end_slot") parent-bol 0)
        ((node-is "/>") parent-bol 0)
        ((node-is ">") parent-bol 0)
+       ((node-is "}") parent-bol 0)
        ((parent-is "comment") prev-adaptive-prefix 0)
        ((parent-is "component") parent-bol ,offset)
        ((parent-is "tag") parent-bol ,offset)
index 500ddb2b536f4ffdb2bcf703ac302511abca1f5f..7fef6571933d077c10447f3057487b06733d89a9 100644 (file)
@@ -45,3 +45,19 @@ Name: Slots
   </:bar>
 </Foo>
 =-=-=
+
+Name: Expression
+
+=-=
+<div>
+{
+@bar
+}
+</div>
+=-=
+<div>
+  {
+    @bar
+  }
+</div>
+=-=-=