]> git.eshelyaron.com Git - emacs.git/commitdiff
python-ts-mode: Improve fontification
authorJostein Kjønigsen <jostein@kjonigsen.net>
Thu, 20 Mar 2025 09:39:31 +0000 (10:39 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 22 Jun 2025 08:09:28 +0000 (10:09 +0200)
python--treesit-settings: Fontification based on selectors & code-conventions

- Constructor: Fontified as type, not function-call.
- Typed default parameters
- Fontify kwargs in function calls as property-use. Differentiate from
  variable-use (passed in arguments)

(cherry picked from commit 39721a4d79a6056e09f4d0996f1942eee8e34934)

lisp/progmodes/python.el

index 664c00243a9528a6ece105ec74477d1392494457..d041d1713ef014c8359d4f77735a3a69b1ca6050 100644 (file)
@@ -1231,6 +1231,7 @@ fontified."
      (parameters (identifier) @font-lock-variable-name-face)
      (parameters (typed_parameter (identifier) @font-lock-variable-name-face))
      (parameters (default_parameter name: (identifier) @font-lock-variable-name-face))
+     (parameters (typed_default_parameter name: (identifier) @font-lock-variable-name-face))
      (lambda_parameters (identifier) @font-lock-variable-name-face)
      (for_in_clause
       left: (identifier) @font-lock-variable-name-face)
@@ -1261,7 +1262,11 @@ fontified."
 
    :feature 'function
    :language 'python
-   '((call function: (identifier) @font-lock-function-call-face)
+   '(((call function: (identifier) @font-lock-type-face)
+      (:match "\\`[A-Z][A-Za-z0-9]+\\'" @font-lock-type-face))
+     (call function: (identifier) @font-lock-function-call-face)
+     (call arguments: (argument_list (keyword_argument
+                                      name: (identifier) @font-lock-property-name-face)))
      (call function: (attribute
                       attribute: (identifier) @font-lock-function-call-face)))