From 9dc6765ad1254914b68096b4a9087925e85e8a3e Mon Sep 17 00:00:00 2001 From: Victor Salgado Date: Fri, 19 Dec 2014 06:47:25 -0200 Subject: [PATCH 01/13] Fix decorators to allow the same kind of characters that functions do --- syntax/python.vim | 2 +- test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 8e25a7f..ba34666 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -179,7 +179,7 @@ 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 +syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained syn match pythonDot "\." display containedin=pythonDottedName " diff --git a/test.py b/test.py index 0ee30a2..671d289 100644 --- a/test.py +++ b/test.py @@ -51,6 +51,7 @@ class Класс @ decoratorname @ object.__init__(arg1, arg2) +@ декоратор.décorateur # Numbers From ea215a90855393539d0c229b11798879341a7e0b Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sat, 27 Dec 2014 15:43:12 +0100 Subject: [PATCH 02/13] Add the MIT license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE 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. From 878e75cf90a6d0ec3e23ec7d5df9f9d060df6762 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sat, 27 Dec 2014 16:13:08 +0100 Subject: [PATCH 03/13] Highlight non-ASCII decorators only for Python 3 --- CHANGES.txt | 5 +++++ README.rst | 1 + syntax/python.vim | 11 ++++++++--- test.py | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e0579bf..8ee9f69 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +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 diff --git a/README.rst b/README.rst index 8293b60..9c34599 100644 --- a/README.rst +++ b/README.rst @@ -139,5 +139,6 @@ List of the contributors in alphabetical order: - Marc Weber - Pedro Algarvio - pydave at GitHub +- Victor Salgado - Will Gray - Yuri Habrusiev diff --git a/syntax/python.vim b/syntax/python.vim index ba34666..8d68796 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -2,9 +2,9 @@ " Language: Python " Maintainer: Dmitry Vasiliev " URL: https://github.com/hdima/python-syntax -" Last Change: 2013-11-18 +" Last Change: 2014-12-27 " Filenames: *.py -" Version: 3.3.6 +" Version: 3.3.7 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -31,6 +31,7 @@ " Marc Weber " Pedro Algarvio " pydave at GitHub +" Victor Salgado " Will Gray " Yuri Habrusiev " @@ -179,7 +180,11 @@ endif " syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite -syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" 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 671d289..b80ea1e 100644 --- a/test.py +++ b/test.py @@ -51,6 +51,7 @@ class Класс @ decoratorname @ object.__init__(arg1, arg2) +@ декоратор @ декоратор.décorateur # Numbers From 716ded1d56713492fb49ddb11958102c78ef6c4f Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sat, 27 Dec 2014 16:48:55 +0100 Subject: [PATCH 04/13] Add GitHub links for most of the contributors --- CHANGES.txt | 4 ++-- README.rst | 20 ++++++++++---------- syntax/python.vim | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8ee9f69..0566e14 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,10 +11,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/README.rst b/README.rst index 9c34599..6017981 100644 --- a/README.rst +++ b/README.rst @@ -130,15 +130,15 @@ Contributors List of the contributors in alphabetical order: -- Andrea Riciputi +- `Andrea Riciputi `_ - Anton Butanaev - Caleb Adamantine -- Elizabeth Myers -- Jeroen Ruigrok van der Werven -- John Eikenberry -- Marc Weber -- Pedro Algarvio -- pydave at GitHub -- Victor Salgado -- Will Gray -- Yuri Habrusiev +- `David Briscoe `_ +- `Elizabeth Myers `_ +- `Jeroen Ruigrok van der Werven `_ +- `John Eikenberry `_ +- `Marc Weber `_ +- `Pedro Algarvio `_ +- `Victor Salgado `_ +- `Will Gray `_ +- `Yuri Habrusiev `_ diff --git a/syntax/python.vim b/syntax/python.vim index 8d68796..a8b4635 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -25,12 +25,12 @@ " Andrea Riciputi " Anton Butanaev " Caleb Adamantine +" David Briscoe " Elizabeth Myers " Jeroen Ruigrok van der Werven " John Eikenberry " Marc Weber " Pedro Algarvio -" pydave at GitHub " Victor Salgado " Will Gray " Yuri Habrusiev From 44f1855902b6e2836ff95bec3fc221ad17021ee3 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Mon, 30 Mar 2015 21:46:54 +0200 Subject: [PATCH 05/13] Update python.vim header --- README.rst | 2 +- syntax.txt | 65 +++++++++++++++++++++++++++++++++++++++++++++++ syntax/python.vim | 13 +++++----- 3 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 syntax.txt diff --git a/README.rst b/README.rst index 6017981..f38c6ab 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 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 a8b4635..42efaa3 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: 2014-12-27 -" Filenames: *.py -" Version: 3.3.7 +" Language: Python +" Current Maintainer: Dmitry Vasiliev +" Previous Maintainer: Neil Schemenauer +" URL: https://github.com/hdima/python-syntax +" Last Change: 2015-03-30 +" Filenames: *.py +" Version: 3.3.7 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer From 4d925a99dd8cb17154c6fbcc823792ef707e261c Mon Sep 17 00:00:00 2001 From: Ihor Gorobets Date: Wed, 27 May 2015 18:12:08 +0300 Subject: [PATCH 06/13] Python 3.5 new syntax sugar https://www.python.org/dev/peps/pep-0492/ --- syntax/python.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/syntax/python.vim b/syntax/python.vim index 42efaa3..fd48398 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -174,6 +174,11 @@ 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 "\" display + syn match pythonStatement "\" display + syn match pythonStatement "\" display + syn match pythonStatement "\" display endif " From d948f835b497079a9be291898d1f947362cb3e29 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Wed, 10 Jun 2015 21:14:14 +0200 Subject: [PATCH 07/13] Update TODO item --- TODO.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 10d2c07687b611b7c647ad09b8b86ed968819dbd Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Wed, 10 Jun 2015 21:20:04 +0200 Subject: [PATCH 08/13] Update CHANGES.txt --- CHANGES.txt | 5 +++++ README.rst | 1 + syntax/python.vim | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0566e14..0452c07 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +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. diff --git a/README.rst b/README.rst index f38c6ab..7e21687 100644 --- a/README.rst +++ b/README.rst @@ -135,6 +135,7 @@ List of the contributors in alphabetical order: - Caleb Adamantine - `David Briscoe `_ - `Elizabeth Myers `_ +- `Ihor Gorobets `_ - `Jeroen Ruigrok van der Werven `_ - `John Eikenberry `_ - `Marc Weber `_ diff --git a/syntax/python.vim b/syntax/python.vim index fd48398..e461241 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -3,9 +3,9 @@ " Current Maintainer: Dmitry Vasiliev " Previous Maintainer: Neil Schemenauer " URL: https://github.com/hdima/python-syntax -" Last Change: 2015-03-30 +" Last Change: 2015-06-10 " Filenames: *.py -" Version: 3.3.7 +" Version: 3.5.0 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -28,6 +28,7 @@ " Caleb Adamantine " David Briscoe " Elizabeth Myers +" Ihor Gorobets " Jeroen Ruigrok van der Werven " John Eikenberry " Marc Weber From 67b6d85258890862372bb3cf7c58a9776d52c3de Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 31 Oct 2015 19:53:06 -0700 Subject: [PATCH 09/13] Dummy pythonInclude group to keep pyrex.vim happy. (I don't know how to create an empty group so I just put back "import" into it.) --- syntax/python.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/syntax/python.vim b/syntax/python.vim index e461241..4c5615f 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -157,6 +157,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 From e4d992dc44cab00e7aa6cae7ff938b05884503e5 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Sun, 1 Nov 2015 18:27:15 +0900 Subject: [PATCH 10/13] Correct highlighting async function names in Python 3.5 --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index e461241..4ad66b3 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -176,7 +176,7 @@ else syn keyword pythonBoolean True False syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained syn keyword pythonStatement await - syn match pythonStatement "\" display + syn match pythonStatement "\" nextgroup=pythonFunction skipwhite syn match pythonStatement "\" display syn match pythonStatement "\" display syn match pythonStatement "\" display From 2ed516d5692ebe742c5968d24399a6017c037b62 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sun, 1 Nov 2015 18:41:08 +0100 Subject: [PATCH 11/13] Update CHANGES/README --- CHANGES.txt | 4 ++++ README.rst | 1 + syntax/python.vim | 2 +- test.py | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0452c07..4a555dc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +Revision 3.6.0 (2015-11-XX): + + - Fix 'async def' highlighting. Patch by Joongi Kim + Revision 3.5.0 (2015-06-10): - Add support for 'async ...' and 'await' keywords introduced in diff --git a/README.rst b/README.rst index 7e21687..a45e330 100644 --- a/README.rst +++ b/README.rst @@ -138,6 +138,7 @@ List of the contributors in alphabetical order: - `Ihor Gorobets `_ - `Jeroen Ruigrok van der Werven `_ - `John Eikenberry `_ +- `Joongi Kim `_ - `Marc Weber `_ - `Pedro Algarvio `_ - `Victor Salgado `_ diff --git a/syntax/python.vim b/syntax/python.vim index 4ad66b3..fe42075 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -31,6 +31,7 @@ " Ihor Gorobets " Jeroen Ruigrok van der Werven " John Eikenberry +" Joongi Kim " Marc Weber " Pedro Algarvio " Victor Salgado @@ -179,7 +180,6 @@ else syn match pythonStatement "\" nextgroup=pythonFunction skipwhite syn match pythonStatement "\" display syn match pythonStatement "\" display - syn match pythonStatement "\" display endif " diff --git a/test.py b/test.py index b80ea1e..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 From ad932f52425260bb56f76f4967ebd74a369a5af3 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sun, 1 Nov 2015 18:58:42 +0100 Subject: [PATCH 12/13] Update CHANGES/README --- CHANGES.txt | 2 ++ README.rst | 1 + syntax/python.vim | 1 + 3 files changed, 4 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 4a555dc..2d3b520 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,8 @@ 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): diff --git a/README.rst b/README.rst index a45e330..f9cd20d 100644 --- a/README.rst +++ b/README.rst @@ -132,6 +132,7 @@ List of the contributors in alphabetical order: - `Andrea Riciputi `_ - Anton Butanaev +- `Antony Lee `_ - Caleb Adamantine - `David Briscoe `_ - `Elizabeth Myers `_ diff --git a/syntax/python.vim b/syntax/python.vim index 89ade79..f19a12c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -25,6 +25,7 @@ " " Andrea Riciputi " Anton Butanaev +" Antony Lee " Caleb Adamantine " David Briscoe " Elizabeth Myers From 69760cb3accce488cc072772ca918ac2cbf384ba Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sun, 1 Nov 2015 19:52:45 +0100 Subject: [PATCH 13/13] Update version and last change date --- syntax/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index f19a12c..e963628 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -3,9 +3,9 @@ " Current Maintainer: Dmitry Vasiliev " Previous Maintainer: Neil Schemenauer " URL: https://github.com/hdima/python-syntax -" Last Change: 2015-06-10 +" Last Change: 2015-11-01 " Filenames: *.py -" Version: 3.5.0 +" Version: 3.6.0 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer