mirror of
https://github.com/vim-python/python-syntax.git
synced 2026-01-25 20:36:58 +08:00
Merge branch 'fstring'
This commit is contained in:
@@ -103,7 +103,7 @@ else
|
||||
syn match pythonStatement '\<async\s\+def\>' nextgroup=pythonFunction skipwhite
|
||||
syn match pythonStatement '\<async\s\+with\>'
|
||||
syn match pythonStatement '\<async\s\+for\>'
|
||||
syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonNone,pythonSingleton,pythonBuiltinObj,pythonBuiltinFunc,pythonBuiltinType
|
||||
syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonFString,pythonRawString,pythonRawFString,pythonBytes,pythonBoolean,pythonNone,pythonSingleton,pythonBuiltinObj,pythonBuiltinFunc,pythonBuiltinType
|
||||
endif
|
||||
|
||||
|
||||
@@ -264,8 +264,8 @@ if s:Enabled('g:python_highlight_string_format')
|
||||
syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString
|
||||
else
|
||||
syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString
|
||||
syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString,pythonRawFString contains=pythonStrInterpRegion,@pythonExpression
|
||||
syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString,pythonRawFString
|
||||
syn region pythonStrInterpRegion matchgroup=pythonStrFormat start="{" end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" extend contained containedin=pythonFString,pythonRawFString contains=pythonStrInterpRegion,@pythonExpression
|
||||
syn match pythonStrFormat "{{\|}}" contained containedin=pythonFString,pythonRawFString
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -471,7 +471,6 @@ if v:version >= 508 || !exists('did_python_syn_inits')
|
||||
HiLink pythonBytesEscapeError Error
|
||||
HiLink pythonFString String
|
||||
HiLink pythonRawFString String
|
||||
HiLink pythonStrInterpRegion Special
|
||||
endif
|
||||
|
||||
HiLink pythonStrFormatting Special
|
||||
|
||||
@@ -244,8 +244,11 @@ b"${test} ${test ${test}aname $$$ $test+nope"
|
||||
f"{var}...{arr[123]} normal {var['{'] // 0xff} \"xzcb\" 'xzcb' {var['}'] + 1} text"
|
||||
f"{expr1 if True or False else expr2} {None} wow {','.join(c.lower() for c in 'asdf')}"
|
||||
f"hello {expr:.2f} yes {(lambda: 0b1)():#03x} lol {var!r}"
|
||||
f'brackets: {{ 1 + 2 }} and {{{{ 3 + 4 }}}}'
|
||||
f'brackets: {{{ 1 + 2 }}} and {{{{ 3 + 4 }}}}'
|
||||
fr'this {that}'
|
||||
f"{f'{1+1}'}"
|
||||
'{{ }}'
|
||||
f"{"{test}"}" # FIXME: syntax error that should not be highlighted
|
||||
|
||||
# Doctests.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user