runtime(python): fix 'type' syntax highlighting
Commit:
https://github.com/vim/vim/commit/900c747da393b031f3347428fb640224ac2f5442
Author: Jon Parise <[email protected]>
Date: Thu Sep 25 19:08:14 2025 +0000
runtime(python): fix 'type' syntax highlighting
The previous patterns unintentionally highlighted words like 'typename'.
addresses: https://github.com/vim/vim/pull/18090#issuecomment-3333025523
closes: #18394
Signed-off-by: Jon Parise <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
index 86aa6d329..05c965ec6 100644
--- a/runtime/syntax/python.vim
+++ b/runtime/syntax/python.vim
@@ -2,6 +2,7 @@
" Language: Python
" Maintainer: Zvezdan Petkovic <[email protected]>
" Last Change: 2025 Sep 08
+" 2025 Sep 25 by Vim Project: fix wrong type highlighting #18394
" Credits: Neil Schemenauer <[email protected]>
" Dmitry Vasiliev
" Rob B
@@ -308,7 +309,7 @@ if !exists("python_no_builtin_highlight")
syn keyword pythonBuiltin setattr slice sorted staticmethod str sum super
syn keyword pythonBuiltin tuple vars zip __import__
" only match `type` as a builtin when it's not followed by an identifier
- syn match pythonBuiltin "\<type\ze\(\s\+\h\w*\)\@!"
+ syn match pythonBuiltin "\<type\>\ze\(\s\+\h\w*\)\@!"
" avoid highlighting attributes as builtins
syn match pythonAttribute /\.\h\w*/hs=s+1
\
contains=ALLBUT,pythonBuiltin,pythonClass,pythonFunction,pythonType,pythonAsync
diff --git a/runtime/syntax/testdir/dumps/python_type_00.dump
b/runtime/syntax/testdir/dumps/python_type_00.dump
new file mode 100644
index 000000000..eeb735e1f
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/python_type_00.dump
@@ -0,0 +1,20 @@
+>#+0#0000e05#ffffff0| |B|u|i|l|t|i|n| +0#0000000&@65
+|t+0#00e0e07&|y|p|e|(+0#0000000&|)| @68
+@75
+|#+0#0000e05&| |S|t|a|t|e|m|e|n|t| +0#0000000&@63
+|t+0#af5f00255&|y|p|e| +0#0000000&|P+0#00e0003&|o|i|n|t| +0#0000000&|=|
|t+0#00e0e07&|u|p|l|e|[+0#0000000&|f+0#00e0e07&|l|o|a|t|,+0#0000000&|
|f+0#00e0e07&|l|o|a|t|]+0#0000000&| @42
+@75
+|#+0#0000e05&| |S|h|o|u|l|d| |n|o|t| |m|a|t|c|h| +0#0000000&@56
+|t|y|p|e|n|a|m|e| |=| |'+0#e000002&@1| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1|
diff --git a/runtime/syntax/testdir/input/python_type.py
b/runtime/syntax/testdir/input/python_type.py
new file mode 100644
index 000000000..513b97fbd
--- /dev/null
+++ b/runtime/syntax/testdir/input/python_type.py
@@ -0,0 +1,8 @@
+# Builtin
+type()
+
+# Statement
+type Point = tuple[float, float]
+
+# Should not match
+typename = ''
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1v1rQm-00BH6V-V0%40256bit.org.