diff --git a/CHANGES.txt b/CHANGES.txt index 68de34b..9961ffd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,8 @@ Revision 2.6.1 (unknown): - Added support for new integer literal syntax "0o" and "0b"; - Added support for string.Template syntax controlled by "python_highlight_string_templates" option; + - Added support for str.format syntax controlled by + "python_highlight_string_format" option; Revision 2.5.6 (2007-02-04): diff --git a/TODO.txt b/TODO.txt index e121e57..ecd9b78 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,8 +1,6 @@ Now === -- Python 3.0 string formatting - Later ===== diff --git a/python.vim b/python.vim index eb19995..53f1112 100644 --- a/python.vim +++ b/python.vim @@ -37,7 +37,10 @@ " For highlight string formatting: " python_highlight_string_formatting " -" For highlight string.Template templates: +" For highlight str.format syntax: +" python_highlight_string_format +" +" For highlight string.Template syntax: " python_highlight_string_templates " " For highlight indentation errors: @@ -78,6 +81,9 @@ if exists("python_highlight_all") && python_highlight_all != 0 if !exists("python_highlight_string_formatting") let python_highlight_string_formatting = 1 endif + if !exists("python_highlight_string_format") + let python_highlight_string_format = 1 + endif if !exists("python_highlight_string_templates") let python_highlight_string_templates = 1 endif @@ -182,8 +188,13 @@ syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0 " String formatting - syn match pythonStrFormat "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString - syn match pythonStrFormat "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString + syn match pythonStrFormatting "%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString + syn match pythonStrFormatting "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString +endif + +if exists("python_highlight_string_format") && python_highlight_string_format != 0 + " str.format syntax + syn match pythonStrFormat "{\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)\(\.[a-zA-Z_][a-zA-Z0-9_]*\|\[\(\d\+\|[^!:\}]\+\)\]\)*\(![rs]\)\=\(:\({\([a-zA-Z_][a-zA-Z0-9_]*\|\d\+\)}\|\([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*\(\.\d\+\)\=[bcdeEfFgGnoxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString endif if exists("python_highlight_string_templates") && python_highlight_string_templates != 0 @@ -311,8 +322,9 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonUniRawEscape Special HiLink pythonUniRawEscapeError Error - HiLink pythonStrFormat Special - HiLink pythonStrTemplate Special + HiLink pythonStrFormatting Special + HiLink pythonStrFormat Special + HiLink pythonStrTemplate Special HiLink pythonDocTest Special HiLink pythonDocTest2 Special