Browse Source

Added support for str.format syntax

Dmitry Vasiliev 15 years ago
parent
commit
07c654e70d
3 changed files with 19 additions and 7 deletions
  1. 2
    0
      CHANGES.txt
  2. 0
    2
      TODO.txt
  3. 17
    5
      python.vim

+ 2
- 0
CHANGES.txt View File

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
12
     - Added support for string.Template syntax controlled by
13
       "python_highlight_string_templates" option;
13
       "python_highlight_string_templates" option;
14
+    - Added support for str.format syntax controlled by
15
+      "python_highlight_string_format" option;
14
 
16
 
15
 Revision 2.5.6 (2007-02-04):
17
 Revision 2.5.6 (2007-02-04):
16
 
18
 

+ 0
- 2
TODO.txt View File

1
 Now
1
 Now
2
 ===
2
 ===
3
 
3
 
4
-- Python 3.0 string formatting
5
-
6
 Later
4
 Later
7
 =====
5
 =====
8
 
6
 

+ 17
- 5
python.vim View File

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:
40
+"    For highlight str.format syntax:
41
+"       python_highlight_string_format
42
+"
43
+"    For highlight string.Template syntax:
41
 "       python_highlight_string_templates
44
 "       python_highlight_string_templates
42
 "
45
 "
43
 "    For highlight indentation errors:
46
 "    For highlight indentation errors:
78
   if !exists("python_highlight_string_formatting")
81
   if !exists("python_highlight_string_formatting")
79
     let python_highlight_string_formatting = 1
82
     let python_highlight_string_formatting = 1
80
   endif
83
   endif
84
+  if !exists("python_highlight_string_format")
85
+    let python_highlight_string_format = 1
86
+  endif
81
   if !exists("python_highlight_string_templates")
87
   if !exists("python_highlight_string_templates")
82
     let python_highlight_string_templates = 1
88
     let python_highlight_string_templates = 1
83
   endif
89
   endif
182
 
188
 
183
 if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
189
 if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
184
   " String formatting
190
   " String formatting
185
-  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
191
+  syn match pythonStrFormatting	"%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
192
+  syn match pythonStrFormatting	"%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
193
+endif
194
+
195
+if exists("python_highlight_string_format") && python_highlight_string_format != 0
196
+  " str.format syntax
197
+  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
187
 endif
198
 endif
188
 
199
 
189
 if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
200
 if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
311
   HiLink pythonUniRawEscape		Special
322
   HiLink pythonUniRawEscape		Special
312
   HiLink pythonUniRawEscapeError	Error
323
   HiLink pythonUniRawEscapeError	Error
313
 
324
 
314
-  HiLink pythonStrFormat	Special
315
-  HiLink pythonStrTemplate	Special
325
+  HiLink pythonStrFormatting	Special
326
+  HiLink pythonStrFormat    	Special
327
+  HiLink pythonStrTemplate	    Special
316
 
328
 
317
   HiLink pythonDocTest		Special
329
   HiLink pythonDocTest		Special
318
   HiLink pythonDocTest2		Special
330
   HiLink pythonDocTest2		Special