unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: "Theodor Thornhill" <theo@thornhill.no>,
	66988@debbugs.gnu.org, "Loïc Lemaître" <loic.lemaitre@gmail.com>,
	"Yuan Fu" <casouri@gmail.com>
Subject: bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode
Date: Fri, 10 Nov 2023 09:37:38 +0200	[thread overview]
Message-ID: <86sf5enlyt.fsf@mail.linkov.net> (raw)
In-Reply-To: <39b0057b-ac0c-8271-0fe2-f4deef7ae8d3@gutov.dev> (Dmitry Gutov's message of "Fri, 10 Nov 2023 03:41:00 +0200")

> @@ -3843,6 +3843,7 @@ js--treesit-sexp-nodes
>      "undefined"
>      "arguments"
>      "pair"
> +    "parenthesized_expression"
>      "jsx")
>    "Nodes that designate sexps in JavaScript.
>  See `treesit-thing-settings' for more information.")

I had the same problem and to make this mode more usable had to use such patch:

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 5a669fdbd42..4c07fbd94b7 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3825,7 +3825,9 @@ js--treesit-sentence-nodes
 See `treesit-thing-settings' for more information.")
 
 (defvar js--treesit-sexp-nodes
-  '("expression"
+  '("expression" ;; SHOULD NOT MATCH "expression_statement", BUT SHOULD MATCH "parenthesized_expression"
+    "parenthesized_expression"
+    "formal_parameters"
     "pattern"
     "array"
     "function"
@@ -3843,7 +3845,13 @@ js--treesit-sexp-nodes
     "undefined"
     "arguments"
     "pair"
-    "jsx")
+    "jsx"
+    "statement_block"
+    "object"
+    "object_pattern"
+    "named_imports"
+    "class_body"
+    )
   "Nodes that designate sexps in JavaScript.
 See `treesit-thing-settings' for more information.")
 
PS:
Also tried to replace
  (setq-local treesit-sexp-type-regexp (regexp-opt js--treesit-sexp-nodes))
with
  (setq-local treesit-sexp-type-regexp (rx-to-string `(seq bol (or ,@js--treesit-sexp-nodes) eol)))





  reply	other threads:[~2023-11-10  7:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07 14:56 bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode Loïc Lemaître
2023-11-10  1:41 ` Dmitry Gutov
2023-11-10  7:37   ` Juri Linkov [this message]
2023-11-11  2:41   ` Yuan Fu
2023-11-11  7:35     ` Eli Zaretskii
2023-11-15  6:28       ` Yuan Fu
2023-11-15 12:19         ` Eli Zaretskii
2023-11-18 18:57           ` Yuan Fu
2023-11-19  5:48             ` Eli Zaretskii
2023-11-19  6:19               ` Yuan Fu
2023-11-11 10:49     ` Dmitry Gutov
2023-11-15  6:32       ` Yuan Fu
2023-11-11 15:43   ` Loïc Lemaître
2023-11-11 23:40     ` Dmitry Gutov
2023-11-12 12:10       ` Loïc Lemaître

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=86sf5enlyt.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=66988@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=dmitry@gutov.dev \
    --cc=loic.lemaitre@gmail.com \
    --cc=theo@thornhill.no \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).