mirror of
https://github.com/neovim/neovim.git
synced 2025-11-16 15:21:20 +00:00
vim-patch:d2b28dd: runtime(python): add syntax support inside f-strings
fixes: vim/vim#14033
closes: vim/vim#17962
d2b28ddfc2
Co-authored-by: Rob B <github@0x7e.net>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
" Vim syntax file
|
" Vim syntax file
|
||||||
" Language: Python
|
" Language: Python
|
||||||
" Maintainer: Zvezdan Petkovic <zpetkovic@acm.org>
|
" Maintainer: Zvezdan Petkovic <zpetkovic@acm.org>
|
||||||
" Last Change: 2025 Aug 23
|
" Last Change: 2025 Sep 05
|
||||||
" Credits: Neil Schemenauer <nas@python.ca>
|
" Credits: Neil Schemenauer <nas@python.ca>
|
||||||
" Dmitry Vasiliev
|
" Dmitry Vasiliev
|
||||||
" Rob B
|
" Rob B
|
||||||
@@ -218,21 +218,24 @@ syn region pythonRawBytes
|
|||||||
|
|
||||||
" F-string replacement fields
|
" F-string replacement fields
|
||||||
"
|
"
|
||||||
" - Matched parentheses, brackets and braces are ignored
|
" - Matched parentheses, brackets and braces are skipped
|
||||||
" - A bare # is ignored to end of line
|
" - A bare = (followed by optional whitespace) enables debugging
|
||||||
" - A bare = (surrounded by optional whitespace) enables debugging
|
" - A bare ! prefixes a conversion field (followed by optional whitespace)
|
||||||
" - A bare ! prefixes a conversion field
|
|
||||||
" - A bare : begins a format specification
|
" - 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
|
syn region pythonFStringField
|
||||||
\ matchgroup=pythonFStringDelimiter
|
\ matchgroup=pythonFStringDelimiter
|
||||||
\ start=/{/
|
\ start=/{/
|
||||||
\ skip=/([^)]*)\|\[[^]]*]\|{[^}]*}\|#.*$/
|
\ end=/\%(=\s*\)\=\%(!\a\s*\)\=\%(:\%({\_[^}]*}\|[^{}]*\)\+\)\=}/
|
||||||
\ end=/\%(\s*=\s*\)\=\%(!\a\)\=\%(:\%({[^}]*}\|[^}]*\)\+\)\=}/
|
|
||||||
\ contained
|
\ contained
|
||||||
" Doubled braces and Unicode escapes are not replacement fields
|
\ contains=ALLBUT,pythonFStringField,pythonClass,pythonFunction,pythonDoctest,pythonDoctestValue,@Spell
|
||||||
syn match pythonFStringSkip /{{\|\\N{/ transparent contained contains=NONE
|
syn match pythonFStringFieldSkip /(\_[^()]*)\|\[\_[^][]*]\|{\_[^{}]*}/
|
||||||
|
\ contained
|
||||||
|
\ contains=ALLBUT,pythonFStringField,pythonClass,pythonFunction,pythonDoctest,pythonDoctestValue,@Spell
|
||||||
|
|
||||||
|
" Doubled braces are not replacement fields
|
||||||
|
syn match pythonFStringSkip /{{/ transparent contained contains=NONE
|
||||||
|
|
||||||
syn match pythonEscape +\\[abfnrtv'"\\]+ contained
|
syn match pythonEscape +\\[abfnrtv'"\\]+ contained
|
||||||
syn match pythonEscape "\\\o\{1,3}" contained
|
syn match pythonEscape "\\\o\{1,3}" contained
|
||||||
|
|||||||
Reference in New Issue
Block a user