]> git.eshelyaron.com Git - emacs.git/commitdiff
Add expression handling to heex-ts-mode
authorWilhelm Kirschbaum <wkirschbaum@gmail.com>
Mon, 30 Dec 2024 10:45:08 +0000 (12:45 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 4 Jan 2025 20:56:20 +0000 (21:56 +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.

(cherry picked from commit ae2589ea7a59ac3bde19b025ba4a7968c77208d7)

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

index fbef233a2aa2b89aa1e80d3f2a9e7555cd3203ea..2d41cdf4221bda4fb77817ad7feca2ba16d355b9 100644 (file)
@@ -59,7 +59,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,
@@ -86,6 +86,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>
+=-=-=