diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2025-07-18 09:42:50 +0200 |
|---|---|---|
| committer | Christian Clason <ch.clason+github@icloud.com> | 2025-07-18 10:33:05 +0200 |
| commit | 9df9d3af3be88ad17157a4028fe0d40101d2664c (patch) | |
| tree | b05a9b2470368edc2519e3c851de2e82624b9b45 /runtime/syntax/python.vim | |
| parent | fd5d04fbffec9a4ba87add584b36abbefa21a69e (diff) | |
vim-patch:b7fc24d: runtime(python): Highlight f-strings in Python
fixes: vim/vim#10734
fixes: vim/vim#14033
closes: vim/vim#17767
https://github.com/vim/vim/commit/b7fc24d3a3d21ccf1461c703eb7ff07ef3994c54
Co-authored-by: Rob B <github@0x7e.net>
Diffstat (limited to 'runtime/syntax/python.vim')
| -rw-r--r-- | runtime/syntax/python.vim | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index 4b775f2c34..dfebf547b1 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 Jul 14 +" Last Change: 2025 Jul 17 " Credits: Neil Schemenauer <nas@python.ca> " Dmitry Vasiliev " Rob B @@ -156,6 +156,33 @@ syn region pythonRawString matchgroup=pythonTripleQuotes \ start=+[rR]\z('''\|"""\)+ end="\z1" keepend \ contains=pythonSpaceError,pythonDoctest,@Spell +" Formatted string literals (f-strings) +" https://docs.python.org/3/reference/lexical_analysis.html#f-strings +syn region pythonFString + \ matchgroup=pythonQuotes + \ start=+\cF\z(['"]\)+ + \ end="\z1" + \ skip="\\\\\|\\\z1" + \ contains=pythonEscape,pythonUnicodeEscape,@Spell +syn region pythonFString + \ matchgroup=pythonTripleQuotes + \ start=+\cF\z('''\|"""\)+ + \ end="\z1" + \ keepend + \ contains=pythonEscape,pythonUnicodeEscape,pythonSpaceError,pythonDoctest,@Spell +syn region pythonRawFString + \ matchgroup=pythonQuotes + \ start=+\c\%(FR\|RF\)\z(['"]\)+ + \ end="\z1" + \ skip="\\\\\|\\\z1" + \ contains=@Spell +syn region pythonRawFString + \ matchgroup=pythonTripleQuotes + \ start=+\c\%(FR\|RF\)\z('''\|"""\)+ + \ end="\z1" + \ keepend + \ contains=pythonSpaceError,pythonDoctest,@Spell + " Bytes syn region pythonBytes \ matchgroup=pythonQuotes @@ -338,6 +365,8 @@ hi def link pythonComment Comment hi def link pythonTodo Todo hi def link pythonString String hi def link pythonRawString String +hi def link pythonFString String +hi def link pythonRawFString String hi def link pythonBytes String hi def link pythonRawBytes String hi def link pythonQuotes String |
