From aff96de4ac4088e1e2ae7489dc207b918d676a45 Mon Sep 17 00:00:00 2001 From: Wilhelm Kirschbaum Date: Mon, 30 Dec 2024 12:45:08 +0200 Subject: [PATCH] Add expression handling to heex-ts-mode 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 | 3 ++- .../progmodes/heex-ts-mode-resources/indent.erts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/heex-ts-mode.el b/lisp/progmodes/heex-ts-mode.el index fbef233a2aa..2d41cdf4221 100644 --- a/lisp/progmodes/heex-ts-mode.el +++ b/lisp/progmodes/heex-ts-mode.el @@ -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) diff --git a/test/lisp/progmodes/heex-ts-mode-resources/indent.erts b/test/lisp/progmodes/heex-ts-mode-resources/indent.erts index 500ddb2b536..7fef6571933 100644 --- a/test/lisp/progmodes/heex-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/heex-ts-mode-resources/indent.erts @@ -45,3 +45,19 @@ Name: Slots =-=-= + +Name: Expression + +=-= +
+{ +@bar +} +
+=-= +
+ { + @bar + } +
+=-=-= -- 2.39.5