]> git.eshelyaron.com Git - emacs.git/commitdiff
Fontification improvements in typescript-ts-mode (bug#60500)
authorJostein Kjønigsen <jostein@kjonigsen.net>
Mon, 2 Jan 2023 19:56:41 +0000 (20:56 +0100)
committerYuan Fu <casouri@gmail.com>
Mon, 2 Jan 2023 22:26:03 +0000 (14:26 -0800)
- highlight method-definitins in interfaces.
- only highlight variable-declarations, not variables
  everywhere (consistency with other modes).
- move highlighting of method invocations to level 4

* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--font-lock-settings): Update rules.
(typescript-ts-mode, tsx-ts-mode): Update feature list.

lisp/progmodes/typescript-ts-mode.el

index a0ba425b3e90a05faa668da4d250dcda8b532089..e0583f4b05ca44c4810c91b3ad1494d443a04b24 100644 (file)
@@ -167,6 +167,8 @@ Argument LANGUAGE is either `typescript' or `tsx'."
 
      (method_definition
       name: (property_identifier) @font-lock-function-name-face)
+     (method_signature
+      name: (property_identifier) @font-lock-function-name-face)
      (required_parameter (identifier) @font-lock-variable-name-face)
      (optional_parameter (identifier) @font-lock-variable-name-face)
 
@@ -211,10 +213,8 @@ Argument LANGUAGE is either `typescript' or `tsx'."
 
      (enum_assignment name: (property_identifier) @font-lock-type-face)
 
-     (assignment_expression
-      left: [(identifier) @font-lock-variable-name-face
-             (member_expression
-              property: (property_identifier) @font-lock-variable-name-face)])
+     (variable_declarator
+      name: (identifier) @font-lock-variable-name-face)
 
      (for_in_statement
       left: (identifier) @font-lock-variable-name-face)
@@ -242,10 +242,6 @@ Argument LANGUAGE is either `typescript' or `tsx'."
       name: (property_identifier) @font-lock-property-face)
      (public_field_definition
       name: (property_identifier) @font-lock-property-face)
-     (member_expression
-      object: (identifier) @font-lock-variable-name-face)
-     (member_expression
-      property: (_) @font-lock-property-face)
 
      (pair key: (property_identifier) @font-lock-variable-name-face)
 
@@ -263,9 +259,11 @@ Argument LANGUAGE is either `typescript' or `tsx'."
       left: [(identifier) @font-lock-function-name-face
              (member_expression
               property: (property_identifier) @font-lock-function-name-face)]
-      right: [(function) (arrow_function)])
+      right: [(function) (arrow_function)]))
 
-     (call_expression
+   :language language
+   :feature 'function
+   '((call_expression
       function:
       [(identifier) @font-lock-function-name-face
        (member_expression
@@ -377,7 +375,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
                 '((comment declaration)
                   (keyword string escape-sequence)
                   (constant expression identifier number pattern property)
-                  (bracket delimiter)))
+                  (function bracket delimiter)))
 
     (treesit-major-mode-setup)))
 
@@ -412,7 +410,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
                 '((comment declaration)
                   (keyword string escape-sequence)
                   (constant expression identifier jsx number pattern property)
-                  (bracket delimiter)))
+                  (function bracket delimiter)))
 
     (treesit-major-mode-setup)))