summaryrefslogtreecommitdiff
path: root/lisp/progmodes/js.el
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2023-02-25 03:15:46 +0200
committerDmitry Gutov <dgutov@yandex.ru>2023-02-25 03:35:08 +0200
commita795c51f6053272de61bc1721305e3c15ff424ee (patch)
tree4dcc2aea937392b95296c4b943059f1d5c454800 /lisp/progmodes/js.el
parent146bce49321da3b65d0a0e0326bb54cf1e79551c (diff)
downloademacs-a795c51f6053272de61bc1721305e3c15ff424ee.tar.gz
Add more/finer faces for tree-sitter
* doc/lispref/modes.texi (Faces for Font Lock): Update the list of faces (bug#61655). * etc/NEWS: Update the list of new faces. * lisp/cus-theme.el (custom-theme--listed-faces): Update. * lisp/font-lock.el (font-lock-function-call-face) (font-lock-variable-ref-face, font-lock-property-ref-face): New faces. (font-lock-property-name-face): Rename from 'font-lock-property-face'. * lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings): Use new faces. More 'enumerator' query to 'definition' feature. (c-ts-mode--fontify-declarator, c-ts-mode--fontify-variable): Use new faces. * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/csharp-mode.el (csharp-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/go-ts-mode.el (go-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/js.el (js--treesit-fontify-assignment-lhs) (js--treesit-font-lock-settings): Use new faces. Highlight variable definitions inside array and object destructuring patterns. * lisp/progmodes/python.el (python--treesit-variable-p): Exclude identifiers in parameters. (python--treesit-settings): Use new faces. Highlight function parameters. Move 'keyword' up to still highlight 'self' as keyword. * lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings): Use new faces. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings): Use new faces. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--font-lock-settings): Use new faces. * lisp/textmodes/css-mode.el (css--treesit-settings): Use font-lock-property-ref-face. * lisp/textmodes/toml-ts-mode.el (toml-ts-mode--font-lock-settings): Use font-lock-property-ref-face. * lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode--font-lock-settings): Same.
Diffstat (limited to 'lisp/progmodes/js.el')
-rw-r--r--lisp/progmodes/js.el35
1 files changed, 16 insertions, 19 deletions
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 027d6053f6e..e53a80bd499 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3544,11 +3544,10 @@ This function is intended for use in `after-change-functions'."
value: [(function) (arrow_function)])
(variable_declarator
- name: (array_pattern
- (identifier)
- (identifier)
- @font-lock-function-name-face)
- value: (array (number) (function)))
+ 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
@@ -3564,15 +3563,13 @@ This function is intended for use in `after-change-functions'."
:language 'javascript
:feature 'property
- '(((property_identifier) @font-lock-property-face
+ '(((property_identifier) @font-lock-property-ref-face
(:pred js--treesit-property-not-function-p
- @font-lock-property-face))
-
- (pair value: (identifier) @font-lock-variable-name-face)
+ @font-lock-property-ref-face))
- ((shorthand_property_identifier) @font-lock-property-face)
+ (pair value: (identifier) @font-lock-variable-ref-face)
- ((shorthand_property_identifier_pattern) @font-lock-property-face))
+ ((shorthand_property_identifier) @font-lock-property-ref-face))
:language 'javascript
:feature 'assignment
@@ -3582,14 +3579,14 @@ This function is intended for use in `after-change-functions'."
:language 'javascript
:feature 'function
'((call_expression
- function: [(identifier) @font-lock-function-name-face
+ function: [(identifier) @font-lock-function-call-face
(member_expression
property:
- (property_identifier) @font-lock-function-name-face)])
+ (property_identifier) @font-lock-function-call-face)])
(method_definition
name: (property_identifier) @font-lock-function-name-face)
(function_declaration
- name: (identifier) @font-lock-function-name-face)
+ name: (identifier) @font-lock-function-call-face)
(function
name: (identifier) @font-lock-function-name-face))
@@ -3597,15 +3594,15 @@ This function is intended for use in `after-change-functions'."
:feature 'jsx
'((jsx_opening_element
[(nested_identifier (identifier)) (identifier)]
- @font-lock-function-name-face)
+ @font-lock-function-call-face)
(jsx_closing_element
[(nested_identifier (identifier)) (identifier)]
- @font-lock-function-name-face)
+ @font-lock-function-call-face)
(jsx_self_closing_element
[(nested_identifier (identifier)) (identifier)]
- @font-lock-function-name-face)
+ @font-lock-function-call-face)
(jsx_attribute
(property_identifier)
@@ -3684,8 +3681,8 @@ For OVERRIDE, START, END, see `treesit-font-lock-rules'."
(treesit-fontify-with-override
(treesit-node-start node) (treesit-node-end node)
(pcase (treesit-node-type node)
- ("identifier" 'font-lock-variable-name-face)
- ("property_identifier" 'font-lock-property-face))
+ ("identifier" 'font-lock-variable-ref-face)
+ ("property_identifier" 'font-lock-property-ref-face))
override start end)))
(defun js--treesit-defun-name (node)