]> git.eshelyaron.com Git - emacs.git/commitdiff
Add font-locking for typed parameters in python-ts-mode (bug#70665)
authorNoah Peart <noah.v.peart@gmail.com>
Tue, 30 Apr 2024 09:55:18 +0000 (02:55 -0700)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:32:07 +0000 (18:32 +0200)
* lisp/progmodes/python.el (python--treesit-settings): Add
tree-sitter font-locking rule for typed parameters.
* test/lisp/progmodes/python-tests.el
(python-ts-mode-types-face-1): Test for
font-lock-variable-name-face in typed parameter.

(cherry picked from commit 0f92d433d2b806eb58a9a4c0197344b08ea5ae65)

lisp/progmodes/python.el
test/lisp/progmodes/python-tests.el

index d6c29e5ffc68d137bb151c32169ebf756383976d..4ff5e9d487809f986c45f0264b079eff132eb432 100644 (file)
@@ -1202,6 +1202,7 @@ fontified."
      (class_definition
       name: (identifier) @font-lock-type-face)
      (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)))
 
    :feature 'builtin
index e11440cdb5b7d45c3c70779841e26c658674c2fe..878f60f16141b53d8f3d142c50ad57845d5b8d27 100644 (file)
@@ -7545,6 +7545,9 @@ always located at the beginning of buffer."
 (ert-deftest python-ts-mode-types-face-1 ()
   (python-ts-tests-with-temp-buffer
    "def f(val: Callable[[Type0], (Type1, Type2)]):"
+   (search-forward "val")
+   (goto-char (match-beginning 0))
+   (should (eq (face-at-point) font-lock-variable-name-face))
    (dolist (test '("Callable" "Type0" "Type1" "Type2"))
      (search-forward test)
      (goto-char (match-beginning 0))