Browse Source

Fixed highlighting for bytes and numbers

Dmitry Vasiliev 14 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
+Revision 3.0.5 (2010-11-11):
2
+
3
+    - Fixed highlighting for bytes. Patch by Anton Butanaev.
4
+    - Fixed highlighting for numbers.
5
+
1
 Revision 3.0.4 (2010-11-09):
6
 Revision 3.0.4 (2010-11-09):
2
 
7
 
3
     - Fixed highlighting for raw bytes literals. Patch by Anton Butanaev.
8
     - Fixed highlighting for raw bytes literals. Patch by Anton Butanaev.

+ 12
- 11
python3.0.vim View File

2
 " Language:	Python
2
 " Language:	Python
3
 " Maintainer:	Dmitry Vasiliev <dima@hlabs.spb.ru>
3
 " Maintainer:	Dmitry Vasiliev <dima@hlabs.spb.ru>
4
 " URL:		http://www.hlabs.spb.ru/vim/python3.0.vim
4
 " URL:		http://www.hlabs.spb.ru/vim/python3.0.vim
5
-" Last Change:	2010-11-09
5
+" Last Change:	2010-11-11
6
 " Filenames:	*.py
6
 " Filenames:	*.py
7
-" Version:	3.0.4
7
+" Version:	3.0.5
8
 "
8
 "
9
 " Based on python.vim (from Vim 6.1 distribution)
9
 " Based on python.vim (from Vim 6.1 distribution)
10
 " by Neil Schemenauer <nas@python.ca>
10
 " by Neil Schemenauer <nas@python.ca>
23
 "    Andrea Riciputi
23
 "    Andrea Riciputi
24
 "        for the patch with new configuration options
24
 "        for the patch with new configuration options
25
 "    Anton Butanaev
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
 " Options:
29
 " Options:
139
 syn keyword pythonTodo		TODO FIXME XXX contained
139
 syn keyword pythonTodo		TODO FIXME XXX contained
140
 
140
 
141
 " Errors
141
 " Errors
142
-" syn match pythonError		"\<\d\+\D\+\>" display
142
+syn match pythonError		"\<\d\+\D\+\>" display
143
 syn match pythonError		"[$?]" display
143
 syn match pythonError		"[$?]" display
144
 syn match pythonError		"[&|]\{2,}" display
144
 syn match pythonError		"[&|]\{2,}" display
145
 syn match pythonError		"[=]\{3,}" display
145
 syn match pythonError		"[=]\{3,}" display
183
 syn match pythonRawEscape	+\\['"]+ display transparent contained
183
 syn match pythonRawEscape	+\\['"]+ display transparent contained
184
 
184
 
185
 " Bytes
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
 syn match pythonBytesEscape	    +\\[abfnrtv'"\\]+ display contained
194
 syn match pythonBytesEscape	    +\\[abfnrtv'"\\]+ display contained
195
 syn match pythonBytesEscape	    "\\\o\o\=\o\=" display contained
195
 syn match pythonBytesEscape	    "\\\o\o\=\o\=" display contained
230
 syn match   pythonOctNumber "\<0[oO]\o\+\>" display
230
 syn match   pythonOctNumber "\<0[oO]\o\+\>" display
231
 syn match   pythonBinNumber "\<0[bB][01]\+\>" display
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
 syn match   pythonNumber	"\<\d\>" display
235
 syn match   pythonNumber	"\<\d\>" display
234
 syn match   pythonNumber	"\<[1-9]\d\+\>" display
236
 syn match   pythonNumber	"\<[1-9]\d\+\>" display
235
 syn match   pythonNumber	"\<\d\+[jJ]\>" display
237
 syn match   pythonNumber	"\<\d\+[jJ]\>" display
236
-syn match   pythonNumberError	"\<0\d\+\>" display
237
 
238
 
238
 syn match   pythonFloat		"\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display
239
 syn match   pythonFloat		"\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display
239
 syn match   pythonFloat		"\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
240
 syn match   pythonFloat		"\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display

+ 4
- 2
test.py View File

51
 
51
 
52
 # Numbers
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
 # Erroneous numbers
56
 # Erroneous numbers
57
 
57
 
74
 
74
 
75
 b"test"
75
 b"test"
76
 
76
 
77
+b"test\r\n\xffff"
78
+
77
 b"тестtest"
79
 b"тестtest"
78
 
80
 
79
 br"test"
81
 br"test"
80
 
82
 
81
-br"\a\b"
83
+br"\a\b\n\r"
82
 
84
 
83
 # Formattings
85
 # Formattings
84
 
86