Browse Source

Add new option 'python_highlight_file_headers_as_comments'

The option is disabled by default and when enabled highlight shebang and
coding file headers as comments instead of special characters.
Dmitry Vasiliev 11 years ago
parent
commit
69f8e12a46
3 changed files with 16 additions and 4 deletions
  1. 3
    0
      CHANGES.txt
  2. 2
    0
      README.rst
  3. 11
    4
      syntax/python.vim

+ 3
- 0
CHANGES.txt View File

2
 
2
 
3
     - Highlight 'import', 'from' and 'as' as include statements.
3
     - Highlight 'import', 'from' and 'as' as include statements.
4
       Patch by pydave at GitHub.
4
       Patch by pydave at GitHub.
5
+    - Added new option 'python_highlight_file_headers_as_comments' (disabled by
6
+      default) to highlight shebang and coding file headers as comments.
7
+      Proposed by pydave at GitHub.
5
 
8
 
6
 Revision 3.3.4 (2013-08-11):
9
 Revision 3.3.4 (2013-08-11):
7
 
10
 

+ 2
- 0
README.rst View File

117
   Highlight doc-tests
117
   Highlight doc-tests
118
 ``python_print_as_function``
118
 ``python_print_as_function``
119
   Highlight ``print`` statement as function for Python 2
119
   Highlight ``print`` statement as function for Python 2
120
+``python_highlight_file_headers_as_comments``
121
+  Highlight shebang and coding headers as comments
120
 ``python_highlight_all``
122
 ``python_highlight_all``
121
   Enable all the options above. *NOTE: This option don't override any
123
   Enable all the options above. *NOTE: This option don't override any
122
   previously set options*
124
   previously set options*

+ 11
- 4
syntax/python.vim View File

73
 "    python_highlight_doctests              Highlight doc-tests
73
 "    python_highlight_doctests              Highlight doc-tests
74
 "    python_print_as_function               Highlight 'print' statement as
74
 "    python_print_as_function               Highlight 'print' statement as
75
 "                                           function for Python 2
75
 "                                           function for Python 2
76
+"    python_highlight_file_headers_as_comments
77
+"                                           Highlight shebang and coding
78
+"                                           headers as comments
76
 "
79
 "
77
 "    python_highlight_all                   Enable all the options above
80
 "    python_highlight_all                   Enable all the options above
78
 "                                           NOTE: This option don't override
81
 "                                           NOTE: This option don't override
179
 "
182
 "
180
 
183
 
181
 syn match   pythonComment	"#.*$" display contains=pythonTodo,@Spell
184
 syn match   pythonComment	"#.*$" display contains=pythonTodo,@Spell
182
-syn match   pythonRun		"\%^#!.*$"
183
-syn match   pythonCoding	"\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
185
+if !s:Enabled("g:python_highlight_file_headers_as_comments")
186
+  syn match   pythonRun		"\%^#!.*$"
187
+  syn match   pythonCoding	"\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$"
188
+endif
184
 syn keyword pythonTodo		TODO FIXME XXX contained
189
 syn keyword pythonTodo		TODO FIXME XXX contained
185
 
190
 
186
 "
191
 "
482
   HiLink pythonDot              Normal
487
   HiLink pythonDot              Normal
483
 
488
 
484
   HiLink pythonComment          Comment
489
   HiLink pythonComment          Comment
485
-  HiLink pythonCoding           Special
486
-  HiLink pythonRun              Special
490
+  if !s:Enabled("g:python_highlight_file_headers_as_comments")
491
+    HiLink pythonCoding           Special
492
+    HiLink pythonRun              Special
493
+  endif
487
   HiLink pythonTodo             Todo
494
   HiLink pythonTodo             Todo
488
 
495
 
489
   HiLink pythonError            Error
496
   HiLink pythonError            Error