aboutsummaryrefslogtreecommitdiff
path: root/runtime/syntax/python.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-09-06 08:03:37 +0800
committerGitHub <noreply@github.com>2025-09-06 08:03:37 +0800
commit7175fe87dc85e5c981cc837bd468bcebc5094117 (patch)
treea3d3ab6a910605cfa01c046f078fdb877af15dbd /runtime/syntax/python.vim
parent069be911064d0e64f1efc13348dbb878afaf347f (diff)
parentb399a13f70887a9835c37710eb8d703ec01524b2 (diff)
downloadrneovim-7175fe87dc85e5c981cc837bd468bcebc5094117.tar.gz
rneovim-7175fe87dc85e5c981cc837bd468bcebc5094117.tar.bz2
rneovim-7175fe87dc85e5c981cc837bd468bcebc5094117.zip
Merge pull request #35645 from zeertzjq/vim-d2b28dd
vim-patch: Python syntax updates
Diffstat (limited to 'runtime/syntax/python.vim')
-rw-r--r--runtime/syntax/python.vim23
1 files changed, 13 insertions, 10 deletions
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
index 61903802a6..b2f866b8b3 100644
--- 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 Aug 23
+" Last Change: 2025 Sep 05
" Credits: Neil Schemenauer <nas@python.ca>
" Dmitry Vasiliev
" Rob B
@@ -218,21 +218,24 @@ syn region pythonRawBytes
" F-string replacement fields
"
-" - Matched parentheses, brackets and braces are ignored
-" - A bare # is ignored to end of line
-" - A bare = (surrounded by optional whitespace) enables debugging
-" - A bare ! prefixes a conversion field
+" - Matched parentheses, brackets and braces are skipped
+" - A bare = (followed by optional whitespace) enables debugging
+" - A bare ! prefixes a conversion field (followed by optional whitespace)
" - A bare : begins a format specification
-" - Matched braces inside a format specification are ignored
+" - Matched braces inside a format specification are skipped
"
syn region pythonFStringField
\ matchgroup=pythonFStringDelimiter
\ start=/{/
- \ skip=/([^)]*)\|\[[^]]*]\|{[^}]*}\|#.*$/
- \ end=/\%(\s*=\s*\)\=\%(!\a\)\=\%(:\%({[^}]*}\|[^}]*\)\+\)\=}/
+ \ end=/\%(=\s*\)\=\%(!\a\s*\)\=\%(:\%({\_[^}]*}\|[^{}]*\)\+\)\=}/
\ contained
-" Doubled braces and Unicode escapes are not replacement fields
-syn match pythonFStringSkip /{{\|\\N{/ transparent contained contains=NONE
+ \ contains=ALLBUT,pythonFStringField,pythonClass,pythonFunction,pythonType,pythonDoctest,pythonDoctestValue,@Spell
+syn match pythonFStringFieldSkip /(\_[^()]*)\|\[\_[^][]*]\|{\_[^{}]*}/
+ \ contained
+ \ contains=ALLBUT,pythonFStringField,pythonClass,pythonFunction,pythonType,pythonDoctest,pythonDoctestValue,@Spell
+
+" Doubled braces are not replacement fields
+syn match pythonFStringSkip /{{/ transparent contained contains=NONE
syn match pythonEscape +\\[abfnrtv'"\\]+ contained
syn match pythonEscape "\\\o\{1,3}" contained