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
     - Added option "python_print_as_function" for highlight "print" as a
9
     - Added option "python_print_as_function" for highlight "print" as a
10
       function;
10
       function;
11
     - Added support for new integer literal syntax "0o" and "0b";
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
 Revision 2.5.6 (2007-02-04):
15
 Revision 2.5.6 (2007-02-04):
14
 
16
 

+ 5
- 1
TODO.txt View File

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

+ 13
- 1
python.vim View File

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