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,6 +11,8 @@ Revision 2.6.1 (unknown):
11 11
     - Added support for new integer literal syntax "0o" and "0b";
12 12
     - Added support for string.Template syntax controlled by
13 13
       "python_highlight_string_templates" option;
14
+    - Added support for str.format syntax controlled by
15
+      "python_highlight_string_format" option;
14 16
 
15 17
 Revision 2.5.6 (2007-02-04):
16 18
 

+ 0
- 2
TODO.txt View File

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

+ 17
- 5
python.vim View File

@@ -37,7 +37,10 @@
37 37
 "    For highlight string formatting:
38 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 44
 "       python_highlight_string_templates
42 45
 "
43 46
 "    For highlight indentation errors:
@@ -78,6 +81,9 @@ if exists("python_highlight_all") && python_highlight_all != 0
78 81
   if !exists("python_highlight_string_formatting")
79 82
     let python_highlight_string_formatting = 1
80 83
   endif
84
+  if !exists("python_highlight_string_format")
85
+    let python_highlight_string_format = 1
86
+  endif
81 87
   if !exists("python_highlight_string_templates")
82 88
     let python_highlight_string_templates = 1
83 89
   endif
@@ -182,8 +188,13 @@ syn match  pythonUniRawEscapeError	"\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display
182 188
 
183 189
 if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
184 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 198
 endif
188 199
 
189 200
 if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
@@ -311,8 +322,9 @@ if version >= 508 || !exists("did_python_syn_inits")
311 322
   HiLink pythonUniRawEscape		Special
312 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 329
   HiLink pythonDocTest		Special
318 330
   HiLink pythonDocTest2		Special