diff --git a/syntax/python.vim b/syntax/python.vim index 63224b1..cd26b76 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -264,7 +264,7 @@ 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 matchgroup=pythonStrFormat start="\({\)\@=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=\(}\)\@=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" extend contained containedin=pythonFString,pythonRawFString contains=pythonStrInterpRegion,@pythonExpression syn match pythonStrFormat "{{\|}}" contained containedin=pythonFString,pythonRawFString endif endif diff --git a/tests/test.py b/tests/test.py index 246d109..f37aedc 100644 --- a/tests/test.py +++ b/tests/test.py @@ -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.