diff options
author | James McCoy <jamessan@jamessan.com> | 2017-04-19 23:16:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 23:16:36 -0400 |
commit | 2fb46adc5e19a0f85deed3983a3b956c31504adf (patch) | |
tree | a971e87f03a42c0f8f33c7bdf481f5b3605a8795 /runtime/syntax/python.vim | |
parent | 462c53eb3ea256bb85eb3916400d984347f0626f (diff) | |
parent | b25fa94eb5234e3c5ae1f7b3c0888aac644ae923 (diff) | |
download | rneovim-2fb46adc5e19a0f85deed3983a3b956c31504adf.tar.gz rneovim-2fb46adc5e19a0f85deed3983a3b956c31504adf.tar.bz2 rneovim-2fb46adc5e19a0f85deed3983a3b956c31504adf.zip |
Merge pull request #6531 from justinmk/vim-dc1f1645cb49
vim-patch: runtime updates
Diffstat (limited to 'runtime/syntax/python.vim')
-rw-r--r-- | runtime/syntax/python.vim | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index fa42b3e2d2..f0f03a8c8d 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Python " Maintainer: Zvezdan Petkovic <zpetkovic@acm.org> -" Last Change: 2016 Jul 21 +" Last Change: 2016 Aug 14 " Credits: Neil Schemenauer <nas@python.ca> " Dmitry Vasiliev " @@ -84,14 +84,30 @@ syn keyword pythonInclude from import syn keyword pythonAsync async await " Decorators (new in Python 2.4) -syn match pythonDecorator "@" display nextgroup=pythonFunction skipwhite -" The zero-length non-grouping match before the function name is -" extremely important in pythonFunction. Without it, everything is -" interpreted as a function inside the contained environment of -" doctests. +" Python 3.5 introduced the use of the same symbol for matrix +" multiplication. We now have to exclude the symbol from being +" highlighted when used in that context. Hence, the check that it's +" preceded by empty space only (possibly in a docstring/doctest) and +" followed by decorator name, optional parenthesized list of arguments, +" and the next line with either def, class, or another decorator. +syn match pythonDecorator + \ "\%(\%(^\s*\)\%(\%(>>>\|\.\.\.\)\s\+\)\=\)\zs@\%(\s*\h\%(\w\|\.\)*\%(([^)]*)\)\=\s*\n\s*\%(\.\.\.\s\+\)\=\%(@\s*\h\|\%(def\|class\)\s\+\)\)\@=" + \ display nextgroup=pythonDecoratorName skipwhite + " A dot must be allowed because of @MyClass.myfunc decorators. +" It must be preceded by a decorator symbol and on a separate line from +" a function/class it decorates. +syn match pythonDecoratorName + \ "\%(@\s*\)\@<=\h\%(\w\|\.\)*\%(\%(([^)]*)\)\=\s*\n\)\@=" + \ contained display nextgroup=pythonFunction skipnl + +" The zero-length non-grouping match of def or class before the function +" name is extremely important in pythonFunction. Without it, everything +" is interpreted as a function inside the contained environment of +" doctests. syn match pythonFunction - \ "\%(\%(def\s\|class\s\|@\)\s*\)\@<=\h\%(\w\|\.\)*" contained + \ "\%(\%(^\s*\)\%(\%(>>>\|\.\.\.\)\s\+\)\=\%(def\|class\)\s\+\)\@<=\h\w*" + \ contained syn match pythonComment "#.*$" contains=pythonTodo,@Spell syn keyword pythonTodo FIXME NOTE NOTES TODO XXX contained @@ -293,6 +309,7 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonInclude Include HiLink pythonAsync Statement HiLink pythonDecorator Define + HiLink pythonDecoratorName Function HiLink pythonFunction Function HiLink pythonComment Comment HiLink pythonTodo Todo |