From: Eli Zaretskii <eliz@gnu.org>
To: "Divvy Cr." <divvycr@gmail.com>
Cc: 69589@debbugs.gnu.org
Subject: bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting
Date: Wed, 06 Mar 2024 19:48:05 +0200 [thread overview]
Message-ID: <86wmqfjlpm.fsf@gnu.org> (raw)
In-Reply-To: <CADmOxiLW3NCEGWotDWDPUCNf_BfR+m7DQYQ46fr0VtGirdqCeQ@mail.gmail.com> (divvycr@gmail.com)
> From: "Divvy Cr." <divvycr@gmail.com>
> Date: Wed, 6 Mar 2024 17:25:40 +0000
>
> Open a JavaScript file containing 'const x = 10;' for instance. Then,
> enable js-ts-mode (M-x js-ts-mode). Expected the literal '10' to be
> highlighted with font-lock-number-face, but it is not.
>
> The apparent reason is that the 'function' node name used in
> treesit-font-lock-rules to define js--treesit-font-lock-settings (in the
> file js.el) is a valid elisp function (C-h f function). This invalidates
> the query, as verified by running the following:
>
> (treesit-query-validate 'javascript ((function
> name: (identifier) @font-lock-function-name-face)
>
> (class_declaration
> name: (identifier) @font-lock-type-face)
>
> (function_declaration
> name: (identifier) @font-lock-function-name-face)
>
> (method_definition
> name: (property_identifier) @font-lock-function-name-face)
>
> (formal_parameters
> [(identifier) @font-lock-variable-name-face
> (array_pattern (identifier) @font-lock-variable-name-face)
> (object_pattern (shorthand_property_identifier_pattern) @font-lock-variable-name-face)])
>
> (variable_declarator
> name: (identifier) @font-lock-variable-name-face)
>
> (variable_declarator
> name: (identifier) @font-lock-function-name-face
> value: [(function) (arrow_function)])
>
> (variable_declarator
> name: [(array_pattern (identifier) @font-lock-variable-name-face)
> (object_pattern
> (shorthand_property_identifier_pattern) @font-lock-variable-name-face)])
>
> ;; full module imports
> (import_clause (identifier) @font-lock-variable-name-face)
> ;; named imports with aliasing
> (import_clause (named_imports (import_specifier
> alias: (identifier) @font-lock-variable-name-face)))
> ;; named imports without aliasing
> (import_clause (named_imports (import_specifier
> !alias
> name: (identifier) @font-lock-variable-name-face)))
>
> ;; full namespace import (* as alias)
> (import_clause (namespace_import (identifier)
> @font-lock-variable-name-face))))
>
> Note that this query is taken directly from the definition of
> js--tresit-font-lock-settings.
>
> Removing the invalid snippet above from the definition of
> js--treesit-font-lock-settings fixes this bug.
Thanks, I believe this is bug#68879, which was already solved in the
development code about a month ago. See commit 2f69353e4a75 on the
emacs-29 branch of the Emacs Git repository. Can you try patching
js.el with that change?
next prev parent reply other threads:[~2024-03-06 17:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 17:25 bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting Divvy Cr.
2024-03-06 17:48 ` Eli Zaretskii [this message]
[not found] ` <CADmOxiLB9J1UhE3UXiMDCDVnUDT-=_i0RjJbbJpn=9uZckf=XA@mail.gmail.com>
2024-03-06 19:21 ` Eli Zaretskii
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=86wmqfjlpm.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=69589@debbugs.gnu.org \
--cc=divvycr@gmail.com \
/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.