Browse Source

Fixed highlighting for bytes and numbers

Dmitry Vasiliev 8 years ago
parent
commit
9f7d4af442
3 changed files with 21 additions and 13 deletions
  1. 5
    0
      CHANGES.txt
  2. 12
    11
      python3.0.vim
  3. 4
    2
      test.py

+ 5
- 0
CHANGES.txt View File

@@ -1,3 +1,8 @@
1
+Revision 3.0.5 (2010-11-11):
2
+
3
+    - Fixed highlighting for bytes. Patch by Anton Butanaev.
4
+    - Fixed highlighting for numbers.
5
+
1 6
 Revision 3.0.4 (2010-11-09):
2 7
 
3 8
     - Fixed highlighting for raw bytes literals. Patch by Anton Butanaev.

+ 12
- 11
python3.0.vim View File

@@ -2,9 +2,9 @@
2 2
 " Language:	Python
3 3
 " Maintainer:	Dmitry Vasiliev <dima@hlabs.spb.ru>
4 4
 " URL:		http://www.hlabs.spb.ru/vim/python3.0.vim
5
-" Last Change:	2010-11-09
5
+" Last Change:	2010-11-11
6 6
 " Filenames:	*.py
7
-" Version:	3.0.4
7
+" Version:	3.0.5
8 8
 "
9 9
 " Based on python.vim (from Vim 6.1 distribution)
10 10
 " by Neil Schemenauer <nas@python.ca>
@@ -23,7 +23,7 @@
23 23
 "    Andrea Riciputi
24 24
 "        for the patch with new configuration options
25 25
 "    Anton Butanaev
26
-"        for the patch fixing raw bytes literals highlighting
26
+"        for the patch fixing bytes literals highlighting
27 27
 
28 28
 "
29 29
 " Options:
@@ -139,7 +139,7 @@ syn match   pythonCoding	"\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
139 139
 syn keyword pythonTodo		TODO FIXME XXX contained
140 140
 
141 141
 " Errors
142
-" syn match pythonError		"\<\d\+\D\+\>" display
142
+syn match pythonError		"\<\d\+\D\+\>" display
143 143
 syn match pythonError		"[$?]" display
144 144
 syn match pythonError		"[&|]\{2,}" display
145 145
 syn match pythonError		"[=]\{3,}" display
@@ -183,13 +183,13 @@ syn region pythonRawString	start=+[bB]\=[rR]'''+ end=+'''+ keepend contains=pyth
183 183
 syn match pythonRawEscape	+\\['"]+ display transparent contained
184 184
 
185 185
 " Bytes
186
-syn region pythonBytes		start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesContent,pythonBytesError,pythonBytesEscape,pythonBytesEscapeError,@Spell
187
-syn region pythonBytes		start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesContent,pythonBytesError,pythonBytesEscape,pythonBytesEscapeError,@Spell
188
-syn region pythonBytes		start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesContent,pythonBytesError,pythonBytesEscape,pythonBytesEscapeError,pythonDocTest2,pythonSpaceError,@Spell
189
-syn region pythonBytes		start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesContent,pythonBytesError,pythonBytesEscape,pythonBytesEscapeError,pythonDocTest,pythonSpaceError,@Spell
186
+syn region pythonBytes		start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell
187
+syn region pythonBytes		start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell
188
+syn region pythonBytes		start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell
189
+syn region pythonBytes		start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell
190 190
 
191
-syn match pythonBytesContent    "[\u0001-\u007f]\+" display contained
192
-syn match pythonBytesError    "[^\u0001-\u007f]\+" display contained
191
+syn match pythonBytesError    ".\+" display contained
192
+syn match pythonBytesContent    "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError
193 193
 
194 194
 syn match pythonBytesEscape	    +\\[abfnrtv'"\\]+ display contained
195 195
 syn match pythonBytesEscape	    "\\\o\o\=\o\=" display contained
@@ -230,10 +230,11 @@ syn match   pythonHexNumber	"\<0[xX]\x\+\>" display
230 230
 syn match   pythonOctNumber "\<0[oO]\o\+\>" display
231 231
 syn match   pythonBinNumber "\<0[bB][01]\+\>" display
232 232
 
233
+syn match   pythonNumberError	"\<\d\+\D\>" display
234
+syn match   pythonNumberError	"\<0\d\+\>" display
233 235
 syn match   pythonNumber	"\<\d\>" display
234 236
 syn match   pythonNumber	"\<[1-9]\d\+\>" display
235 237
 syn match   pythonNumber	"\<\d\+[jJ]\>" display
236
-syn match   pythonNumberError	"\<0\d\+\>" display
237 238
 
238 239
 syn match   pythonFloat		"\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display
239 240
 syn match   pythonFloat		"\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display

+ 4
- 2
test.py View File

@@ -51,7 +51,7 @@ RuntimeWarning FutureWarning OverflowWarning ImportWarning UnicodeWarning
51 51
 
52 52
 # Numbers
53 53
 
54
-0 1 2 9 10 0x1f .3 12.34 0j 0j 34.2E-3 0b10 0o77
54
+0 1 2 9 10 0x1f .3 12.34 0j 0j 34.2E-3 0b10 0o77 1023434 0x0
55 55
 
56 56
 # Erroneous numbers
57 57
 
@@ -74,11 +74,13 @@ r" \" \' "
74 74
 
75 75
 b"test"
76 76
 
77
+b"test\r\n\xffff"
78
+
77 79
 b"тестtest"
78 80
 
79 81
 br"test"
80 82
 
81
-br"\a\b"
83
+br"\a\b\n\r"
82 84
 
83 85
 # Formattings
84 86