all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Wilhelm Kirschbaum <wkirschbaum@gmail.com>
To: 75191@debbugs.gnu.org
Subject: bug#75191: [PATCH] Add expression handling to heex-ts-mode
Date: Mon, 30 Dec 2024 12:53:48 +0200	[thread overview]
Message-ID: <CAOS0-37Fu+=OENasjwsNYL2bPBJ+LNO_rJ52Wj9PLPt2cU-XVA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 208 bytes --]

This patch is to handle the recent update to the heex grammar:
https://github.com/phoenixframework/tree-sitter-heex/releases/tag/v0.7.0

This change appears to be backwards compatible.

Kind regards,
Wilhelm

[-- Attachment #1.2: Type: text/html, Size: 400 bytes --]

[-- Attachment #2: 0001-Add-expression-handling-to-heex-ts-mode.patch --]
[-- Type: text/x-patch, Size: 2084 bytes --]

From 7e1fd814d19e820a6b17d62ce4229ae1daaef5cf Mon Sep 17 00:00:00 2001
From: Wilhelm Kirschbaum <wkirschbaum@gmail.com>
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
   </:bar>
 </Foo>
 =-=-=
+
+Name: Expression
+
+=-=
+<div>
+{
+@bar
+}
+</div>
+=-=
+<div>
+  {
+    @bar
+  }
+</div>
+=-=-=
-- 
2.45.2


             reply	other threads:[~2024-12-30 10:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-30 10:53 Wilhelm Kirschbaum [this message]
2025-01-02  7:44 ` bug#75191: [PATCH] Add expression handling to heex-ts-mode Stefan Kangas
2025-01-02  8:35   ` Eli Zaretskii
2025-01-03  5:53     ` Yuan Fu
2025-01-03  8:41       ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOS0-37Fu+=OENasjwsNYL2bPBJ+LNO_rJ52Wj9PLPt2cU-XVA@mail.gmail.com' \
    --to=wkirschbaum@gmail.com \
    --cc=75191@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.