diff --git a/CHANGES.txt b/CHANGES.txt index e0579bf..2d3b520 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,19 @@ +Revision 3.6.0 (2015-11-XX): + + - Fix 'async def' highlighting. Patch by Joongi Kim + - Add dummy 'pythonInclude' group to avoid crashing standard pyrex.vim. + Patch by Antony Lee + +Revision 3.5.0 (2015-06-10): + + - Add support for 'async ...' and 'await' keywords introduced in + Python 3.5. Patch by Ihor Gorobets + +Revision 3.3.7 (2014-12-27): + + - Add support for Python 3 non-ASCII decorator names. + Patch by Victor Salgado + Revision 3.3.6 (2013-11-18): - Highlight 'yield from' statement introduced in Python 3.3. Reported by @@ -6,10 +22,10 @@ Revision 3.3.6 (2013-11-18): Revision 3.3.5 (2013-08-31): - Highlight 'import', 'from' and 'as' as include statements. - Patch by pydave at GitHub. + Patch by David Briscoe - Added new option 'python_highlight_file_headers_as_comments' (disabled by default) to highlight shebang and coding file headers as comments. - Proposed by pydave at GitHub. + Proposed by David Briscoe. Revision 3.3.4 (2013-08-11): diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..348583e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2002-2014 Dmitry Vasiliev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.rst b/README.rst index 8293b60..f9cd20d 100644 --- a/README.rst +++ b/README.rst @@ -81,7 +81,7 @@ Option and commands to select Python version ``python_version_2`` Enable highlighting for Python 2 (Python 3 highlighting is enabled by - default). Can also be set as a local to buffer ``b:python_version_2`` + default). Also can be set as a local to buffer ``b:python_version_2`` variable. The following local to buffer commands can be used to switch between two @@ -130,14 +130,18 @@ Contributors List of the contributors in alphabetical order: -- Andrea Riciputi +- `Andrea Riciputi `_ - Anton Butanaev +- `Antony Lee `_ - Caleb Adamantine -- Elizabeth Myers -- Jeroen Ruigrok van der Werven -- John Eikenberry -- Marc Weber -- Pedro Algarvio -- pydave at GitHub -- Will Gray -- Yuri Habrusiev +- `David Briscoe `_ +- `Elizabeth Myers `_ +- `Ihor Gorobets `_ +- `Jeroen Ruigrok van der Werven `_ +- `John Eikenberry `_ +- `Joongi Kim `_ +- `Marc Weber `_ +- `Pedro Algarvio `_ +- `Victor Salgado `_ +- `Will Gray `_ +- `Yuri Habrusiev `_ diff --git a/TODO.txt b/TODO.txt index f562bfb..605c45a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,7 +2,8 @@ Now === - It seems python.vim doesn't highlight special characters inside strings by - default but only when it reloaded? + default but only when reloaded? Or maybe only when set to Python 2 + by default? - Add support for slice syntax: http://img155.imageshack.us/img155/7767/screenshotgs.png diff --git a/syntax.txt b/syntax.txt new file mode 100644 index 0000000..294b11a --- /dev/null +++ b/syntax.txt @@ -0,0 +1,65 @@ +PYTHON *python.vim* *ft-python-syntax* + +There are two commands to enable or disable an option for python.vim + + Enable option: > + :let option_name = 1 +< + Disable option: > + :let option_name = 0 +< +For example to enable all syntax highlighting features you can place the +following command in your `~/.vimrc` script: > + + let python_highlight_all = 1 +< +Option and commands to select Python version: > + + :let python_version_2 = 1 +< + Enable highlighting for Python 2 (Python 3 highlighting is enabled by + default). Also can be set as a local to buffer `b:python_version_2` + variable. + +The following local to buffer commands can be used to switch between two +highlighting modes: + + Switch to Python 2 highlighting mode > + :Python2Syntax +< + Switch to Python 3 highlighting mode > + :Python3Syntax +< +Options used by the script + + Highlight builtin functions and objects > + :let python_highlight_builtins = 1 +< Highlight builtin objects only > + :let python_highlight_builtin_objs = 1 +< Highlight builtin functions only > + :let python_highlight_builtin_funcs = 1 +< Highlight standard exceptions > + :let python_highlight_exceptions = 1 +< Highlight `%` string formatting > + :let python_highlight_string_formatting = 1 +< Highlight syntax of `str.format` syntax > + :let python_highlight_string_format = 1 +< Highlight syntax of `string.Template` > + :let python_highlight_string_templates = 1 +< Highlight indentation errors > + :let python_highlight_indent_errors = 1 +< Highlight trailing spaces > + :let python_highlight_space_errors = 1 +< Highlight doc-tests > + :let python_highlight_doctests = 1 +< Highlight `print` statement as function for Python 2 > + :let python_print_as_function = 1 +< Highlight shebang and coding headers as comments > + :let python_highlight_file_headers_as_comments = 1 +< Enable all the options above. NOTE: This option don't override any + previously set options > + :let python_highlight_all = 1 +< Can be set to 0 for slow machines > + :let python_slow_sync = 1 +< + vim:tw=78:sw=4:ts=8:ft=help:norl: diff --git a/syntax/python.vim b/syntax/python.vim index 8e25a7f..e963628 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -1,10 +1,11 @@ " Vim syntax file -" Language: Python -" Maintainer: Dmitry Vasiliev -" URL: https://github.com/hdima/python-syntax -" Last Change: 2013-11-18 -" Filenames: *.py -" Version: 3.3.6 +" Language: Python +" Current Maintainer: Dmitry Vasiliev +" Previous Maintainer: Neil Schemenauer +" URL: https://github.com/hdima/python-syntax +" Last Change: 2015-11-01 +" Filenames: *.py +" Version: 3.6.0 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -24,13 +25,17 @@ " " Andrea Riciputi " Anton Butanaev +" Antony Lee " Caleb Adamantine +" David Briscoe " Elizabeth Myers +" Ihor Gorobets " Jeroen Ruigrok van der Werven " John Eikenberry +" Joongi Kim " Marc Weber " Pedro Algarvio -" pydave at GitHub +" Victor Salgado " Will Gray " Yuri Habrusiev " @@ -154,6 +159,9 @@ syn keyword pythonStatement with syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite syn keyword pythonRepeat for while syn keyword pythonConditional if elif else +" The standard pyrex.vim unconditionally removes the pythonInclude group, so +" we provide a dummy group here to avoid crashing pyrex.vim. +syn keyword pythonInclude import syn keyword pythonImport import syn keyword pythonException try except finally syn keyword pythonOperator and in is not or @@ -172,6 +180,10 @@ else syn match pythonStatement "\" display syn keyword pythonBoolean True False syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained + syn keyword pythonStatement await + syn match pythonStatement "\" nextgroup=pythonFunction skipwhite + syn match pythonStatement "\" display + syn match pythonStatement "\" display endif " @@ -179,7 +191,11 @@ endif " syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite -syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained +if s:Python2Syntax() + syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained +else + syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained +endif syn match pythonDot "\." display containedin=pythonDottedName " diff --git a/test.py b/test.py index 0ee30a2..df81a9a 100644 --- a/test.py +++ b/test.py @@ -18,6 +18,11 @@ class Classname def функция class Класс +await +async def Test +async with +async for + # Builtin objects. True False Ellipsis None NotImplemented @@ -51,6 +56,8 @@ class Класс @ decoratorname @ object.__init__(arg1, arg2) +@ декоратор +@ декоратор.décorateur # Numbers