commit d15936f6ef9b6d225b92d93369efaf2b1bb37474
parent eb19206e032a9798e68de1d76f02e568d8e076f4
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 9 Sep 2025 12:40:12 +0800
Merge pull request #35693 from zeertzjq/vim-6bb16d2
vim-patch: Python syntax updates
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: Python
" Maintainer: Zvezdan Petkovic <zpetkovic@acm.org>
-" Last Change: 2025 Sep 05
+" Last Change: 2025 Sep 08
" Credits: Neil Schemenauer <nas@python.ca>
" Dmitry Vasiliev
" Rob B
@@ -271,7 +271,7 @@ if !exists("python_no_number_highlight")
syn match pythonNumber
\ "\<\d\%(_\=\d\)*\.\%([eE][+-]\=\d\%(_\=\d\)*\)\=[jJ]\=\%(\W\|$\)\@="
syn match pythonNumber
- \ "\%(^\|\W\)\zs\%(\d\%(_\=\d\)*\)\=\.\d\%(_\=\d\)*\%([eE][+-]\=\d\%(_\=\d\)*\)\=[jJ]\=\>"
+ \ "\%(^\|\W\)\@1<=\%(\d\%(_\=\d\)*\)\=\.\d\%(_\=\d\)*\%([eE][+-]\=\d\%(_\=\d\)*\)\=[jJ]\=\>"
endif
" Group the built-ins in the order in the 'Python Library Reference' for
@@ -313,6 +313,8 @@ if !exists("python_no_builtin_highlight")
syn match pythonAttribute /\.\h\w*/hs=s+1
\ contains=ALLBUT,pythonBuiltin,pythonClass,pythonFunction,pythonType,pythonAsync
\ transparent
+ " the ellipsis literal `...` can be used in multiple syntactic contexts
+ syn match pythonEllipsis "\.\@1<!.\.\.\ze\.\@!" display
endif
" From the 'Python Library Reference' class hierarchy at the bottom.
@@ -368,10 +370,12 @@ if !exists("python_no_doctest_highlight")
if !exists("python_no_doctest_code_highlight")
syn region pythonDoctest
\ start="^\s*>>>\s" end="^\s*$"
- \ contained contains=ALLBUT,pythonDoctest,pythonClass,pythonFunction,pythonType,@Spell
+ \ contained contains=ALLBUT,pythonDoctest,pythonEllipsis,pythonClass,pythonFunction,pythonType,@Spell
syn region pythonDoctestValue
\ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$"
- \ contained
+ \ contained contains=pythonEllipsis
+ syn match pythonEllipsis "\%(^\s*\)\@<!\.\@1<!\zs\.\.\.\ze\.\@!" display
+ \ contained containedin=pythonDoctest
else
syn region pythonDoctest
\ start="^\s*>>>" end="^\s*$"
@@ -414,6 +418,7 @@ if !exists("python_no_number_highlight")
endif
if !exists("python_no_builtin_highlight")
hi def link pythonBuiltin Function
+ hi def link pythonEllipsis pythonBuiltin
endif
if !exists("python_no_exception_highlight")
hi def link pythonExceptions Structure