Browse Source

Allow the shebang and coding headers to be highlighted as special

Pedro Algarvio 9 years ago
parent
commit
d8a637209b
1 changed files with 20 additions and 2 deletions
  1. 20
    2
      syntax/python.vim

+ 20
- 2
syntax/python.vim View File

31
 "   let python_no_exception_highlight = 1
31
 "   let python_no_exception_highlight = 1
32
 "   let python_no_number_highlight = 1
32
 "   let python_no_number_highlight = 1
33
 "   let python_space_error_highlight = 1
33
 "   let python_space_error_highlight = 1
34
+"   let python_shebang_header_highlight = 1
35
+"   let python_coding_header_highlight = 1
34
 "
36
 "
35
 " All the options above can be switched on together.
37
 " All the options above can be switched on together.
36
 "
38
 "
94
 " Add spelling to comments with some exceptions
96
 " Add spelling to comments with some exceptions
95
 syn match   pythonComment	"#.*$" contains=pythonTodo,@Spell
97
 syn match   pythonComment	"#.*$" contains=pythonTodo,@Spell
96
 " Skip for PyLint's in-line comment rules
98
 " Skip for PyLint's in-line comment rules
97
-syn match   pythonComment	"# pylint:.*$" display contains=@NoSpell
99
+syn match   pythonComment	"# pylint:.*$" contains=@NoSpell
98
 " Skip noqa inline comments
100
 " Skip noqa inline comments
99
-syn match   pythonComment	"# noqa.*$" display contains=@NoSpell
101
+syn match   pythonComment	"# noqa.*$" contains=@NoSpell
100
 syn keyword pythonTodo		FIXME NOTE NOTES TODO XXX contained
102
 syn keyword pythonTodo		FIXME NOTE NOTES TODO XXX contained
101
 
103
 
102
 " Triple-quoted strings can contain doctests.
104
 " Triple-quoted strings can contain doctests.
138
     unlet python_no_number_highlight
140
     unlet python_no_number_highlight
139
   endif
141
   endif
140
   let python_space_error_highlight = 1
142
   let python_space_error_highlight = 1
143
+  let python_shebang_header_highlight = 1
144
+  let python_coding_header_highlight = 1
141
 endif
145
 endif
142
 
146
 
143
 " It is very important to understand all details before changing the
147
 " It is very important to understand all details before changing the
237
   syn match   pythonSpaceError	display "\t\+ "
241
   syn match   pythonSpaceError	display "\t\+ "
238
 endif
242
 endif
239
 
243
 
244
+if exists("python_shebang_header_highlight")
245
+  syn match pythonRun "\%^#!.*$" contains=@NoSpell
246
+endif
247
+
248
+if exists("python_coding_header_highlight")
249
+  syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" contains=@NoSpell
250
+endif
251
+
240
 " Do not spell doctests inside strings.
252
 " Do not spell doctests inside strings.
241
 " Notice that the end of a string, either ''', or """, will end the contained
253
 " Notice that the end of a string, either ''', or """, will end the contained
242
 " doctest too.  Thus, we do *not* need to have it as an end pattern.
254
 " doctest too.  Thus, we do *not* need to have it as an end pattern.
276
   HiLink pythonDecorator	Define
288
   HiLink pythonDecorator	Define
277
   HiLink pythonFunction		Function
289
   HiLink pythonFunction		Function
278
   HiLink pythonComment		Comment
290
   HiLink pythonComment		Comment
291
+  if exists("python_shebang_header_highlight")
292
+    HiLink pythonRun		Special
293
+  endif
294
+  if exists("python_coding_header_highlight")
295
+    HiLink pythonCoding		Special
296
+  endif
279
   HiLink pythonTodo		Todo
297
   HiLink pythonTodo		Todo
280
   HiLink pythonString		String
298
   HiLink pythonString		String
281
   HiLink pythonRawString	String
299
   HiLink pythonRawString	String