From 907ec01b459d97fe631e3f448af82347a5d34371 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sun, 21 Sep 2008 17:41:55 +0400 Subject: [PATCH] Added support for string.Template syntax --- CHANGES.txt | 2 ++ TODO.txt | 6 +++++- python.vim | 14 +++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 02f2023..68de34b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,8 @@ Revision 2.6.1 (unknown): - Added option "python_print_as_function" for highlight "print" as a function; - Added support for new integer literal syntax "0o" and "0b"; + - Added support for string.Template syntax controlled by + "python_highlight_string_templates" option; Revision 2.5.6 (2007-02-04): diff --git a/TODO.txt b/TODO.txt index 3f83a8d..e121e57 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,11 @@ -- Highligh for string.Template? +Now +=== - Python 3.0 string formatting +Later +===== + - Highligh errors where symbols follow by numbers like this: 0o123LaB - Need more accurate way to handle indentation errors. For example diff --git a/python.vim b/python.vim index eb94df7..8877500 100644 --- a/python.vim +++ b/python.vim @@ -13,7 +13,7 @@ " Thanks: " " Jeroen Ruigrok van der Werven -" for the idea of highlighting for erroneous operators +" for the idea to highlight erroneous operators " Pedro Algarvio " for the patch to enable spell checking only for the right spots " (strings and comments) @@ -37,6 +37,9 @@ " For highlight string formatting: " python_highlight_string_formatting " +" For highlight string.Template templates: +" python_highlight_string_templates +" " For highlight indentation errors: " python_highlight_indent_errors " @@ -75,6 +78,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_templates") + let python_highlight_string_templates = 1 + endif if !exists("python_highlight_indent_errors") let python_highlight_indent_errors = 1 endif @@ -180,6 +186,11 @@ if exists("python_highlight_string_formatting") && python_highlight_string_forma syn match pythonStrFormat "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString endif +if exists("python_highlight_string_templates") && python_highlight_string_templates != 0 + " String templates + syn match pythonStrTemplate "\$\(\$\|{[^}]*}\|[a-zA-Z_][a-zA-Z0-9_]*\)" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString +endif + if exists("python_highlight_doctests") && python_highlight_doctests != 0 " DocTests syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained @@ -301,6 +312,7 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonUniRawEscapeError Error HiLink pythonStrFormat Special + HiLink pythonStrTemplate Special HiLink pythonDocTest Special HiLink pythonDocTest2 Special