Browse Source

Added support for string.Template syntax

Dmitry Vasiliev 15 years ago
parent
commit
907ec01b45
3 changed files with 20 additions and 2 deletions
  1. 2
    0
      CHANGES.txt
  2. 5
    1
      TODO.txt
  3. 13
    1
      python.vim

+ 2
- 0
CHANGES.txt View File

@@ -9,6 +9,8 @@ Revision 2.6.1 (unknown):
9 9
     - Added option "python_print_as_function" for highlight "print" as a
10 10
       function;
11 11
     - Added support for new integer literal syntax "0o" and "0b";
12
+    - Added support for string.Template syntax controlled by
13
+      "python_highlight_string_templates" option;
12 14
 
13 15
 Revision 2.5.6 (2007-02-04):
14 16
 

+ 5
- 1
TODO.txt View File

@@ -1,7 +1,11 @@
1
-- Highligh for string.Template?
1
+Now
2
+===
2 3
 
3 4
 - Python 3.0 string formatting
4 5
 
6
+Later
7
+=====
8
+
5 9
 - Highligh errors where symbols follow by numbers like this: 0o123LaB
6 10
 
7 11
 - Need more accurate way to handle indentation errors. For example

+ 13
- 1
python.vim View File

@@ -13,7 +13,7 @@
13 13
 " Thanks:
14 14
 "
15 15
 "    Jeroen Ruigrok van der Werven
16
-"        for the idea of highlighting for erroneous operators
16
+"        for the idea to highlight erroneous operators
17 17
 "    Pedro Algarvio
18 18
 "        for the patch to enable spell checking only for the right spots
19 19
 "        (strings and comments)
@@ -37,6 +37,9 @@
37 37
 "    For highlight string formatting:
38 38
 "       python_highlight_string_formatting
39 39
 "
40
+"    For highlight string.Template templates:
41
+"       python_highlight_string_templates
42
+"
40 43
 "    For highlight indentation errors:
41 44
 "       python_highlight_indent_errors
42 45
 "
@@ -75,6 +78,9 @@ if exists("python_highlight_all") && python_highlight_all != 0
75 78
   if !exists("python_highlight_string_formatting")
76 79
     let python_highlight_string_formatting = 1
77 80
   endif
81
+  if !exists("python_highlight_string_templates")
82
+    let python_highlight_string_templates = 1
83
+  endif
78 84
   if !exists("python_highlight_indent_errors")
79 85
     let python_highlight_indent_errors = 1
80 86
   endif
@@ -180,6 +186,11 @@ if exists("python_highlight_string_formatting") && python_highlight_string_forma
180 186
   syn match pythonStrFormat	"%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
181 187
 endif
182 188
 
189
+if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
190
+  " String templates
191
+  syn match pythonStrTemplate	"\$\(\$\|{[^}]*}\|[a-zA-Z_][a-zA-Z0-9_]*\)" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
192
+endif
193
+
183 194
 if exists("python_highlight_doctests") && python_highlight_doctests != 0
184 195
   " DocTests
185 196
   syn region pythonDocTest	start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
@@ -301,6 +312,7 @@ if version >= 508 || !exists("did_python_syn_inits")
301 312
   HiLink pythonUniRawEscapeError	Error
302 313
 
303 314
   HiLink pythonStrFormat	Special
315
+  HiLink pythonStrTemplate	Special
304 316
 
305 317
   HiLink pythonDocTest		Special
306 318
   HiLink pythonDocTest2		Special