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,6 +31,8 @@
31 31
 "   let python_no_exception_highlight = 1
32 32
 "   let python_no_number_highlight = 1
33 33
 "   let python_space_error_highlight = 1
34
+"   let python_shebang_header_highlight = 1
35
+"   let python_coding_header_highlight = 1
34 36
 "
35 37
 " All the options above can be switched on together.
36 38
 "
@@ -94,9 +96,9 @@ syn match   pythonFunction
94 96
 " Add spelling to comments with some exceptions
95 97
 syn match   pythonComment	"#.*$" contains=pythonTodo,@Spell
96 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 100
 " Skip noqa inline comments
99
-syn match   pythonComment	"# noqa.*$" display contains=@NoSpell
101
+syn match   pythonComment	"# noqa.*$" contains=@NoSpell
100 102
 syn keyword pythonTodo		FIXME NOTE NOTES TODO XXX contained
101 103
 
102 104
 " Triple-quoted strings can contain doctests.
@@ -138,6 +140,8 @@ if exists("python_highlight_all")
138 140
     unlet python_no_number_highlight
139 141
   endif
140 142
   let python_space_error_highlight = 1
143
+  let python_shebang_header_highlight = 1
144
+  let python_coding_header_highlight = 1
141 145
 endif
142 146
 
143 147
 " It is very important to understand all details before changing the
@@ -237,6 +241,14 @@ if exists("python_space_error_highlight")
237 241
   syn match   pythonSpaceError	display "\t\+ "
238 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 252
 " Do not spell doctests inside strings.
241 253
 " Notice that the end of a string, either ''', or """, will end the contained
242 254
 " doctest too.  Thus, we do *not* need to have it as an end pattern.
@@ -276,6 +288,12 @@ if version >= 508 || !exists("did_python_syn_inits")
276 288
   HiLink pythonDecorator	Define
277 289
   HiLink pythonFunction		Function
278 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 297
   HiLink pythonTodo		Todo
280 298
   HiLink pythonString		String
281 299
   HiLink pythonRawString	String