aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoah Peart2024-04-30 02:55:18 -0700
committerYuan Fu2024-05-01 21:26:29 -0700
commit0f92d433d2b806eb58a9a4c0197344b08ea5ae65 (patch)
treeac37a8fea44d120caf1cebb604b08ef099aa189d
parentb84fa71f8985284560bacda7d407e3559583844f (diff)
downloademacs-0f92d433d2b806eb58a9a4c0197344b08ea5ae65.tar.gz
emacs-0f92d433d2b806eb58a9a4c0197344b08ea5ae65.zip
Add font-locking for typed parameters in python-ts-mode (bug#70665)
* 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.
-rw-r--r--lisp/progmodes/python.el1
-rw-r--r--test/lisp/progmodes/python-tests.el3
2 files changed, 4 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d6c29e5ffc6..4ff5e9d4878 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1202,6 +1202,7 @@ fontified."
1202 (class_definition 1202 (class_definition
1203 name: (identifier) @font-lock-type-face) 1203 name: (identifier) @font-lock-type-face)
1204 (parameters (identifier) @font-lock-variable-name-face) 1204 (parameters (identifier) @font-lock-variable-name-face)
1205 (parameters (typed_parameter (identifier) @font-lock-variable-name-face))
1205 (parameters (default_parameter name: (identifier) @font-lock-variable-name-face))) 1206 (parameters (default_parameter name: (identifier) @font-lock-variable-name-face)))
1206 1207
1207 :feature 'builtin 1208 :feature 'builtin
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index e11440cdb5b..878f60f1614 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -7545,6 +7545,9 @@ always located at the beginning of buffer."
7545(ert-deftest python-ts-mode-types-face-1 () 7545(ert-deftest python-ts-mode-types-face-1 ()
7546 (python-ts-tests-with-temp-buffer 7546 (python-ts-tests-with-temp-buffer
7547 "def f(val: Callable[[Type0], (Type1, Type2)]):" 7547 "def f(val: Callable[[Type0], (Type1, Type2)]):"
7548 (search-forward "val")
7549 (goto-char (match-beginning 0))
7550 (should (eq (face-at-point) font-lock-variable-name-face))
7548 (dolist (test '("Callable" "Type0" "Type1" "Type2")) 7551 (dolist (test '("Callable" "Type0" "Type1" "Type2"))
7549 (search-forward test) 7552 (search-forward test)
7550 (goto-char (match-beginning 0)) 7553 (goto-char (match-beginning 0))