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.
This commit is contained in:
Noah Peart 2024-04-30 02:55:18 -07:00 committed by Yuan Fu
parent b84fa71f89
commit 0f92d433d2
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 4 additions and 0 deletions

View 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

View 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))