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: Divvy Cr.
Subject: bug#69589: 29.2; Invalid query in js--treesit-font-lock-settings prevents syntax highlighting
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.


In GNU Emacs 29.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33,
 cairo version 1.16.0) of 2024-03-05 built on DV-Portable
System Description: Ubuntu 22.04.4 LTS

Configured using:
 'configure --with-pgtk --with-native-compilation
 --without-compress-install --with-tree-sitter'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER XIM GTK3 ZLIB

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix

Major mode: _javascript_

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr cl-print thingatpt help-fns radix-tree emacsbug
message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec
password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils pp wid-edit descr-text js
c-ts-common treesit json map byte-opt imenu cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
cl-loaddefs comp comp-cstr warnings icons subr-x rx cl-seq cl-macs gv
cl-extra help-mode bytecomp byte-compile cl-lib rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs theme-loaddefs faces cus-face macroexp files window
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget keymap hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
gtk pgtk lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 146459 33528)
 (symbols 48 22745 0)
 (strings 32 97373 2695)
 (string-bytes 1 2500148)
 (vectors 16 25550)
 (vector-slots 8 853209 33493)
 (floats 8 53 28)
 (intervals 56 282 0)
 (buffers 984 14))

reply via email to

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