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 5 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,6 +2,9 @@ Revision 3.3.5 (2013-08-31):
2 2
 
3 3
     - Highlight 'import', 'from' and 'as' as include statements.
4 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 9
 Revision 3.3.4 (2013-08-11):
7 10
 

+ 2
- 0
README.rst View File

@@ -117,6 +117,8 @@ Options used by the script
117 117
   Highlight doc-tests
118 118
 ``python_print_as_function``
119 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 122
 ``python_highlight_all``
121 123
   Enable all the options above. *NOTE: This option don't override any
122 124
   previously set options*

+ 11
- 4
syntax/python.vim View File

@@ -73,6 +73,9 @@
73 73
 "    python_highlight_doctests              Highlight doc-tests
74 74
 "    python_print_as_function               Highlight 'print' statement as
75 75
 "                                           function for Python 2
76
+"    python_highlight_file_headers_as_comments
77
+"                                           Highlight shebang and coding
78
+"                                           headers as comments
76 79
 "
77 80
 "    python_highlight_all                   Enable all the options above
78 81
 "                                           NOTE: This option don't override
@@ -179,8 +182,10 @@ syn match   pythonDot        "\." display containedin=pythonDottedName
179 182
 "
180 183
 
181 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 189
 syn keyword pythonTodo		TODO FIXME XXX contained
185 190
 
186 191
 "
@@ -482,8 +487,10 @@ if version >= 508 || !exists("did_python_syn_inits")
482 487
   HiLink pythonDot              Normal
483 488
 
484 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 494
   HiLink pythonTodo             Todo
488 495
 
489 496
   HiLink pythonError            Error