From 135a6c88568929f6af2506b98bd90da996280b3a Mon Sep 17 00:00:00 2001 From: Noah Peart Date: Tue, 30 Apr 2024 02:55:18 -0700 Subject: [PATCH] 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. (cherry picked from commit 0f92d433d2b806eb58a9a4c0197344b08ea5ae65) --- lisp/progmodes/python.el | 1 + test/lisp/progmodes/python-tests.el | 3 +++ 2 files changed, 4 insertions(+) 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." (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 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." (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)) -- 2.39.5