diff options
author | Dmitry Gutov <dmitry@gutov.dev> | 2023-12-08 04:12:21 +0200 |
---|---|---|
committer | Dmitry Gutov <dmitry@gutov.dev> | 2023-12-08 04:12:21 +0200 |
commit | 4a72f13bdfb7806b933b5198641938cbf3586611 (patch) | |
tree | b2dd3b229ac6402b1bd2aba025d6e7cd2b046493 /lisp/progmodes | |
parent | 83ed9018ede57f6ef0e3645147fdb529490268fc (diff) | |
download | emacs-4a72f13bdfb7806b933b5198641938cbf3586611.tar.gz emacs-4a72f13bdfb7806b933b5198641938cbf3586611.tar.bz2 emacs-4a72f13bdfb7806b933b5198641938cbf3586611.zip |
js-ts-mode: Highlight property shorthands in assignments
* lisp/progmodes/js.el (js--treesit-lhs-identifier-query): Match
property shorthands (which turn into variable reference).
(js--treesit-fontify-assignment-lhs): Use the matches.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/js.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 03f34647288..eb4adc627ee 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3664,7 +3664,8 @@ OVERRIDE is the override flag described in (defvar js--treesit-lhs-identifier-query (when (treesit-available-p) (treesit-query-compile 'javascript '((identifier) @id - (property_identifier) @id))) + (property_identifier) @id + (shorthand_property_identifier_pattern) @id))) "Query that captures identifier and query_identifier.") (defun js--treesit-fontify-assignment-lhs (node override start end &rest _) @@ -3676,7 +3677,8 @@ For OVERRIDE, START, END, see `treesit-font-lock-rules'." (treesit-node-start node) (treesit-node-end node) (pcase (treesit-node-type node) ("identifier" 'font-lock-variable-use-face) - ("property_identifier" 'font-lock-property-use-face)) + ("property_identifier" 'font-lock-property-use-face) + ("shorthand_property_identifier_pattern" 'font-lock-variable-use-face)) override start end))) (defun js--treesit-defun-name (node) |