Browse Source

Removed old SVN stuff

Dmitry Vasiliev 15 years ago
commit
3b960bac77
4 changed files with 507 additions and 0 deletions
  1. 84
    0
      CHANGES.txt
  2. 9
    0
      TODO.txt
  3. 307
    0
      python.vim
  4. 107
    0
      test.py

+ 84
- 0
CHANGES.txt View File

@@ -0,0 +1,84 @@
1
+Revision 2.5.6 (2007-02-04):
2
+
3
+    - Applied patch by Pedro Algarvio to enable spell checking only for
4
+      the right spots (strings and comments);
5
+
6
+Revision 2.5.5 (2006-09-26):
7
+
8
+    - added new warnings (ImportWarning, UnicodeWarning)
9
+      introduced in Python 2.5;
10
+
11
+Revision 2.5.4 (2006-05-11):
12
+
13
+    - added highlighting for erroneous operators: &&, ||, ++, --, ===
14
+      (inspired by http://www.vim.org/tips/tip.php?tip_id=969, thanks
15
+      Jeroen Ruigrok van der Werven for the link);
16
+    - added highlighting for new 'with' statement and 'BaseException',
17
+      'GeneratorExit' exceptions introduced in Python 2.5;
18
+    - added highlighting for 'OverflowWarning' exception which had been
19
+      forgotten;
20
+    - returned more robust recognition for function names;
21
+
22
+Revision 2.5.3:
23
+
24
+    - fixed %-formatting highlighting for raw unicode strings;
25
+
26
+Revision 2.5.2:
27
+
28
+    - slightly simplified option handling;
29
+    - fixed regexp for indentation errors;
30
+    - fixed highlighting for backslashed symbols inside strings;
31
+    - added highlighting for trailing-space errors (triggered by new
32
+      option: python_highlight_space_errors);
33
+    - added highlighting for variable name errors;
34
+    - added highlighting for hex number errors;
35
+
36
+Revision 2.5.1 (2005-03-13):
37
+
38
+    - added new builtins 'all' and 'any' (Python 2.5a0)
39
+
40
+Revision 2.4.2 (2004-08-05):
41
+
42
+    - added highlighting for new @decorator syntax introduced in python 2.4a2
43
+
44
+Revision 2.4.1 (2004-03-17):
45
+
46
+    - new versioning scheme (based on python version numbers);
47
+    - added highlighting for new types/builtins introduced in python 2.4
48
+      (set, frozenset, reversed, sorted);
49
+    - new option added: python_slow_sync (set this for slow but more
50
+      robust syntax synchronization);
51
+    - added highlighting for doctests;
52
+
53
+Revision 1.19:
54
+
55
+    - new option added: python_highlight_indent_errors;
56
+    - python_highlight_all now not override previously set options,
57
+      for example code:
58
+          let python_highlight_indent_errors = 0
59
+          let python_highlight_all = 1
60
+      set all highlight options except indentation errors highlighting option;
61
+
62
+Revision 1.17:
63
+
64
+    - changed header, "Based on..." string added;
65
+
66
+Revision 1.16:
67
+
68
+    - added basestring builtin;
69
+
70
+Revision 1.15 (first public revision).
71
+
72
+    The changes since the original (vim6.1) python.vim are:
73
+
74
+    - changed string highlighting;
75
+    - enhanced special symbols highlighting inside strings;
76
+    - enhanced constant numbers highlighting;
77
+    - added optional highlighting for %-formatting inside strings;
78
+    - added highlighting for error conditions (wrong symbols in source file,
79
+      mixing spaces and tabs, wrong number values,
80
+      wrong %-formatting inside strings);
81
+    - added highlighting for magic comments: source code encoding
82
+      and #! (executable) strings;
83
+    - added highlighting for new exceptions and builtins introduced
84
+      in python 2.3;

+ 9
- 0
TODO.txt View File

@@ -0,0 +1,9 @@
1
+- Integer literal support
2
+
3
+- Python 3.0 string formatting
4
+
5
+- Need more accurate way to handle indentation errors. For example
6
+  mixing spaces and tabs may be used for pretty formatting;
7
+
8
+- Need more checks for errors like: absent brackets, absent quotes,
9
+  back slash at the end of strings;

+ 307
- 0
python.vim View File

@@ -0,0 +1,307 @@
1
+" Vim syntax file
2
+" Language:	Python
3
+" Maintainer:	Dmitry Vasiliev <dima@hlabs.spb.ru>
4
+" URL:		http://www.hlabs.spb.ru/vim/python.vim
5
+" Last Change:	$Date$
6
+" Filenames:	*.py
7
+" Version:	2.6.1
8
+" $Rev$
9
+"
10
+" Based on python.vim (from Vim 6.1 distribution)
11
+" by Neil Schemenauer <nas@python.ca>
12
+"
13
+" Thanks:
14
+"
15
+"    Jeroen Ruigrok van der Werven
16
+"        for the idea of highlighting for erroneous operators
17
+"    Pedro Algarvio
18
+"        for the patch to enable spell checking only for the right spots
19
+"        (strings and comments)
20
+"    John Eikenberry
21
+"        for the patch fixing small typo
22
+
23
+"
24
+" Options:
25
+"
26
+"    For set option do: let OPTION_NAME = 1
27
+"    For clear option do: let OPTION_NAME = 0
28
+"
29
+" Option names:
30
+"
31
+"    For highlight builtin functions:
32
+"       python_highlight_builtins
33
+"
34
+"    For highlight standard exceptions:
35
+"       python_highlight_exceptions
36
+"
37
+"    For highlight string formatting:
38
+"       python_highlight_string_formatting
39
+"
40
+"    For highlight indentation errors:
41
+"       python_highlight_indent_errors
42
+"
43
+"    For highlight trailing spaces:
44
+"       python_highlight_space_errors
45
+"
46
+"    For highlight doc-tests:
47
+"       python_highlight_doctests
48
+"
49
+"    If you want all possible Python highlighting:
50
+"    (This option not override previously set options)
51
+"       python_highlight_all
52
+"
53
+"    For fast machines:
54
+"       python_slow_sync
55
+"
56
+
57
+" For version 5.x: Clear all syntax items
58
+" For version 6.x: Quit when a syntax file was already loaded
59
+if version < 600
60
+  syntax clear
61
+elseif exists("b:current_syntax")
62
+  finish
63
+endif
64
+
65
+if exists("python_highlight_all") && python_highlight_all != 0
66
+  " Not override previously set options
67
+  if !exists("python_highlight_builtins")
68
+    let python_highlight_builtins = 1
69
+  endif
70
+  if !exists("python_highlight_exceptions")
71
+    let python_highlight_exceptions = 1
72
+  endif
73
+  if !exists("python_highlight_string_formatting")
74
+    let python_highlight_string_formatting = 1
75
+  endif
76
+  if !exists("python_highlight_indent_errors")
77
+    let python_highlight_indent_errors = 1
78
+  endif
79
+  if !exists("python_highlight_space_errors")
80
+    let python_highlight_space_errors = 1
81
+  endif
82
+  if !exists("python_highlight_doctests")
83
+    let python_highlight_doctests = 1
84
+  endif
85
+endif
86
+
87
+" Keywords
88
+syn keyword pythonStatement	break continue del
89
+syn keyword pythonStatement	exec return
90
+syn keyword pythonStatement	pass raise
91
+syn keyword pythonStatement	global assert
92
+syn keyword pythonStatement	lambda yield
93
+syn keyword pythonStatement	with
94
+syn keyword pythonStatement	def class nextgroup=pythonFunction skipwhite
95
+syn match   pythonFunction	"[a-zA-Z_][a-zA-Z0-9_]*" display contained
96
+syn keyword pythonRepeat	for while
97
+syn keyword pythonConditional	if elif else
98
+syn keyword pythonImport	import from as
99
+syn keyword pythonException	try except finally
100
+syn keyword pythonOperator	and in is not or
101
+
102
+" Decorators (new in Python 2.4)
103
+syn match   pythonDecorator	"@" display nextgroup=pythonFunction skipwhite
104
+
105
+" Comments
106
+syn match   pythonComment	"#.*$" display contains=pythonTodo,@Spell
107
+syn match   pythonRun		"\%^#!.*$"
108
+syn match   pythonCoding	"\%^.*\(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
109
+syn keyword pythonTodo		TODO FIXME XXX contained
110
+
111
+" Errors
112
+syn match pythonError		"\<\d\+\D\+\>" display
113
+syn match pythonError		"[$?]" display
114
+syn match pythonError		"[-+&|]\{2,}" display
115
+syn match pythonError		"[=]\{3,}" display
116
+
117
+" TODO: Mixing spaces and tabs also may be used for pretty formatting multiline
118
+" statements. For now I don't know how to work around this.
119
+if exists("python_highlight_indent_errors") && python_highlight_indent_errors != 0
120
+  syn match pythonIndentError	"^\s*\( \t\|\t \)\s*\S"me=e-1 display
121
+endif
122
+
123
+" Trailing space errors
124
+if exists("python_highlight_space_errors") && python_highlight_space_errors != 0
125
+  syn match pythonSpaceError	"\s\+$" display
126
+endif
127
+
128
+" Strings
129
+syn region pythonString		start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
130
+syn region pythonString		start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonEscapeError,@Spell
131
+syn region pythonString		start=+"""+ end=+"""+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest2,pythonSpaceError,@Spell
132
+syn region pythonString		start=+'''+ end=+'''+ keepend contains=pythonEscape,pythonEscapeError,pythonDocTest,pythonSpaceError,@Spell
133
+
134
+syn match  pythonEscape		+\\[abfnrtv'"\\]+ display contained
135
+syn match  pythonEscape		"\\\o\o\=\o\=" display contained
136
+syn match  pythonEscapeError	"\\\o\{,2}[89]" display contained
137
+syn match  pythonEscape		"\\x\x\{2}" display contained
138
+syn match  pythonEscapeError	"\\x\x\=\X" display contained
139
+syn match  pythonEscape		"\\$"
140
+
141
+" Unicode strings
142
+syn region pythonUniString	start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
143
+syn region pythonUniString	start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,@Spell
144
+syn region pythonUniString	start=+[uU]"""+ end=+"""+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
145
+syn region pythonUniString	start=+[uU]'''+ end=+'''+ keepend contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
146
+
147
+syn match  pythonUniEscape	"\\u\x\{4}" display contained
148
+syn match  pythonUniEscapeError	"\\u\x\{,3}\X" display contained
149
+syn match  pythonUniEscape	"\\U\x\{8}" display contained
150
+syn match  pythonUniEscapeError	"\\U\x\{,7}\X" display contained
151
+syn match  pythonUniEscape	"\\N{[A-Z ]\+}" display contained
152
+syn match  pythonUniEscapeError	"\\N{[^A-Z ]\+}" display contained
153
+
154
+" Raw strings
155
+syn region pythonRawString	start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell
156
+syn region pythonRawString	start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell
157
+syn region pythonRawString	start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell
158
+syn region pythonRawString	start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell
159
+
160
+syn match pythonRawEscape	+\\['"]+ display transparent contained
161
+
162
+" Unicode raw strings
163
+syn region pythonUniRawString	start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
164
+syn region pythonUniRawString	start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell
165
+syn region pythonUniRawString	start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell
166
+syn region pythonUniRawString	start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell
167
+
168
+syn match  pythonUniRawEscape		"\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained
169
+syn match  pythonUniRawEscapeError	"\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained
170
+
171
+if exists("python_highlight_string_formatting") && python_highlight_string_formatting != 0
172
+  " String formatting
173
+  syn match pythonStrFormat	"%\(([^)]\+)\)\=[-#0 +]*\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
174
+  syn match pythonStrFormat	"%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
175
+endif
176
+
177
+if exists("python_highlight_doctests") && python_highlight_doctests != 0
178
+  " DocTests
179
+  syn region pythonDocTest	start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
180
+  syn region pythonDocTest2	start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained
181
+endif
182
+
183
+" Numbers (ints, longs, floats, complex)
184
+syn match   pythonHexNumber	"\<0[xX]\x\+[lL]\=\>" display
185
+syn match   pythonHexNumber	"\<0[xX]\>" display
186
+syn match   pythonNumber	"\<\d\+[lLjJ]\=\>" display
187
+syn match   pythonFloat		"\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display
188
+syn match   pythonFloat		"\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display
189
+syn match   pythonFloat		"\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display
190
+
191
+syn match   pythonOctalError	"\<0\o*[89]\d*[lL]\=\>" display
192
+syn match   pythonHexError	"\<0[xX]\X\+[lL]\=\>" display
193
+
194
+if exists("python_highlight_builtins") && python_highlight_builtins != 0
195
+  " Builtin functions, types and objects
196
+  syn keyword pythonBuiltinObj	True False Ellipsis None NotImplemented __debug__
197
+
198
+  syn keyword pythonBuiltinFunc	__import__ abs all any apply
199
+  syn keyword pythonBuiltinFunc	basestring bool buffer callable
200
+  syn keyword pythonBuiltinFunc	chr classmethod cmp coerce compile complex
201
+  syn keyword pythonBuiltinFunc	delattr dict dir divmod enumerate eval
202
+  syn keyword pythonBuiltinFunc	execfile file filter float frozenset getattr
203
+  syn keyword pythonBuiltinFunc	globals hasattr hash help hex id 
204
+  syn keyword pythonBuiltinFunc	input int intern isinstance
205
+  syn keyword pythonBuiltinFunc	issubclass iter len list locals long map max
206
+  syn keyword pythonBuiltinFunc	min next object oct open ord
207
+  syn keyword pythonBuiltinFunc	pow print property range
208
+  syn keyword pythonBuiltinFunc	raw_input reduce reload repr
209
+  syn keyword pythonBuiltinFunc	reversed round set setattr
210
+  syn keyword pythonBuiltinFunc	slice sorted staticmethod str sum super tuple
211
+  syn keyword pythonBuiltinFunc	type unichr unicode vars xrange zip
212
+endif
213
+
214
+if exists("python_highlight_exceptions") && python_highlight_exceptions != 0
215
+  " Builtin exceptions and warnings
216
+  syn keyword pythonExClass	BaseException
217
+  syn keyword pythonExClass	Exception StandardError ArithmeticError
218
+  syn keyword pythonExClass	LookupError EnvironmentError
219
+
220
+  syn keyword pythonExClass	AssertionError AttributeError EOFError
221
+  syn keyword pythonExClass	FloatingPointError GeneratorExit IOError
222
+  syn keyword pythonExClass	ImportError IndexError KeyError
223
+  syn keyword pythonExClass	KeyboardInterrupt MemoryError NameError
224
+  syn keyword pythonExClass	NotImplementedError OSError OverflowError
225
+  syn keyword pythonExClass	ReferenceError RuntimeError StopIteration
226
+  syn keyword pythonExClass	SyntaxError IndentationError TabError
227
+  syn keyword pythonExClass	SystemError SystemExit TypeError
228
+  syn keyword pythonExClass	UnboundLocalError UnicodeError
229
+  syn keyword pythonExClass	UnicodeEncodeError UnicodeDecodeError
230
+  syn keyword pythonExClass	UnicodeTranslateError ValueError
231
+  syn keyword pythonExClass	WindowsError ZeroDivisionError
232
+
233
+  syn keyword pythonExClass	Warning UserWarning DeprecationWarning
234
+  syn keyword pythonExClass	PendingDepricationWarning SyntaxWarning
235
+  syn keyword pythonExClass	RuntimeWarning FutureWarning
236
+  syn keyword pythonExClass	ImportWarning UnicodeWarning
237
+endif
238
+
239
+if exists("python_slow_sync") && python_slow_sync != 0
240
+  syn sync minlines=2000
241
+else
242
+  " This is fast but code inside triple quoted strings screws it up. It
243
+  " is impossible to fix because the only way to know if you are inside a
244
+  " triple quoted string is to start from the beginning of the file.
245
+  syn sync match pythonSync grouphere NONE "):$"
246
+  syn sync maxlines=200
247
+endif
248
+
249
+if version >= 508 || !exists("did_python_syn_inits")
250
+  if version <= 508
251
+    let did_python_syn_inits = 1
252
+    command -nargs=+ HiLink hi link <args>
253
+  else
254
+    command -nargs=+ HiLink hi def link <args>
255
+  endif
256
+
257
+  HiLink pythonStatement	Statement
258
+  HiLink pythonImport		Statement
259
+  HiLink pythonFunction		Function
260
+  HiLink pythonConditional	Conditional
261
+  HiLink pythonRepeat		Repeat
262
+  HiLink pythonException	Exception
263
+  HiLink pythonOperator		Operator
264
+
265
+  HiLink pythonDecorator	Define
266
+
267
+  HiLink pythonComment		Comment
268
+  HiLink pythonCoding		Special
269
+  HiLink pythonRun		Special
270
+  HiLink pythonTodo		Todo
271
+
272
+  HiLink pythonError		Error
273
+  HiLink pythonIndentError	Error
274
+  HiLink pythonSpaceError	Error
275
+
276
+  HiLink pythonString		String
277
+  HiLink pythonUniString	String
278
+  HiLink pythonRawString	String
279
+  HiLink pythonUniRawString	String
280
+
281
+  HiLink pythonEscape			Special
282
+  HiLink pythonEscapeError		Error
283
+  HiLink pythonUniEscape		Special
284
+  HiLink pythonUniEscapeError		Error
285
+  HiLink pythonUniRawEscape		Special
286
+  HiLink pythonUniRawEscapeError	Error
287
+
288
+  HiLink pythonStrFormat	Special
289
+
290
+  HiLink pythonDocTest		Special
291
+  HiLink pythonDocTest2		Special
292
+
293
+  HiLink pythonNumber		Number
294
+  HiLink pythonHexNumber	Number
295
+  HiLink pythonFloat		Float
296
+  HiLink pythonOctalError	Error
297
+  HiLink pythonHexError		Error
298
+
299
+  HiLink pythonBuiltinObj	Structure
300
+  HiLink pythonBuiltinFunc	Function
301
+
302
+  HiLink pythonExClass	Structure
303
+
304
+  delcommand HiLink
305
+endif
306
+
307
+let b:current_syntax = "python"

+ 107
- 0
test.py View File

@@ -0,0 +1,107 @@
1
+#! /usr/bin/env python
2
+# -*- coding: utf-8 -*-
3
+# Above the run-comment and file encoding comment.
4
+
5
+# Comments.
6
+
7
+# TODO FIXME XXX
8
+
9
+# Keywords.
10
+
11
+with break continue del exec return pass print raise global assert lambda yield
12
+for while if elif else import from as try except finally and in is not or
13
+def functionname
14
+class classname
15
+
16
+# Builtin objects.
17
+
18
+True False Ellipsis None NotImplemented
19
+
20
+# Builtin function and types.
21
+
22
+__import__ abs all any apply basestring bool buffer callable chr classmethod
23
+cmp coerce compile complex delattr dict dir divmod enumerate eval execfile file
24
+filter float frozenset getattr globals hasattr hash help hex id input int
25
+intern isinstance issubclass iter len list locals long map max min object oct
26
+open ord pow property range raw_input reduce reload repr reversed round set
27
+setattr slice sorted staticmethod str sum super tuple type unichr unicode vars
28
+xrange zip
29
+
30
+# Builtin exceptions and warnings.
31
+
32
+BaseException Exception StandardError ArithmeticError LookupError
33
+EnvironmentError
34
+
35
+AssertionError AttributeError EOFError FloatingPointError GeneratorExit IOError
36
+ImportError IndexError KeyError KeyboardInterrupt MemoryError NameError
37
+NotImplementedError OSError OverflowError ReferenceError RuntimeError
38
+StopIteration SyntaxError IndentationError TabError SystemError SystemExit
39
+TypeError UnboundLocalError UnicodeError UnicodeEncodeError UnicodeDecodeError
40
+UnicodeTranslateError ValueError WindowsError ZeroDivisionError
41
+
42
+Warning UserWarning DeprecationWarning PendingDepricationWarning SyntaxWarning
43
+RuntimeWarning FutureWarning OverflowWarning ImportWarning UnicodeWarning
44
+
45
+# Decorators.
46
+
47
+@ decoratorname
48
+
49
+# Numbers
50
+
51
+0 0x 0x1f 077 .3 12.34 100L 0j 0j 34.2E-3
52
+
53
+# Erroneous numbers
54
+
55
+08 0xk
56
+
57
+# Strings
58
+
59
+" test " ' test '
60
+"""
61
+  test
62
+"""
63
+'''
64
+  test
65
+'''
66
+
67
+" \a\b\c\"\'\n\r \x34\077 \08 \xag"
68
+r" \" \' "
69
+
70
+# Doctests.
71
+
72
+"""
73
+    Test:
74
+    >>> a = 5
75
+    >>> a
76
+    5
77
+
78
+    Test
79
+"""
80
+
81
+'''
82
+    Test:
83
+    >>> a = 5
84
+    >>> a
85
+    5
86
+
87
+    Test
88
+'''
89
+
90
+# Erroneous symbols or bad variable names.
91
+
92
+$ ? 6xav
93
+
94
+&& || ++ -- ===
95
+
96
+# Indentation errors.
97
+
98
+    	    break
99
+
100
+# Trailing space errors.
101
+
102
+    	
103
+    break	    
104
+"""  	
105
+   	 
106
+    test    	
107
+"""