Merge pull request #35693 from zeertzjq/vim-6bb16d2

vim-patch: Python syntax updates
This commit is contained in:
zeertzjq
2025-09-09 12:40:12 +08:00
committed by GitHub

View File

@@ -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