From e344f212b67b291bcf56ed75d3c7e6de0d5bcdac Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sat, 1 Jun 2013 17:18:56 +0200 Subject: [PATCH 01/23] Fix behaviour of b:python_version_2 variable --- CHANGES.txt | 4 ++++ README.rst | 1 + syntax/python.vim | 12 ++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f8e75b2..463f047 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +Revision 3.3.2 (2013-06-01): + + - Fixed behaviour of b:python_version_2 variable. Reported by Will Gray. + Revision 3.3.1 (2013-05-12): - The script was moved to its own repository at diff --git a/README.rst b/README.rst index 82c4195..aeda04d 100644 --- a/README.rst +++ b/README.rst @@ -133,3 +133,4 @@ Contributors - Andrea Riciputi - Anton Butanaev - Marc Weber +- Will Gray diff --git a/syntax/python.vim b/syntax/python.vim index 7b65c42..bc7f319 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-05-12 +" Last Change: 2013-06-01 " Filenames: *.py -" Version: 3.3.1 +" Version: 3.3.2 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -27,6 +27,7 @@ " Andrea Riciputi " Anton Butanaev " Marc Weber +" Will Gray " " Options " ======= @@ -99,12 +100,15 @@ endfunction " Check if option is enabled function! s:Enabled(name) - return exists(a:name) && {a:name} != 0 + return exists(a:name) && {a:name} endfunction " Is it Python 2 syntax? function! s:Python2Syntax() - return s:Enabled("b:python_version_2") || s:Enabled("g:python_version_2") + if exists("b:python_version_2") + return b:python_version_2 + endif + return s:Enabled("g:python_version_2") endfunction " From fc6a66bf8025d311ce86076c064aa9263a1e5b3e Mon Sep 17 00:00:00 2001 From: Will Gray Date: Sat, 1 Jun 2013 14:53:27 -0500 Subject: [PATCH 02/23] Reload local syntax only Turning syntax off and back on is more than what's necessary to reload the syntax for the current buffer. --- syntax/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index bc7f319..5f0c19f 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -88,8 +88,8 @@ endif " " Commands " -command! -buffer Python2Syntax let b:python_version_2 = 1 | if exists("g:syntax_on") | syn off | endif | syn enable -command! -buffer Python3Syntax let b:python_version_2 = 0 | if exists("g:syntax_on") | syn off | endif | syn enable +command! -buffer Python2Syntax let b:python_version_2 = 1 | let &syntax=&syntax +command! -buffer Python3Syntax let b:python_version_2 = 0 | let &syntax=&syntax " Enable option if it's not defined function! s:EnableByDefault(name) From ebbdd093b73156485a3c4adf3fdbc9261bb092c5 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sun, 2 Jun 2013 13:52:27 +0200 Subject: [PATCH 03/23] Revision 3.3.3 --- CHANGES.txt | 4 ++++ README.rst | 10 ++++++---- syntax/python.vim | 14 ++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 463f047..776ef86 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +Revision 3.3.3 (2013-06-02): + + - More lightweight syntax reloading. Patch by Will Gray. + Revision 3.3.2 (2013-06-01): - Fixed behaviour of b:python_version_2 variable. Reported by Will Gray. diff --git a/README.rst b/README.rst index aeda04d..c49b7d3 100644 --- a/README.rst +++ b/README.rst @@ -126,11 +126,13 @@ Options used by the script Contributors ------------ -- Jeroen Ruigrok van der Werven -- Pedro Algarvio -- John Eikenberry -- Caleb Adamantine +List of the contributors in alphabetical order: + - Andrea Riciputi - Anton Butanaev +- Caleb Adamantine +- Jeroen Ruigrok van der Werven +- John Eikenberry - Marc Weber +- Pedro Algarvio - Will Gray diff --git a/syntax/python.vim b/syntax/python.vim index 5f0c19f..0db6929 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-06-01 +" Last Change: 2013-06-02 " Filenames: *.py -" Version: 3.3.2 +" Version: 3.3.3 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -20,13 +20,15 @@ " Contributors " ============ " -" Jeroen Ruigrok van der Werven -" Pedro Algarvio -" John Eikenberry -" Caleb Adamantine +" List of the contributors in alphabetical order: +" " Andrea Riciputi " Anton Butanaev +" Caleb Adamantine +" Jeroen Ruigrok van der Werven +" John Eikenberry " Marc Weber +" Pedro Algarvio " Will Gray " " Options From a0d21acc1c557c4b01c686f30ae63474adcceb49 Mon Sep 17 00:00:00 2001 From: Yuri Habrusiev Date: Thu, 1 Aug 2013 17:49:49 +0300 Subject: [PATCH 04/23] add pythonBoolean syntax --- syntax/python.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 0db6929..2f4b493 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -159,7 +159,8 @@ if s:Python2Syntax() syn keyword pythonPreCondit as syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained else - syn keyword pythonStatement as nonlocal False None True + syn keyword pythonStatement as nonlocal + syn keyword pythonBoolean True False None syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained endif @@ -523,6 +524,8 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonHexError Error HiLink pythonBinError Error + HiLink pythonBoolean Boolean + HiLink pythonBuiltinObj Structure HiLink pythonBuiltinFunc Function From 6f6f10ff5408182f1d8ff1af26058e80c5dfa9cd Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sun, 11 Aug 2013 17:25:39 +0200 Subject: [PATCH 05/23] Clean up boolean highlighting --- CHANGES.txt | 4 ++++ README.rst | 1 + syntax/python.vim | 12 +++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 776ef86..05e7a20 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +Revision 3.3.4 (2013-08-11): + + - Highlight True and False as booleans. Patch by Yuri Habrusiev. + Revision 3.3.3 (2013-06-02): - More lightweight syntax reloading. Patch by Will Gray. diff --git a/README.rst b/README.rst index c49b7d3..9c012cd 100644 --- a/README.rst +++ b/README.rst @@ -136,3 +136,4 @@ List of the contributors in alphabetical order: - Marc Weber - Pedro Algarvio - Will Gray +- Yuri Habrusiev diff --git a/syntax/python.vim b/syntax/python.vim index 2f4b493..f317df0 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-06-02 +" Last Change: 2013-08-11 " Filenames: *.py -" Version: 3.3.3 +" Version: 3.3.4 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -30,6 +30,7 @@ " Marc Weber " Pedro Algarvio " Will Gray +" Yuri Habrusiev " " Options " ======= @@ -159,8 +160,8 @@ if s:Python2Syntax() syn keyword pythonPreCondit as syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained else - syn keyword pythonStatement as nonlocal - syn keyword pythonBoolean True False None + syn keyword pythonStatement as nonlocal None + syn keyword pythonBoolean True False syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained endif @@ -371,7 +372,8 @@ syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display if s:Enabled("g:python_highlight_builtin_objs") if s:Python2Syntax() - syn keyword pythonBuiltinObj True False None + syn keyword pythonBuiltinObj None + syn keyword pythonBoolean True False endif syn keyword pythonBuiltinObj Ellipsis NotImplemented syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ From 9ccbd6196b893fb3f094de9667828ad556a8cf67 Mon Sep 17 00:00:00 2001 From: pydave Date: Sat, 24 Aug 2013 10:54:06 -0700 Subject: [PATCH 06/23] Make imports look like includes Imports work like includes so they should use the relevant group-name. I also renamed pythonPreCondit to pythonImport since it's specific to that type of "preprocessor" statement. --- syntax/python.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index f317df0..195e77f 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -149,7 +149,7 @@ syn keyword pythonStatement with syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite syn keyword pythonRepeat for while syn keyword pythonConditional if elif else -syn keyword pythonPreCondit import from +syn keyword pythonImport import from syn keyword pythonException try except finally syn keyword pythonOperator and in is not or @@ -157,7 +157,7 @@ if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") syn keyword pythonStatement print endif - syn keyword pythonPreCondit as + syn keyword pythonImport as syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained else syn keyword pythonStatement as nonlocal None @@ -469,7 +469,7 @@ if version >= 508 || !exists("did_python_syn_inits") endif HiLink pythonStatement Statement - HiLink pythonPreCondit Statement + HiLink pythonImport Include HiLink pythonFunction Function HiLink pythonConditional Conditional HiLink pythonRepeat Repeat From 21a2e84df6ff1770f153d1a70b2b35e387547364 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sat, 31 Aug 2013 12:47:35 +0200 Subject: [PATCH 07/23] 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 05e7a20..79d87f2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +Revision 3.3.5 (2013-08-31): + + - Highlight 'import', 'from' and 'as' as include statements. + Patch by pydave at GitHub. + Revision 3.3.4 (2013-08-11): - Highlight True and False as booleans. Patch by Yuri Habrusiev. diff --git a/README.rst b/README.rst index 9c012cd..7dca0c2 100644 --- a/README.rst +++ b/README.rst @@ -135,5 +135,6 @@ List of the contributors in alphabetical order: - John Eikenberry - Marc Weber - Pedro Algarvio +- pydave at GitHub - Will Gray - Yuri Habrusiev diff --git a/syntax/python.vim b/syntax/python.vim index 195e77f..ec9bc2f 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-08-11 +" Last Change: 2013-08-31 " Filenames: *.py -" Version: 3.3.4 +" Version: 3.3.5 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -29,6 +29,7 @@ " John Eikenberry " Marc Weber " Pedro Algarvio +" pydave at GitHub " Will Gray " Yuri Habrusiev " From 69f8e12a46237f556e6b2a1bd2d2172eec4b6b0d Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Sat, 31 Aug 2013 14:28:14 +0200 Subject: [PATCH 08/23] 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. --- CHANGES.txt | 3 +++ README.rst | 2 ++ syntax/python.vim | 15 +++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 79d87f2..ca6ab78 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,9 @@ Revision 3.3.5 (2013-08-31): - Highlight 'import', 'from' and 'as' as include statements. Patch by pydave at GitHub. + - 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. Revision 3.3.4 (2013-08-11): diff --git a/README.rst b/README.rst index 7dca0c2..f7d20f4 100644 --- a/README.rst +++ b/README.rst @@ -117,6 +117,8 @@ Options used by the script Highlight doc-tests ``python_print_as_function`` Highlight ``print`` statement as function for Python 2 +``python_highlight_file_headers_as_comments`` + Highlight shebang and coding headers as comments ``python_highlight_all`` Enable all the options above. *NOTE: This option don't override any previously set options* diff --git a/syntax/python.vim b/syntax/python.vim index ec9bc2f..e2eaa90 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -73,6 +73,9 @@ " python_highlight_doctests Highlight doc-tests " python_print_as_function Highlight 'print' statement as " function for Python 2 +" python_highlight_file_headers_as_comments +" Highlight shebang and coding +" headers as comments " " python_highlight_all Enable all the options above " NOTE: This option don't override @@ -179,8 +182,10 @@ syn match pythonDot "\." display containedin=pythonDottedName " syn match pythonComment "#.*$" display contains=pythonTodo,@Spell -syn match pythonRun "\%^#!.*$" -syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" +if !s:Enabled("g:python_highlight_file_headers_as_comments") + syn match pythonRun "\%^#!.*$" + syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" +endif syn keyword pythonTodo TODO FIXME XXX contained " @@ -482,8 +487,10 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonDot Normal HiLink pythonComment Comment - HiLink pythonCoding Special - HiLink pythonRun Special + if !s:Enabled("g:python_highlight_file_headers_as_comments") + HiLink pythonCoding Special + HiLink pythonRun Special + endif HiLink pythonTodo Todo HiLink pythonError Error From efe8499cfbd56439603214c3577b3815d37a8ab7 Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Mon, 18 Nov 2013 21:23:03 +0100 Subject: [PATCH 09/23] Add TODO item --- TODO.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO.txt b/TODO.txt index f80a476..f562bfb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,9 @@ Now === +- It seems python.vim doesn't highlight special characters inside strings by + default but only when it reloaded? + - Add support for slice syntax: http://img155.imageshack.us/img155/7767/screenshotgs.png From 453269d0f86ce3c2e401b1bc8f7dfc5e1b8a5b7d Mon Sep 17 00:00:00 2001 From: Dmitry Vasiliev Date: Mon, 18 Nov 2013 21:29:47 +0100 Subject: [PATCH 10/23] Highlight 'yield from' statement The 'yield from' statement was introduced in Python 3.3. Reported by Elizabeth Myers. --- CHANGES.txt | 5 +++++ README.rst | 1 + syntax/python.vim | 13 +++++++++---- test.py | 3 +++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ca6ab78..e0579bf 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +Revision 3.3.6 (2013-11-18): + + - Highlight 'yield from' statement introduced in Python 3.3. Reported by + Elizabeth Myers. + Revision 3.3.5 (2013-08-31): - Highlight 'import', 'from' and 'as' as include statements. diff --git a/README.rst b/README.rst index f7d20f4..8293b60 100644 --- a/README.rst +++ b/README.rst @@ -133,6 +133,7 @@ List of the contributors in alphabetical order: - Andrea Riciputi - Anton Butanaev - Caleb Adamantine +- Elizabeth Myers - Jeroen Ruigrok van der Werven - John Eikenberry - Marc Weber diff --git a/syntax/python.vim b/syntax/python.vim index e2eaa90..8e25a7f 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-08-31 +" Last Change: 2013-11-18 " Filenames: *.py -" Version: 3.3.5 +" Version: 3.3.6 " " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer @@ -25,6 +25,7 @@ " Andrea Riciputi " Anton Butanaev " Caleb Adamantine +" Elizabeth Myers " Jeroen Ruigrok van der Werven " John Eikenberry " Marc Weber @@ -148,15 +149,18 @@ syn keyword pythonStatement break continue del syn keyword pythonStatement exec return syn keyword pythonStatement pass raise syn keyword pythonStatement global assert -syn keyword pythonStatement lambda yield +syn keyword pythonStatement lambda syn keyword pythonStatement with syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite syn keyword pythonRepeat for while syn keyword pythonConditional if elif else -syn keyword pythonImport import from +syn keyword pythonImport import syn keyword pythonException try except finally syn keyword pythonOperator and in is not or +syn match pythonStatement "\" display +syn match pythonImport "\" display + if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") syn keyword pythonStatement print @@ -165,6 +169,7 @@ if s:Python2Syntax() syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained else syn keyword pythonStatement as nonlocal None + syn match pythonStatement "\" display syn keyword pythonBoolean True False syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained endif diff --git a/test.py b/test.py index af17c27..0ee30a2 100644 --- a/test.py +++ b/test.py @@ -10,6 +10,9 @@ with break continue del exec return pass print raise global assert lambda yield for while if elif else import from as try except finally and in is not or + +yield from + def functionname class Classname def функция From 9dc6765ad1254914b68096b4a9087925e85e8a3e Mon Sep 17 00:00:00 2001 From: Victor Salgado Date: Fri, 19 Dec 2014 06:47:25 -0200 Subject: [PATCH 11/23] 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 12/23] 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 13/23] 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 14/23] 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 15/23] 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 16/23] 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 17/23] 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 18/23] 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 19/23] 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 20/23] 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 21/23] 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 22/23] 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 23/23] 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