From 53e78bec7c60fea67ef4ef05ada11ab3c058b0eb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 9 Sep 2025 11:36:47 +0800 Subject: vim-patch:6bb16d2: runtime(python): Update syntax file, fix f-string float highlighting Fix matching of floats at the beginning of an f-string replacement field, immediately after the opening brace. The existing pattern, using `\zs`, cannot consume the already matched `{` so use a lookbehind instead. See comment: https://github.com/vim/vim/pull/17962#issuecomment-3201550443 closes: vim/vim#18220 https://github.com/vim/vim/commit/6bb16d2cee87f834f003bf368ce70c5688242ac1 Co-authored-by: Doug Kearns --- runtime/syntax/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/syntax/python.vim') diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index b2f866b8b3..2382690531 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Python " Maintainer: Zvezdan Petkovic -" Last Change: 2025 Sep 05 +" Last Change: 2025 Sep 08 " Credits: Neil Schemenauer " 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 -- cgit v1.3-3-g829e From 12868474db6fe7e4c3a1494bac26c8b0799393a3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 9 Sep 2025 11:39:03 +0800 Subject: vim-patch:77cfc49: runtime(python): highlight ellipsis literals The ellipsis literal (`...`) can be used in multiple contexts: - Placeholders: `class Foo: ...` - Containers: `Tuple[int, ...]` - Assignments: `x = ...` This is a trickier pattern to match because we can't rely on keyword boundaries, so we instead look for exactly three dots (`...`). This does mean that we will match the `...` portion of `x...x`, which isn't valid Python syntax, but I think that's an acceptable trade-off that avoids making this pattern much more complex. Reference: - https://docs.python.org/3/library/constants.html#Ellipsis closes: vim/vim#18107 https://github.com/vim/vim/commit/77cfc49060a50daefd1675b8a1dece0e6e943384 Co-authored-by: Jon Parise --- runtime/syntax/python.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'runtime/syntax/python.vim') diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index 2382690531..eb1be624fd 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -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>>\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*\)\@>>" 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 -- cgit v1.3-3-g829e