bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevent


From: Eli Zaretskii
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

> 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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]