From 7e1fd814d19e820a6b17d62ce4229ae1daaef5cf 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. * test/lisp/progmodes/heex-ts-mode-resources/indent.erts: Add expression indent test. --- 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 b527d96b579..797bfd6c8ff 100644 --- a/lisp/progmodes/heex-ts-mode.el +++ b/lisp/progmodes/heex-ts-mode.el @@ -54,7 +54,7 @@ heex-ts-indent-offset (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 @@ heex-ts--indent-rules ((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.45.2