From 0051cf3adb11952859cbe8da2803658a271852b8 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Sat, 25 Jun 2016 18:37:11 +0300 Subject: [PATCH 001/103] self and keyword arguments are highlighted now. Also builtin types such as int, float, str etc highlighted as types ans not as functions --- syntax/python.vim | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index e963628..3bdba44 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -150,6 +150,7 @@ endif " Keywords " +syn keyword pythonInstanceVariable self syn keyword pythonStatement break continue del syn keyword pythonStatement exec return syn keyword pythonStatement pass raise @@ -174,11 +175,10 @@ if s:Python2Syntax() syn keyword pythonStatement print endif syn keyword pythonImport as - syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" display contained + syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained else - syn keyword pythonStatement as nonlocal None + syn keyword pythonStatement as nonlocal 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 @@ -186,6 +186,20 @@ else syn match pythonStatement "\" display endif +syn region FunctionParameters start='(' end=')' contains= + \ OptionalParameters, + \ pythonInstanceVariable, + \ pythonHexNumber, + \ pythonOctNumber, + \ pythonString, + \ pythonUniString, + \ pythonUniRawString, + \ pythonNumber, + \ pythonRawString, + \ pythonBuiltinObj, + \ pythonBuiltinFunc + \ nextgroup=OptionalParameters +syn match OptionalParameters /\i*\ze=/ display contained " " Decorators (new in Python 2.4) " @@ -398,11 +412,11 @@ syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display " if s:Enabled("g:python_highlight_builtin_objs") - if s:Python2Syntax() - syn keyword pythonBuiltinObj None - syn keyword pythonBoolean True False - endif + syn keyword pythonBuiltinObj None + syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented + syn keyword pythonBuiltinObj int float tuple str list dict set frozenset + syn keyword pythonBuiltinObj defaultdict syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ endif @@ -424,15 +438,15 @@ if s:Enabled("g:python_highlight_builtin_funcs") syn keyword pythonBuiltinFunc __import__ abs all any syn keyword pythonBuiltinFunc bin bool bytearray bytes syn keyword pythonBuiltinFunc chr classmethod cmp compile complex - syn keyword pythonBuiltinFunc delattr dict dir divmod enumerate eval - syn keyword pythonBuiltinFunc filter float format frozenset getattr + syn keyword pythonBuiltinFunc delattr dir divmod enumerate eval + syn keyword pythonBuiltinFunc filter format getattr syn keyword pythonBuiltinFunc globals hasattr hash hex id - syn keyword pythonBuiltinFunc input int isinstance - syn keyword pythonBuiltinFunc issubclass iter len list locals map max + syn keyword pythonBuiltinFunc input isinstance + syn keyword pythonBuiltinFunc issubclass iter len locals map max syn keyword pythonBuiltinFunc min next object oct open ord syn keyword pythonBuiltinFunc pow property range - syn keyword pythonBuiltinFunc repr reversed round set setattr - syn keyword pythonBuiltinFunc slice sorted staticmethod str sum super tuple + syn keyword pythonBuiltinFunc repr reversed round setattr + syn keyword pythonBuiltinFunc slice sorted staticmethod sum super syn keyword pythonBuiltinFunc type vars zip endif @@ -561,6 +575,8 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonBuiltinFunc Function HiLink pythonExClass Structure + HiLink pythonInstanceVariable htmlTagN + HiLink OptionalParameters htmlTagN delcommand HiLink endif From cf3c3594908a63cf0d7e6d85f1aeb69129979ddf Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Sun, 26 Jun 2016 17:39:00 +0300 Subject: [PATCH 002/103] bug with keyword arguments highlighting have been fixed --- syntax/python.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax/python.vim b/syntax/python.vim index 3bdba44..8d479f7 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -187,6 +187,7 @@ else endif syn region FunctionParameters start='(' end=')' contains= + \ FunctionParameters, \ OptionalParameters, \ pythonInstanceVariable, \ pythonHexNumber, From 5881fdc81ec65c1ae227f89bbd5abdf73b0cc3d9 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 27 Jun 2016 16:03:36 +0300 Subject: [PATCH 003/103] vim bultin objects and functions aren't highlighted if they come after dot --- syntax/python.vim | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 8d479f7..0a6e734 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -416,8 +416,7 @@ if s:Enabled("g:python_highlight_builtin_objs") syn keyword pythonBuiltinObj None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn keyword pythonBuiltinObj int float tuple str list dict set frozenset - syn keyword pythonBuiltinObj defaultdict + syn match pythonBuiltinObj '\v[^.]*<(int|float|tuple|str|list|dict|set|frozenset)>' syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ endif @@ -427,28 +426,28 @@ endif if s:Enabled("g:python_highlight_builtin_funcs") if s:Python2Syntax() - syn keyword pythonBuiltinFunc apply basestring buffer callable coerce - syn keyword pythonBuiltinFunc execfile file help intern long raw_input - syn keyword pythonBuiltinFunc reduce reload unichr unicode xrange + syn match pythonBuiltinFunc 'v[^.]*<(apply|basestring|buffer|callable|coerce)>' + syn match pythonBuiltinFunc 'v[^.]*<(execfile|file|help|intern|long|raw_input)>' + syn match pythonBuiltinFunc 'v[^.]*<(reduce|reload|unichr|unicode|xrange)>' if s:Enabled("g:python_print_as_function") - syn keyword pythonBuiltinFunc print + syn match pythonBuiltinFunc 'v[^.]*<(print)>' endif else - syn keyword pythonBuiltinFunc ascii exec memoryview print + syn match pythonBuiltinFunc 'v[^.]*<(ascii|exec|memoryview|print)>' endif - syn keyword pythonBuiltinFunc __import__ abs all any - syn keyword pythonBuiltinFunc bin bool bytearray bytes - syn keyword pythonBuiltinFunc chr classmethod cmp compile complex - syn keyword pythonBuiltinFunc delattr dir divmod enumerate eval - syn keyword pythonBuiltinFunc filter format getattr - syn keyword pythonBuiltinFunc globals hasattr hash hex id - syn keyword pythonBuiltinFunc input isinstance - syn keyword pythonBuiltinFunc issubclass iter len locals map max - syn keyword pythonBuiltinFunc min next object oct open ord - syn keyword pythonBuiltinFunc pow property range - syn keyword pythonBuiltinFunc repr reversed round setattr - syn keyword pythonBuiltinFunc slice sorted staticmethod sum super - syn keyword pythonBuiltinFunc type vars zip + syn match pythonBuiltinFunc 'v[^.]*<(__import__|abs|all|any)>' + syn match pythonBuiltinFunc 'v[^.]*<(bin|bool|bytearray|bytes)>' + syn match pythonBuiltinFunc 'v[^.]*<(chr|classmethod|cmp|compile|complex)>' + syn match pythonBuiltinFunc 'v[^.]*<(delattr|dir|divmod|enumerate|eval)>' + syn match pythonBuiltinFunc 'v[^.]*<(filter|format|getattr)>' + syn match pythonBuiltinFunc 'v[^.]*<(globals|hasattr|hash|hex|id)>' + syn match pythonBuiltinFunc 'v[^.]*<(input|isinstance)>' + syn match pythonBuiltinFunc 'v[^.]*<(issubclass|iter|len|locals|map|max)>' + syn match pythonBuiltinFunc 'v[^.]*<(min|next|object|oct|open|ord)>' + syn match pythonBuiltinFunc 'v[^.]*<(pow|property|range)>' + syn match pythonBuiltinFunc 'v[^.]*<(repr|reversed|round|setattr)>' + syn match pythonBuiltinFunc 'v[^.]*<(slice|sorted|staticmethod|sum|super)>' + syn match pythonBuiltinFunc 'v[^.]*<(type|vars|zip)>' endif " From 036effcdf329f652b21d73a4ea6771a8b132140a Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 27 Jun 2016 16:29:49 +0300 Subject: [PATCH 004/103] disabling highlighting of builtin functions is now really working --- syntax/python.vim | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 0a6e734..51596c0 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -416,7 +416,7 @@ if s:Enabled("g:python_highlight_builtin_objs") syn keyword pythonBuiltinObj None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v[^.]*<(int|float|tuple|str|list|dict|set|frozenset)>' + syn match pythonBuiltinObj '\v(\.)@' syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ endif @@ -426,28 +426,28 @@ endif if s:Enabled("g:python_highlight_builtin_funcs") if s:Python2Syntax() - syn match pythonBuiltinFunc 'v[^.]*<(apply|basestring|buffer|callable|coerce)>' - syn match pythonBuiltinFunc 'v[^.]*<(execfile|file|help|intern|long|raw_input)>' - syn match pythonBuiltinFunc 'v[^.]*<(reduce|reload|unichr|unicode|xrange)>' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' if s:Enabled("g:python_print_as_function") - syn match pythonBuiltinFunc 'v[^.]*<(print)>' + syn match pythonBuiltinFunc '\v(\.)@' endif else - syn match pythonBuiltinFunc 'v[^.]*<(ascii|exec|memoryview|print)>' + syn match pythonBuiltinFunc '\v(\.)@' endif - syn match pythonBuiltinFunc 'v[^.]*<(__import__|abs|all|any)>' - syn match pythonBuiltinFunc 'v[^.]*<(bin|bool|bytearray|bytes)>' - syn match pythonBuiltinFunc 'v[^.]*<(chr|classmethod|cmp|compile|complex)>' - syn match pythonBuiltinFunc 'v[^.]*<(delattr|dir|divmod|enumerate|eval)>' - syn match pythonBuiltinFunc 'v[^.]*<(filter|format|getattr)>' - syn match pythonBuiltinFunc 'v[^.]*<(globals|hasattr|hash|hex|id)>' - syn match pythonBuiltinFunc 'v[^.]*<(input|isinstance)>' - syn match pythonBuiltinFunc 'v[^.]*<(issubclass|iter|len|locals|map|max)>' - syn match pythonBuiltinFunc 'v[^.]*<(min|next|object|oct|open|ord)>' - syn match pythonBuiltinFunc 'v[^.]*<(pow|property|range)>' - syn match pythonBuiltinFunc 'v[^.]*<(repr|reversed|round|setattr)>' - syn match pythonBuiltinFunc 'v[^.]*<(slice|sorted|staticmethod|sum|super)>' - syn match pythonBuiltinFunc 'v[^.]*<(type|vars|zip)>' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@' endif " From 7eaa930b434bb98804fb48302bbc1c5eea608bbb Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 27 Jun 2016 16:43:24 +0300 Subject: [PATCH 005/103] Forgot to add Boolean to the list on groups that FunctionParameters can contain --- syntax/python.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 51596c0..81761f3 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -198,7 +198,8 @@ syn region FunctionParameters start='(' end=')' contains= \ pythonNumber, \ pythonRawString, \ pythonBuiltinObj, - \ pythonBuiltinFunc + \ pythonBuiltinFunc, + \ pythonBoolean, \ nextgroup=OptionalParameters syn match OptionalParameters /\i*\ze=/ display contained " From 7520bfc22dc1158eea3b9aab7c3f14d33f3c8518 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 27 Jun 2016 16:44:40 +0300 Subject: [PATCH 006/103] removed , --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 81761f3..5521b8c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -199,7 +199,7 @@ syn region FunctionParameters start='(' end=')' contains= \ pythonRawString, \ pythonBuiltinObj, \ pythonBuiltinFunc, - \ pythonBoolean, + \ pythonBoolean \ nextgroup=OptionalParameters syn match OptionalParameters /\i*\ze=/ display contained " From cafb8760384f2a1522cac8788c6f5444c84de53a Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 27 Jun 2016 17:31:30 +0300 Subject: [PATCH 007/103] builtin functions highlighted only when used for calls --- syntax/python.vim | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 5521b8c..9261760 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -151,6 +151,7 @@ endif " syn keyword pythonInstanceVariable self +syn keyword pythonClassVaraible cls syn keyword pythonStatement break continue del syn keyword pythonStatement exec return syn keyword pythonStatement pass raise @@ -427,28 +428,28 @@ endif if s:Enabled("g:python_highlight_builtin_funcs") if s:Python2Syntax() - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' if s:Enabled("g:python_print_as_function") - syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' endif else - syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' endif - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' - syn match pythonBuiltinFunc '\v(\.)@' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@/ze\(?' endif " From a5df8e35d9c21e0a2b711a2ea969142723935f08 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 27 Jun 2016 23:46:15 +0300 Subject: [PATCH 008/103] import related module attributes added to builtin objects highlighting group --- syntax/python.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax/python.vim b/syntax/python.vim index 5521b8c..14966ae 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -419,6 +419,7 @@ if s:Enabled("g:python_highlight_builtin_objs") syn keyword pythonBuiltinObj Ellipsis NotImplemented syn match pythonBuiltinObj '\v(\.)@' syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ + syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif " From ac37a4f3b6abb1043fd5a23d7b712e28f7e67dcf Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Tue, 28 Jun 2016 09:23:58 +0300 Subject: [PATCH 009/103] function arguments can contain pythonStatement now --- syntax/python.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax/python.vim b/syntax/python.vim index 8980766..60a3d7c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -192,6 +192,7 @@ syn region FunctionParameters start='(' end=')' contains= \ OptionalParameters, \ pythonInstanceVariable, \ pythonHexNumber, + \ pythonStatement, \ pythonOctNumber, \ pythonString, \ pythonUniString, From d404efb776357ddef1ced1dffc087165510bc0bf Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Tue, 28 Jun 2016 09:35:23 +0300 Subject: [PATCH 010/103] builtin functions highlighted only if followed by opening brace --- syntax/python.vim | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 60a3d7c..6eb6d80 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -430,28 +430,28 @@ endif if s:Enabled("g:python_highlight_builtin_funcs") if s:Python2Syntax() - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' if s:Enabled("g:python_print_as_function") - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' endif else - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' endif - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@\ze\(?' - syn match pythonBuiltinFunc '\v(\.)@/ze\(?' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@/ze\(' endif " From d61f30a60564bd12c399608927fece59f8111591 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Tue, 28 Jun 2016 21:03:09 +0300 Subject: [PATCH 011/103] pythonRepeat have been added to groups contained in FunctionParameters --- syntax/python.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax/python.vim b/syntax/python.vim index 6eb6d80..b577d09 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -190,6 +190,7 @@ endif syn region FunctionParameters start='(' end=')' contains= \ FunctionParameters, \ OptionalParameters, + \ pythonRepeat, \ pythonInstanceVariable, \ pythonHexNumber, \ pythonStatement, From d02b79a8cdf9f5325561f72b5fbdb7c0eab17e61 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Tue, 28 Jun 2016 21:22:41 +0300 Subject: [PATCH 012/103] small bugfix with group that contains zip --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index b577d09..eac4c13 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -452,7 +452,7 @@ if s:Enabled("g:python_highlight_builtin_funcs") syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@/ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' endif " From cf46b81e13b67a445133d8ea4ed7eecebbba54f4 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 29 Jun 2016 11:51:28 +0300 Subject: [PATCH 013/103] pythonRepeat can be highlighted inside FunctionParameters group --- syntax/python.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 6eb6d80..1be4d98 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -193,6 +193,7 @@ syn region FunctionParameters start='(' end=')' contains= \ pythonInstanceVariable, \ pythonHexNumber, \ pythonStatement, + \ pythonRepeat, \ pythonOctNumber, \ pythonString, \ pythonUniString, @@ -451,7 +452,7 @@ if s:Enabled("g:python_highlight_builtin_funcs") syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@/ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' endif " From 4338cd85f5e4a659a61b0cd8979789d5642e76a3 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 29 Jun 2016 15:09:17 +0300 Subject: [PATCH 014/103] conditional and operator group is added to groups contained in FunctionParameters --- syntax/python.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syntax/python.vim b/syntax/python.vim index 1be4d98..668110e 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -191,6 +191,8 @@ syn region FunctionParameters start='(' end=')' contains= \ FunctionParameters, \ OptionalParameters, \ pythonInstanceVariable, + \ pythonConditional, + \ pythonOperator, \ pythonHexNumber, \ pythonStatement, \ pythonRepeat, From 27c4de218bce4df8fbe00c525298c9538e42a97f Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 4 Jul 2016 18:11:39 +0300 Subject: [PATCH 015/103] comment have been added to the function parameters group --- syntax/python.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/syntax/python.vim b/syntax/python.vim index 668110e..df2bfd3 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -190,8 +190,11 @@ endif syn region FunctionParameters start='(' end=')' contains= \ FunctionParameters, \ OptionalParameters, + \ OptionalParameters, \ pythonInstanceVariable, \ pythonConditional, + \ pythonComment, + \ pythonOperator, \ pythonOperator, \ pythonHexNumber, \ pythonStatement, From ebcb1ba1e7ef9ccad86e0a7138da56ae1be59f2a Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Tue, 5 Jul 2016 13:30:04 +0300 Subject: [PATCH 016/103] object is highlighlted as a type not as a function --- syntax/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index c2b5484..d0a4ff4 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -423,7 +423,7 @@ if s:Enabled("g:python_highlight_builtin_objs") syn keyword pythonBuiltinObj None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v(\.)@' + syn match pythonBuiltinObj '\v(\.)@' syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif @@ -451,7 +451,7 @@ if s:Enabled("g:python_highlight_builtin_funcs") syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' From a35dce769d2a97476e9f1a13b78c8c103567857e Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 20 Jul 2016 17:55:19 +0300 Subject: [PATCH 017/103] floats and onther numbers have been added to a list of groups that could be inside function parameters --- syntax/python.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syntax/python.vim b/syntax/python.vim index d0a4ff4..48c38bb 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -195,11 +195,15 @@ syn region FunctionParameters start='(' end=')' contains= \ pythonConditional, \ pythonComment, \ pythonOperator, + \ pythonNumber, + \ pythonNumberError, + \ pythonFloat, \ pythonHexNumber, \ pythonStatement, \ pythonOctNumber, \ pythonString, \ pythonUniString, + \ pythonExClass, \ pythonUniRawString, \ pythonNumber, \ pythonRawString, From 4523a6d86db70cdc1146a70c31ee07399bc55fc9 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Fri, 29 Jul 2016 09:35:20 +0300 Subject: [PATCH 018/103] faster syntax highlight (or not, can not test it) --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 48c38bb..f41b961 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -187,7 +187,7 @@ else syn match pythonStatement "\" display endif -syn region FunctionParameters start='(' end=')' contains= +syn region FunctionParameters start='(' end=')' display contains= \ FunctionParameters, \ OptionalParameters, \ pythonRepeat, From 8d58bf46f6b9234edfd756a599989de256c971e5 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Fri, 12 Aug 2016 16:30:27 +0300 Subject: [PATCH 019/103] moved bytes, bytearray to bultinobj group --- syntax/python.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index f41b961..611a05c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -202,11 +202,13 @@ syn region FunctionParameters start='(' end=')' display contains= \ pythonStatement, \ pythonOctNumber, \ pythonString, + \ pythonRawString, \ pythonUniString, \ pythonExClass, \ pythonUniRawString, \ pythonNumber, \ pythonRawString, + \ pythonBytes, \ pythonBuiltinObj, \ pythonBuiltinFunc, \ pythonBoolean @@ -427,7 +429,7 @@ if s:Enabled("g:python_highlight_builtin_objs") syn keyword pythonBuiltinObj None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v(\.)@' + syn match pythonBuiltinObj '\v(\.)@' syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif @@ -448,8 +450,7 @@ if s:Enabled("g:python_highlight_builtin_funcs") syn match pythonBuiltinFunc '\v(\.)@\ze\(' endif syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' syn match pythonBuiltinFunc '\v(\.)@\ze\(' @@ -477,6 +478,7 @@ if s:Enabled("g:python_highlight_exceptions") syn keyword pythonExClass FileNotFoundError InterruptedError syn keyword pythonExClass IsADirectoryError NotADirectoryError syn keyword pythonExClass PermissionError ProcessLookupError TimeoutError + syn keyword pythonExClass StopAsyncIteration syn keyword pythonExClass ResourceWarning endif From b8ee3f0444a95df0c9ed2d4ac5f2824e3181a0a3 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 15 Aug 2016 11:07:34 +0300 Subject: [PATCH 020/103] class variable hightlight --- syntax/python.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syntax/python.vim b/syntax/python.vim index 611a05c..69cffe8 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -192,6 +192,7 @@ syn region FunctionParameters start='(' end=')' display contains= \ OptionalParameters, \ pythonRepeat, \ pythonInstanceVariable, + \ pythonClassVaraible, \ pythonConditional, \ pythonComment, \ pythonOperator, @@ -590,6 +591,7 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonExClass Structure HiLink pythonInstanceVariable htmlTagN + HiLink pythonClassVaraible htmlTagN HiLink OptionalParameters htmlTagN delcommand HiLink From 10c3c0ece8064f2d61639b196ae9f9d6660866c4 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Thu, 27 Oct 2016 18:56:27 +0300 Subject: [PATCH 021/103] from keyword highlighted only if it is at start of line --- syntax/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 69cffe8..010e7a0 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -168,8 +168,8 @@ 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 +syn match pythonStatement "^\s*yield\>" display +syn match pythonImport "^\s*from\>" display if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") From bd24b62a3fb6fec31d2ed92fa63550954d60a2f4 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Thu, 10 Nov 2016 10:37:06 +0300 Subject: [PATCH 022/103] from is keyword and can't be used otherwised --- syntax/python.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 010e7a0..e9318f3 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -165,11 +165,11 @@ syn keyword pythonConditional if elif else " we provide a dummy group here to avoid crashing pyrex.vim. syn keyword pythonInclude import syn keyword pythonImport import +syn keyword pythonImport from syn keyword pythonException try except finally syn keyword pythonOperator and in is not or syn match pythonStatement "^\s*yield\>" display -syn match pythonImport "^\s*from\>" display if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") @@ -195,6 +195,7 @@ syn region FunctionParameters start='(' end=')' display contains= \ pythonClassVaraible, \ pythonConditional, \ pythonComment, + \ pythonImport, \ pythonOperator, \ pythonNumber, \ pythonNumberError, From bbed01805079561f467f44421b31e87b3bfefe5c Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Sat, 19 Nov 2016 13:00:07 +0300 Subject: [PATCH 023/103] keyword arguments and optional parameters are only highlighted inside actual function calls and function defenitions --- syntax/python.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index e9318f3..e110516 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -170,6 +170,7 @@ syn keyword pythonException try except finally syn keyword pythonOperator and in is not or syn match pythonStatement "^\s*yield\>" display +syn match pythonIdentifier "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") @@ -180,7 +181,7 @@ if s:Python2Syntax() else syn keyword pythonStatement as nonlocal syn match pythonStatement "\" display - syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained + syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained syn keyword pythonStatement await syn match pythonStatement "\" nextgroup=pythonFunction skipwhite syn match pythonStatement "\" display @@ -195,7 +196,6 @@ syn region FunctionParameters start='(' end=')' display contains= \ pythonClassVaraible, \ pythonConditional, \ pythonComment, - \ pythonImport, \ pythonOperator, \ pythonNumber, \ pythonNumberError, @@ -214,7 +214,7 @@ syn region FunctionParameters start='(' end=')' display contains= \ pythonBuiltinObj, \ pythonBuiltinFunc, \ pythonBoolean - \ nextgroup=OptionalParameters + \ nextgroup=OptionalParameters display contained syn match OptionalParameters /\i*\ze=/ display contained " " Decorators (new in Python 2.4) From 3ef357e3bacc3594b85fe5b1eb06277c0264717c Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 21 Nov 2016 16:04:13 +0300 Subject: [PATCH 024/103] keyword arguments highlighted inside of builtin object constructors --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index e110516..469bd40 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -431,7 +431,7 @@ if s:Enabled("g:python_highlight_builtin_objs") syn keyword pythonBuiltinObj None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v(\.)@' + syn match pythonBuiltinObj '\v(\.)@' nextgroup=FunctionParameters syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif From 7d63a53598f6af0ce1780a03d1b58fb67966f6ca Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 23 Nov 2016 12:21:03 +0300 Subject: [PATCH 025/103] highlight yield from as a keyword and await only if it is a keyword --- syntax/python.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index e9318f3..4c3e787 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -168,8 +168,8 @@ syn keyword pythonImport import syn keyword pythonImport from syn keyword pythonException try except finally syn keyword pythonOperator and in is not or +syn match pythonStatement "^\s*yield\>" display -syn match pythonStatement "^\s*yield\>" display if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") @@ -179,9 +179,9 @@ if s:Python2Syntax() syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained else syn keyword pythonStatement as nonlocal - syn match pythonStatement "\" display + syn match pythonStatement "\v\s*" display syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained - syn keyword pythonStatement await + syn match pythonStatement "\v(\.)@" syn match pythonStatement "\" nextgroup=pythonFunction skipwhite syn match pythonStatement "\" display syn match pythonStatement "\" display From 3422bbab29f208ed47479fcb06bffb105c389b80 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 23 Nov 2016 12:22:29 +0300 Subject: [PATCH 026/103] addition --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 4c3e787..deb4475 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -165,7 +165,7 @@ syn keyword pythonConditional if elif else " we provide a dummy group here to avoid crashing pyrex.vim. syn keyword pythonInclude import syn keyword pythonImport import -syn keyword pythonImport from +syn match pythonImport "\(yield \)\@" syn keyword pythonException try except finally syn keyword pythonOperator and in is not or syn match pythonStatement "^\s*yield\>" display From 0a240893e8f6f8c7ba04e8dbcdef2bcf0033290b Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 23 Nov 2016 12:58:23 +0300 Subject: [PATCH 027/103] from highlighted in imports but not in yield from (not sure how this works) --- syntax/python.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 934f5f0..8e18939 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -165,12 +165,12 @@ syn keyword pythonConditional if elif else " we provide a dummy group here to avoid crashing pyrex.vim. syn keyword pythonInclude import syn keyword pythonImport import -syn match pythonImport "\(yield \)\@" +syn keyword pythonImport from syn keyword pythonException try except finally syn keyword pythonOperator and in is not or -syn match pythonStatement "^\s*yield\>" display +syn match pythonStatement "\s*\([.,]\)\@" -syn match pythonIdentifier "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display +syn match pythonIdentifier "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") @@ -180,12 +180,12 @@ if s:Python2Syntax() syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained else syn keyword pythonStatement as nonlocal - syn match pythonStatement "\v\s*" display + syn match pythonStatement "\v\s*" syn match pythonStatement "\v(\.)@" syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained syn match pythonStatement "\" nextgroup=pythonFunction skipwhite - syn match pythonStatement "\" display - syn match pythonStatement "\" display + syn match pythonStatement "\" + syn match pythonStatement "\" endif syn region FunctionParameters start='(' end=')' display contains= From b8f13b83feeff6cce2465f99e94b9da768754d17 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 23 Nov 2016 17:05:44 +0300 Subject: [PATCH 028/103] added keyword arguments highlight to builtin functions --- syntax/python.vim | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 8e18939..f80f848 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -442,27 +442,27 @@ endif if s:Enabled("g:python_highlight_builtin_funcs") if s:Python2Syntax() - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters if s:Enabled("g:python_print_as_function") - syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters endif else - syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters endif - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' - syn match pythonBuiltinFunc '\v(\.)@\ze\(' + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters endif " From 752a19fa976094f827450a91214fac24ef35156b Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Thu, 24 Nov 2016 12:47:29 +0300 Subject: [PATCH 029/103] keyword arguments in decorators --- syntax/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index f80f848..ed09a80 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -222,9 +222,9 @@ syn match OptionalParameters /\i*\ze=/ display contained syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite if s:Python2Syntax() - syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained + syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained nextgroup=FunctionParameters else - syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained + syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained nextgroup=FunctionParameters endif syn match pythonDot "\." display containedin=pythonDottedName From 8db44e7a57efac3975c4e4599654cc680627965f Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Wed, 7 Dec 2016 22:19:28 +0300 Subject: [PATCH 030/103] now from `from import` in highlighted as import and as keyword in `raise from` --- syntax/python.vim | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index ed09a80..0c79997 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -154,7 +154,8 @@ syn keyword pythonInstanceVariable self syn keyword pythonClassVaraible cls syn keyword pythonStatement break continue del syn keyword pythonStatement exec return -syn keyword pythonStatement pass raise +syn keyword pythonStatement pass +syn keyword pythonStatement raise nextgroup=pythonIdentifier skipwhite syn keyword pythonStatement global assert syn keyword pythonStatement lambda syn keyword pythonStatement with @@ -163,14 +164,16 @@ 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 pythonImport from syn keyword pythonException try except finally syn keyword pythonOperator and in is not or syn match pythonStatement "\s*\([.,]\)\@" +syn keyword pythonInclude import +syn keyword pythonImport import +syn match pythonIdentifier "\v[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters +syn match pythonRaiseFromStatement "from\>" +syn match pythonImport "\v^\s*\zsfrom\ze\s*[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*\s*import" + -syn match pythonIdentifier "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters if s:Python2Syntax() if !s:Enabled("g:python_print_as_function") @@ -180,7 +183,7 @@ if s:Python2Syntax() syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained else syn keyword pythonStatement as nonlocal - syn match pythonStatement "\v\s*" + syn match pythonStatement "\v\s*" syn match pythonStatement "\v(\.)@" syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained syn match pythonStatement "\" nextgroup=pythonFunction skipwhite @@ -213,8 +216,7 @@ syn region FunctionParameters start='(' end=')' display contains= \ pythonBytes, \ pythonBuiltinObj, \ pythonBuiltinFunc, - \ pythonBoolean - \ nextgroup=OptionalParameters display contained + \ pythonBoolean nextgroup=pythonRaiseFromStatement display contained syn match OptionalParameters /\i*\ze=/ display contained " " Decorators (new in Python 2.4) @@ -526,6 +528,7 @@ if version >= 508 || !exists("did_python_syn_inits") endif HiLink pythonStatement Statement + HiLink pythonRaiseFromStatement Statement HiLink pythonImport Include HiLink pythonFunction Function HiLink pythonConditional Conditional From 41efca646e4b367effabe1493fbe9501e2cc3c43 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Thu, 8 Dec 2016 12:55:36 +0300 Subject: [PATCH 031/103] simplified rules for yield, yield from, from * import --- syntax/python.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 0c79997..6ddcafa 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -154,7 +154,7 @@ syn keyword pythonInstanceVariable self syn keyword pythonClassVaraible cls syn keyword pythonStatement break continue del syn keyword pythonStatement exec return -syn keyword pythonStatement pass +syn keyword pythonStatement pass yield syn keyword pythonStatement raise nextgroup=pythonIdentifier skipwhite syn keyword pythonStatement global assert syn keyword pythonStatement lambda @@ -171,7 +171,7 @@ syn keyword pythonInclude import syn keyword pythonImport import syn match pythonIdentifier "\v[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters syn match pythonRaiseFromStatement "from\>" -syn match pythonImport "\v^\s*\zsfrom\ze\s*[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*\s*import" +syn match pythonImport "^\s*\zsfrom\>" @@ -183,7 +183,6 @@ if s:Python2Syntax() syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained else syn keyword pythonStatement as nonlocal - syn match pythonStatement "\v\s*" syn match pythonStatement "\v(\.)@" syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained syn match pythonStatement "\" nextgroup=pythonFunction skipwhite From 3685b3116990f273f545d8f98f03d69d22d33c51 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 26 Dec 2016 22:50:05 +0300 Subject: [PATCH 032/103] Exceptions highlighted only if no dot is before them --- syntax/python.vim | 62 ++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 6ddcafa..aebc4ed 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -155,7 +155,7 @@ syn keyword pythonClassVaraible cls syn keyword pythonStatement break continue del syn keyword pythonStatement exec return syn keyword pythonStatement pass yield -syn keyword pythonStatement raise nextgroup=pythonIdentifier skipwhite +syn keyword pythonStatement raise nextgroup=pythonIdentifier,pythonExClass skipwhite syn keyword pythonStatement global assert syn keyword pythonStatement lambda syn keyword pythonStatement with @@ -472,40 +472,36 @@ endif if s:Enabled("g:python_highlight_exceptions") if s:Python2Syntax() - syn keyword pythonExClass StandardError + syn match pythonExClass '\v(\.)@' else - syn keyword pythonExClass BlockingIOError ChildProcessError - syn keyword pythonExClass ConnectionError BrokenPipeError - syn keyword pythonExClass ConnectionAbortedError ConnectionRefusedError - syn keyword pythonExClass ConnectionResetError FileExistsError - syn keyword pythonExClass FileNotFoundError InterruptedError - syn keyword pythonExClass IsADirectoryError NotADirectoryError - syn keyword pythonExClass PermissionError ProcessLookupError TimeoutError - syn keyword pythonExClass StopAsyncIteration - - syn keyword pythonExClass ResourceWarning + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' endif - syn keyword pythonExClass BaseException - syn keyword pythonExClass Exception ArithmeticError - syn keyword pythonExClass LookupError EnvironmentError - - syn keyword pythonExClass AssertionError AttributeError BufferError EOFError - syn keyword pythonExClass FloatingPointError GeneratorExit IOError - syn keyword pythonExClass ImportError IndexError KeyError - syn keyword pythonExClass KeyboardInterrupt MemoryError NameError - syn keyword pythonExClass NotImplementedError OSError OverflowError - syn keyword pythonExClass ReferenceError RuntimeError StopIteration - syn keyword pythonExClass SyntaxError IndentationError TabError - syn keyword pythonExClass SystemError SystemExit TypeError - syn keyword pythonExClass UnboundLocalError UnicodeError - syn keyword pythonExClass UnicodeEncodeError UnicodeDecodeError - syn keyword pythonExClass UnicodeTranslateError ValueError VMSError - syn keyword pythonExClass WindowsError ZeroDivisionError - - syn keyword pythonExClass Warning UserWarning BytesWarning DeprecationWarning - syn keyword pythonExClass PendingDepricationWarning SyntaxWarning - syn keyword pythonExClass RuntimeWarning FutureWarning - syn keyword pythonExClass ImportWarning UnicodeWarning + + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' endif if s:Enabled("g:python_slow_sync") From 023fbd2a4a37f66e8a02f906c0a723cace94e6d9 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Tue, 27 Dec 2016 09:55:01 +0300 Subject: [PATCH 033/103] keyword arguments names highlighted in exception constuctor calls --- syntax/python.vim | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index aebc4ed..94dc9cd 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -472,36 +472,36 @@ endif if s:Enabled("g:python_highlight_exceptions") if s:Python2Syntax() - syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters else - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters endif - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' - syn match pythonExClass '\v(\.)@' + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters endif if s:Enabled("g:python_slow_sync") From 0b6be3fbc805e5dd0b27aeef7e5a9597557b52ff Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Mon, 9 Jan 2017 13:03:47 +0300 Subject: [PATCH 034/103] python 3.6 formatted string literals support --- syntax/python.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 94dc9cd..51df6ee 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -267,6 +267,7 @@ endif if s:Python2Syntax() " Python 2 strings syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+[bB]\="""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell @@ -303,10 +304,10 @@ if s:Python2Syntax() syn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell else " Python 3 strings - syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell - syn region pythonString start=+'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonString start=+f\?'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonString start=+f\?"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonString start=+f\?"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonString start=+f\?'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell endif if s:Python2Syntax() From b4466414b5104437a1dcd7c0ef73ac6811147f22 Mon Sep 17 00:00:00 2001 From: Michael Doronin Date: Thu, 26 Jan 2017 15:41:11 +0300 Subject: [PATCH 035/103] None is highlighted as constant value (which it is in python3) --- syntax/python.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 51df6ee..752ce01 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -214,6 +214,7 @@ syn region FunctionParameters start='(' end=')' display contains= \ pythonRawString, \ pythonBytes, \ pythonBuiltinObj, + \ pythonNone, \ pythonBuiltinFunc, \ pythonBoolean nextgroup=pythonRaiseFromStatement display contained syn match OptionalParameters /\i*\ze=/ display contained @@ -430,7 +431,7 @@ syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display " if s:Enabled("g:python_highlight_builtin_objs") - syn keyword pythonBuiltinObj None + syn keyword pythonNone None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented syn match pythonBuiltinObj '\v(\.)@' nextgroup=FunctionParameters @@ -585,6 +586,7 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonBinError Error HiLink pythonBoolean Boolean + HiLink pythonNone Constant HiLink pythonBuiltinObj Structure HiLink pythonBuiltinFunc Function From bb5058fd7fb79ff5bb1d1efa3a0d6af914610381 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 18:14:13 +0100 Subject: [PATCH 036/103] Update links --- README.rst | 15 +++++---------- syntax/python.vim | 16 ++++++---------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/README.rst b/README.rst index f9cd20d..2ea9fa9 100644 --- a/README.rst +++ b/README.rst @@ -11,13 +11,8 @@ Enhanced version of the original Python syntax highlighting script. Based on ca). Check also `python.vim page on vim.org `_. -Please use the following channels for reporting bugs, offering suggestions or -feedback: - -- python.vim issue tracker: https://github.com/hdima/python-syntax/issues -- Email: Dmitry Vasiliev (dima at hlabs.org) -- Send a message or follow me for updates on Twitter: `@hdima - `__ +Please report bugs and feature requests to our issue tracker over at: +https://github.com/vim-python/python-syntax/issues Features -------- @@ -52,13 +47,13 @@ How to install -------------- The easiest installation method is to place `syntax/python.vim -`_ script +`_ script into your ``~/.vim/syntax/`` directory. You can also use `Pathogen `_ or `Vundle `_ plugin managers in which case you can -install the whole `python.vim repository -`_ into the corresponding plugins +install the whole `repository +`_ into the corresponding plugins directory. Script options diff --git a/syntax/python.vim b/syntax/python.vim index 752ce01..07a78f9 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -1,8 +1,7 @@ " Vim syntax file " Language: Python -" Current Maintainer: Dmitry Vasiliev -" Previous Maintainer: Neil Schemenauer -" URL: https://github.com/hdima/python-syntax +" Current Maintainer: vim-python organization on GitHub +" URL: https://github.com/vim-python/python-syntax " Last Change: 2015-11-01 " Filenames: *.py " Version: 3.6.0 @@ -10,13 +9,8 @@ " Based on python.vim (from Vim 6.1 distribution) " by Neil Schemenauer " -" Please use the following channels for reporting bugs, offering suggestions or -" feedback: - -" - python.vim issue tracker: https://github.com/hdima/python-syntax/issues -" - Email: Dmitry Vasiliev (dima at hlabs.org) -" - Send a message or follow me for updates on Twitter: `@hdima -" `__ +" Please report bugs and feature requests to our issue tracker over at: +" https://github.com/vim-python/python-syntax/issues " " Contributors " ============ @@ -33,7 +27,9 @@ " Jeroen Ruigrok van der Werven " John Eikenberry " Joongi Kim +" lilydjwg " Marc Weber +" Michael Doronin " Pedro Algarvio " Victor Salgado " Will Gray From 20f4848c5d2345d4de5169eec8de1d5c2846d446 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 18:18:32 +0100 Subject: [PATCH 037/103] Remove `folding-ideas` and add link to SimpylFold --- README.rst | 2 + folding-ideas/python.vim.1.13 | 237 ---------------------------------- folding-ideas/python.vim.1.14 | 236 --------------------------------- 3 files changed, 2 insertions(+), 473 deletions(-) delete mode 100644 folding-ideas/python.vim.1.13 delete mode 100644 folding-ideas/python.vim.1.14 diff --git a/README.rst b/README.rst index 2ea9fa9..49c39b5 100644 --- a/README.rst +++ b/README.rst @@ -43,6 +43,8 @@ Changes from the original ``python.vim`` are: Some of these features was later backported into the original ``python.vim``. +Folding is done by the plugin `SimpylFold `_ + How to install -------------- diff --git a/folding-ideas/python.vim.1.13 b/folding-ideas/python.vim.1.13 deleted file mode 100644 index e5ea668..0000000 --- a/folding-ideas/python.vim.1.13 +++ /dev/null @@ -1,237 +0,0 @@ -" Vim syntax file -" Language: Python -" Maintainer: Neil Schemenauer -" Updated: $Date: 2003/01/12 14:17:34 $ -" Updated by: Dmitry Vasiliev -" Filenames: *.py -" $Revision: 1.13 $ -" -" Options: -" For folded functions and classes: -" -" let python_folding = 1 -" -" For highlighted builtin functions: -" -" let python_highlight_builtins = 1 -" -" For highlighted standard exceptions: -" -" let python_highlight_exceptions = 1 -" -" For highlighted string formatting: -" -" let python_highlight_string_formatting = 1 -" -" If you want all possible Python highlighting: -" -" let python_highlight_all = 1 -" -" TODO: Check more errors? - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -if exists("python_highlight_all") - let python_folding = 1 - let python_highlight_builtins = 1 - let python_highlight_exceptions = 1 - let python_highlight_string_formatting = 1 -endif - -" Keywords -syn keyword pythonStatement break continue del -syn keyword pythonStatement exec return -syn keyword pythonStatement pass print raise -syn keyword pythonStatement global assert -syn keyword pythonStatement lambda yield -if exists("python_folding") && has("folding") - syn match pythonStatement "\<\(def\|class\)\>" display nextgroup=pythonFunction skipwhite -else - syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite -endif -syn match pythonFunction "\h\w*" display contained -syn keyword pythonRepeat for while -syn keyword pythonConditional if elif else -syn keyword pythonImport import from as -syn keyword pythonException try except finally -syn keyword pythonOperator and in is not or - -" Comments -syn match pythonComment "#.*$" display contains=pythonTodo -syn keyword pythonTodo TODO FIXME XXX contained - -" Erroneous characters that cannont be in a python program -syn match pythonError "[@$?]" display -" Mixing spaces and tabs is bad -syn match pythonIndentError "^\s*\(\t \| \t\)\s*" display - -" Strings -syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonEscape,pythonEscapeError -syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonEscape,pythonEscapeError -syn region pythonString start=+"""+ end=+"""+ contains=pythonEscape,pythonEscapeError -syn region pythonString start=+'''+ end=+'''+ contains=pythonEscape,pythonEscapeError - -syn match pythonEscape +\\[abfnrtv'"\\]+ display contained -syn match pythonEscapeError +\\[^abfnrtv'"\\]+ display contained -syn match pythonEscape "\\\o\o\=\o\=" display contained -syn match pythonEscapeError "\\\o\{,2}[89]" display contained -syn match pythonEscape "\\x\x\{2}" display contained -syn match pythonEscapeError "\\x\x\=\X" display contained -syn match pythonEscape "\\$" - -" Unicode strings -syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError -syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError -syn region pythonUniString start=+[uU]"""+ end=+"""+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError -syn region pythonUniString start=+[uU]'''+ end=+'''+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError - -syn match pythonUniEscape "\\u\x\{4}" display contained -syn match pythonUniEscapeError "\\u\x\{,3}\X" display contained -syn match pythonUniEscape "\\U\x\{8}" display contained -syn match pythonUniEscapeError "\\U\x\{,7}\X" display contained -syn match pythonUniEscape "\\N{[A-Z ]\+}" display contained -syn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained - -" Raw strings -syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonRawEscape -syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonRawEscape -syn region pythonRawString start=+[rR]"""+ end=+"""+ -syn region pythonRawString start=+[rR]'''+ end=+'''+ - -syn match pythonRawEscape +\\['"]+ display transparent contained - -" Unicode raw strings -syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError -syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError -syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ contains=pythonUniRawEscape,pythonUniRawEscapeError -syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ contains=pythonUniRawEscape,pythonUniRawEscapeError - -syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained -syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained - -if exists("python_highlight_string_formatting") - " String formatting - syn match pythonStrFormat "%\(([^)]\+)\)\=[-#0 +]\=\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString - syn match pythonStrFormat "%[-#0 +]\=\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString -endif - -" Numbers (ints, longs, floats, complex) -syn match pythonNumber "\<0[xX]\x\+[lL]\=\>" display -syn match pythonNumber "\<\d\+[lLjJ]\=\>" display -syn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display -syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display -syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display -syn match pythonOctalError "\<0\o*[89]\d*[lLjJ]\=\>" display - -if exists("python_highlight_builtins") - " Builtin functions, types and objects, not really part of the syntax - syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented - syn keyword pythonBuiltinFunc bool __import__ abs - syn keyword pythonBuiltinFunc apply buffer callable chr classmethod cmp - syn keyword pythonBuiltinFunc coerce compile complex delattr dict dir divmod - syn keyword pythonBuiltinFunc eval execfile file filter float getattr globals - syn keyword pythonBuiltinFunc hasattr hash hex id input int intern isinstance - syn keyword pythonBuiltinFunc issubclass iter len list locals long map max - syn keyword pythonBuiltinFunc min object oct open ord pow property range - syn keyword pythonBuiltinFunc raw_input reduce reload repr round setattr - syn keyword pythonBuiltinFunc slice staticmethod str super tuple type unichr - syn keyword pythonBuiltinFunc unicode vars xrange zip -endif - -if exists("python_highlight_exceptions") - " Builtin exceptions and warnings - syn keyword pythonExClass ArithmeticError AssertionError AttributeError - syn keyword pythonExClass DeprecationWarning EOFError EnvironmentError - syn keyword pythonExClass Exception FloatingPointError IOError - syn keyword pythonExClass ImportError IndentiationError IndexError - syn keyword pythonExClass KeyError KeyboardInterrupt LookupError - syn keyword pythonExClass MemoryError NameError NotImplementedError - syn keyword pythonExClass OSError OverflowError OverflowWarning - syn keyword pythonExClass ReferenceError RuntimeError RuntimeWarning - syn keyword pythonExClass StandardError StopIteration SyntaxError - syn keyword pythonExClass SyntaxWarning SystemError SystemExit TabError - syn keyword pythonExClass TypeError UnboundLocalError UnicodeError - syn keyword pythonExClass UserWarning ValueError Warning WindowsError - syn keyword pythonExClass ZeroDivisionError -endif - -syn sync clear -if exists("python_folding") && has("folding") - syn sync fromstart - - "syn match pythonFold "^\(\s*\)\(class\|def\)\s.*\(\(\n\s*\)*\n\1\s\+\S.*\)\+" transparent fold - syn region pythonFold start="^\z(\s*\)\(class\|def\)\s" skip="^\z1\s\+\S" end="^\s*\S"me=s-1 transparent fold - syn region pythonFold start="{" end="}" transparent fold - syn region pythonFold start="\[" end="\]" transparent fold -else - " This is fast but code inside triple quoted strings screws it up. It - " is impossible to fix because the only way to know if you are inside a - " triple quoted string is to start from the beginning of the file. If - " you have a fast machine you can try uncommenting the "sync minlines" - " and commenting out the rest. - syn sync match pythonSync grouphere NONE "):$" - syn sync maxlines=200 - "syn sync minlines=2000 -endif - -if version >= 508 || !exists("did_python_syn_inits") - if version <= 508 - let did_python_syn_inits = 1 - command -nargs=+ HiLink hi link - else - command -nargs=+ HiLink hi def link - endif - - HiLink pythonStatement Statement - HiLink pythonImport Statement - HiLink pythonFunction Function - HiLink pythonConditional Conditional - HiLink pythonRepeat Repeat - HiLink pythonException Exception - HiLink pythonOperator Operator - - HiLink pythonComment Comment - HiLink pythonTodo Todo - - HiLink pythonError Error - HiLink pythonIndentError Error - - HiLink pythonString String - HiLink pythonUniString String - HiLink pythonRawString String - HiLink pythonUniRawString String - - HiLink pythonEscape Special - HiLink pythonEscapeError Error - HiLink pythonUniEscape Special - HiLink pythonUniEscapeError Error - HiLink pythonUniRawEscape Special - HiLink pythonUniRawEscapeError Error - - if exists("python_highlight_string_formatting") - HiLink pythonStrFormat Special - endif - - HiLink pythonNumber Number - HiLink pythonFloat Float - HiLink pythonOctalError Error - - if exists("python_highlight_builtins") - HiLink pythonBuiltinObj Structure - HiLink pythonBuiltinFunc Function - endif - - if exists("python_highlight_exceptions") - HiLink pythonExClass Structure - endif - - delcommand HiLink -endif - -let b:current_syntax = "python" diff --git a/folding-ideas/python.vim.1.14 b/folding-ideas/python.vim.1.14 deleted file mode 100644 index 9027838..0000000 --- a/folding-ideas/python.vim.1.14 +++ /dev/null @@ -1,236 +0,0 @@ -" Vim syntax file -" Language: Python -" Maintainer: Neil Schemenauer -" Updated: $Date: 2003/01/12 15:35:02 $ -" Updated by: Dmitry Vasiliev -" Filenames: *.py -" $Revision: 1.14 $ -" -" Options: -" For folded functions and classes: -" -" let python_folding = 1 -" -" For highlighted builtin functions: -" -" let python_highlight_builtins = 1 -" -" For highlighted standard exceptions: -" -" let python_highlight_exceptions = 1 -" -" For highlighted string formatting: -" -" let python_highlight_string_formatting = 1 -" -" If you want all possible Python highlighting: -" -" let python_highlight_all = 1 -" -" TODO: Check more errors? - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -if exists("python_highlight_all") - let python_folding = 1 - let python_highlight_builtins = 1 - let python_highlight_exceptions = 1 - let python_highlight_string_formatting = 1 -endif - -" Keywords -syn keyword pythonStatement break continue del -syn keyword pythonStatement exec return -syn keyword pythonStatement pass print raise -syn keyword pythonStatement global assert -syn keyword pythonStatement lambda yield -if exists("python_folding") && has("folding") - syn match pythonStatement "\<\(def\|class\)\>" display nextgroup=pythonFunction skipwhite -else - syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite -endif -syn match pythonFunction "\h\w*" display contained -syn keyword pythonRepeat for while -syn keyword pythonConditional if elif else -syn keyword pythonImport import from as -syn keyword pythonException try except finally -syn keyword pythonOperator and in is not or - -" Comments -syn match pythonComment "#.*$" display contains=pythonTodo -syn keyword pythonTodo TODO FIXME XXX contained - -" Erroneous characters that cannont be in a python program -syn match pythonError "[@$?]" display -" Mixing spaces and tabs is bad -syn match pythonError "^\s*\(\t \| \t\)\s*" display - -" Strings -syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonEscape,pythonEscapeError -syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonEscape,pythonEscapeError -syn region pythonString start=+"""+ end=+"""+ contains=pythonEscape,pythonEscapeError -syn region pythonString start=+'''+ end=+'''+ contains=pythonEscape,pythonEscapeError - -syn match pythonEscape +\\[abfnrtv'"\\]+ display contained -syn match pythonEscapeError +\\[^abfnrtv'"\\]+ display contained -syn match pythonEscape "\\\o\o\=\o\=" display contained -syn match pythonEscapeError "\\\o\{,2}[89]" display contained -syn match pythonEscape "\\x\x\{2}" display contained -syn match pythonEscapeError "\\x\x\=\X" display contained -syn match pythonEscape "\\$" - -" Unicode strings -syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError -syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError -syn region pythonUniString start=+[uU]"""+ end=+"""+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError -syn region pythonUniString start=+[uU]'''+ end=+'''+ contains=pythonEscape,pythonUniEscape,pythonEscapeError,pythonUniEscapeError - -syn match pythonUniEscape "\\u\x\{4}" display contained -syn match pythonUniEscapeError "\\u\x\{,3}\X" display contained -syn match pythonUniEscape "\\U\x\{8}" display contained -syn match pythonUniEscapeError "\\U\x\{,7}\X" display contained -syn match pythonUniEscape "\\N{[A-Z ]\+}" display contained -syn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained - -" Raw strings -syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonRawEscape -syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonRawEscape -syn region pythonRawString start=+[rR]"""+ end=+"""+ -syn region pythonRawString start=+[rR]'''+ end=+'''+ - -syn match pythonRawEscape +\\['"]+ display transparent contained - -" Unicode raw strings -syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError -syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError -syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ contains=pythonUniRawEscape,pythonUniRawEscapeError -syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ contains=pythonUniRawEscape,pythonUniRawEscapeError - -syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained -syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained - -if exists("python_highlight_string_formatting") - " String formatting - syn match pythonStrFormat "%\(([^)]\+)\)\=[-#0 +]\=\d*\(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString - syn match pythonStrFormat "%[-#0 +]\=\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString -endif - -" Numbers (ints, longs, floats, complex) -syn match pythonNumber "\<0[xX]\x\+[lL]\=\>" display -syn match pythonNumber "\<\d\+[lLjJ]\=\>" display -syn match pythonFloat "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>" display -syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display -syn match pythonFloat "\<\d\+\.\d*\([eE][+-]\=\d\+\)\=[jJ]\=" display -syn match pythonOctalError "\<0\o*[89]\d*[lLjJ]\=\>" display - -if exists("python_highlight_builtins") - " Builtin functions, types and objects, not really part of the syntax - syn keyword pythonBuiltinObj True False Ellipsis None NotImplemented - syn keyword pythonBuiltinFunc bool __import__ abs - syn keyword pythonBuiltinFunc apply buffer callable chr classmethod cmp - syn keyword pythonBuiltinFunc coerce compile complex delattr dict dir divmod - syn keyword pythonBuiltinFunc eval execfile file filter float getattr globals - syn keyword pythonBuiltinFunc hasattr hash hex id input int intern isinstance - syn keyword pythonBuiltinFunc issubclass iter len list locals long map max - syn keyword pythonBuiltinFunc min object oct open ord pow property range - syn keyword pythonBuiltinFunc raw_input reduce reload repr round setattr - syn keyword pythonBuiltinFunc slice staticmethod str super tuple type unichr - syn keyword pythonBuiltinFunc unicode vars xrange zip -endif - -if exists("python_highlight_exceptions") - " Builtin exceptions and warnings - syn keyword pythonExClass ArithmeticError AssertionError AttributeError - syn keyword pythonExClass DeprecationWarning EOFError EnvironmentError - syn keyword pythonExClass Exception FloatingPointError IOError - syn keyword pythonExClass ImportError IndentiationError IndexError - syn keyword pythonExClass KeyError KeyboardInterrupt LookupError - syn keyword pythonExClass MemoryError NameError NotImplementedError - syn keyword pythonExClass OSError OverflowError OverflowWarning - syn keyword pythonExClass ReferenceError RuntimeError RuntimeWarning - syn keyword pythonExClass StandardError StopIteration SyntaxError - syn keyword pythonExClass SyntaxWarning SystemError SystemExit TabError - syn keyword pythonExClass TypeError UnboundLocalError UnicodeError - syn keyword pythonExClass UserWarning ValueError Warning WindowsError - syn keyword pythonExClass ZeroDivisionError -endif - -syn sync clear -if exists("python_folding") && has("folding") - syn sync fromstart - - "syn match pythonFold "^\(\s*\)\(class\|def\)\s.*\(\(\n\s*\)*\n\1\s\+\S.*\)\+" transparent fold - syn region pythonFold start="^\z(\s*\)\(class\|def\)\s" skip="\(\s*\n\)\+\z1\s\+\(\S\|\%$\)" end="\(\s*\n\)\+\s*\(\S\|\%$\)"me=s-1 transparent fold - syn region pythonFold start="{" end="}" transparent fold - syn region pythonFold start="\[" end="\]" transparent fold -else - " This is fast but code inside triple quoted strings screws it up. It - " is impossible to fix because the only way to know if you are inside a - " triple quoted string is to start from the beginning of the file. If - " you have a fast machine you can try uncommenting the "sync minlines" - " and commenting out the rest. - syn sync match pythonSync grouphere NONE "):$" - syn sync maxlines=200 - "syn sync minlines=2000 -endif - -if version >= 508 || !exists("did_python_syn_inits") - if version <= 508 - let did_python_syn_inits = 1 - command -nargs=+ HiLink hi link - else - command -nargs=+ HiLink hi def link - endif - - HiLink pythonStatement Statement - HiLink pythonImport Statement - HiLink pythonFunction Function - HiLink pythonConditional Conditional - HiLink pythonRepeat Repeat - HiLink pythonException Exception - HiLink pythonOperator Operator - - HiLink pythonComment Comment - HiLink pythonTodo Todo - - HiLink pythonError Error - - HiLink pythonString String - HiLink pythonUniString String - HiLink pythonRawString String - HiLink pythonUniRawString String - - HiLink pythonEscape Special - HiLink pythonEscapeError Error - HiLink pythonUniEscape Special - HiLink pythonUniEscapeError Error - HiLink pythonUniRawEscape Special - HiLink pythonUniRawEscapeError Error - - if exists("python_highlight_string_formatting") - HiLink pythonStrFormat Special - endif - - HiLink pythonNumber Number - HiLink pythonFloat Float - HiLink pythonOctalError Error - - if exists("python_highlight_builtins") - HiLink pythonBuiltinObj Structure - HiLink pythonBuiltinFunc Function - endif - - if exists("python_highlight_exceptions") - HiLink pythonExClass Structure - endif - - delcommand HiLink -endif - -let b:current_syntax = "python" From 94baf90c530d95f7bd96c6379f55e6927ec41bf3 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 18:18:59 +0100 Subject: [PATCH 038/103] Move tests into `tests` directory --- test.py => tests/test.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test.py => tests/test.py (100%) diff --git a/test.py b/tests/test.py similarity index 100% rename from test.py rename to tests/test.py From dec4b0814e7cc6f025474088dc92422672f84ea3 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 18:39:19 +0100 Subject: [PATCH 039/103] linting with vint --- .vintrc.yaml | 3 + syntax/python.vim | 298 +++++++++++++++++++++++----------------------- 2 files changed, 152 insertions(+), 149 deletions(-) create mode 100644 .vintrc.yaml diff --git a/.vintrc.yaml b/.vintrc.yaml new file mode 100644 index 0000000..b371660 --- /dev/null +++ b/.vintrc.yaml @@ -0,0 +1,3 @@ +policies: + ProhibitImplicitScopeVariable: + enabled: false diff --git a/syntax/python.vim b/syntax/python.vim index 07a78f9..97959b3 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -88,9 +88,9 @@ " For version 5.x: Clear all syntax items " For versions greater than 6.x: Quit when a syntax file was already loaded -if version < 600 +if v:version < 600 syntax clear -elseif exists("b:current_syntax") +elseif exists('b:current_syntax') finish endif @@ -114,32 +114,32 @@ endfunction " Is it Python 2 syntax? function! s:Python2Syntax() - if exists("b:python_version_2") + if exists('b:python_version_2') return b:python_version_2 endif - return s:Enabled("g:python_version_2") + return s:Enabled('g:python_version_2') endfunction " " Default options " -call s:EnableByDefault("g:python_slow_sync") +call s:EnableByDefault('g:python_slow_sync') -if s:Enabled("g:python_highlight_all") - call s:EnableByDefault("g:python_highlight_builtins") - if s:Enabled("g:python_highlight_builtins") - call s:EnableByDefault("g:python_highlight_builtin_objs") - call s:EnableByDefault("g:python_highlight_builtin_funcs") +if s:Enabled('g:python_highlight_all') + call s:EnableByDefault('g:python_highlight_builtins') + if s:Enabled('g:python_highlight_builtins') + call s:EnableByDefault('g:python_highlight_builtin_objs') + call s:EnableByDefault('g:python_highlight_builtin_funcs') endif - call s:EnableByDefault("g:python_highlight_exceptions") - call s:EnableByDefault("g:python_highlight_string_formatting") - call s:EnableByDefault("g:python_highlight_string_format") - call s:EnableByDefault("g:python_highlight_string_templates") - call s:EnableByDefault("g:python_highlight_indent_errors") - call s:EnableByDefault("g:python_highlight_space_errors") - call s:EnableByDefault("g:python_highlight_doctests") - call s:EnableByDefault("g:python_print_as_function") + call s:EnableByDefault('g:python_highlight_exceptions') + call s:EnableByDefault('g:python_highlight_string_formatting') + call s:EnableByDefault('g:python_highlight_string_format') + call s:EnableByDefault('g:python_highlight_string_templates') + call s:EnableByDefault('g:python_highlight_indent_errors') + call s:EnableByDefault('g:python_highlight_space_errors') + call s:EnableByDefault('g:python_highlight_doctests') + call s:EnableByDefault('g:python_print_as_function') endif " @@ -162,28 +162,28 @@ syn keyword pythonConditional if elif else " we provide a dummy group here to avoid crashing pyrex.vim. syn keyword pythonException try except finally syn keyword pythonOperator and in is not or -syn match pythonStatement "\s*\([.,]\)\@" +syn match pythonStatement '\s*\([.,]\)\@' syn keyword pythonInclude import syn keyword pythonImport import -syn match pythonIdentifier "\v[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters -syn match pythonRaiseFromStatement "from\>" -syn match pythonImport "^\s*\zsfrom\>" +syn match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters +syn match pythonRaiseFromStatement 'from\>' +syn match pythonImport '^\s*\zsfrom\>' if s:Python2Syntax() - if !s:Enabled("g:python_print_as_function") + if !s:Enabled('g:python_print_as_function') syn keyword pythonStatement print endif syn keyword pythonImport as - syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained + syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters display contained else syn keyword pythonStatement as nonlocal - syn match pythonStatement "\v(\.)@" - syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" nextgroup=FunctionParameters display contained - syn match pythonStatement "\" nextgroup=pythonFunction skipwhite - syn match pythonStatement "\" - syn match pythonStatement "\" + syn match pythonStatement '\v(\.)@' + syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters display contained + syn match pythonStatement '\' nextgroup=pythonFunction skipwhite + syn match pythonStatement '\' + syn match pythonStatement '\' endif syn region FunctionParameters start='(' end=')' display contains= @@ -218,43 +218,43 @@ syn match OptionalParameters /\i*\ze=/ display contained " Decorators (new in Python 2.4) " -syn match pythonDecorator "@" display nextgroup=pythonDottedName skipwhite +syn match pythonDecorator '@' display nextgroup=pythonDottedName skipwhite if s:Python2Syntax() - syn match pythonDottedName "[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*" display contained nextgroup=FunctionParameters + syn match pythonDottedName '[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*' display contained nextgroup=FunctionParameters else - syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained nextgroup=FunctionParameters + syn match pythonDottedName '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*' display contained nextgroup=FunctionParameters endif -syn match pythonDot "\." display containedin=pythonDottedName +syn match pythonDot '\.' display containedin=pythonDottedName " " Comments " -syn match pythonComment "#.*$" display contains=pythonTodo,@Spell -if !s:Enabled("g:python_highlight_file_headers_as_comments") - syn match pythonRun "\%^#!.*$" - syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" +syn match pythonComment '#.*$' display contains=pythonTodo,@Spell +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 +syn keyword pythonTodo TODO FIXME XXX contained " " Errors " -syn match pythonError "\<\d\+\D\+\>" display -syn match pythonError "[$?]" display -syn match pythonError "[&|]\{2,}" display -syn match pythonError "[=]\{3,}" display +syn match pythonError '\<\d\+\D\+\>' display +syn match pythonError '[$?]' display +syn match pythonError '[&|]\{2,}' display +syn match pythonError '[=]\{3,}' display " Mixing spaces and tabs also may be used for pretty formatting multiline " statements -if s:Enabled("g:python_highlight_indent_errors") - syn match pythonIndentError "^\s*\%( \t\|\t \)\s*\S"me=e-1 display +if s:Enabled('g:python_highlight_indent_errors') + syn match pythonIndentError '^\s*\%( \t\|\t \)\s*\S'me=e-1 display endif " Trailing space errors -if s:Enabled("g:python_highlight_space_errors") - syn match pythonSpaceError "\s\+$" display +if s:Enabled('g:python_highlight_space_errors') + syn match pythonSpaceError '\s\+$' display endif " @@ -270,28 +270,28 @@ if s:Python2Syntax() syn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell else " Python 3 byte strings - syn region pythonBytes start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell - syn region pythonBytes start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell - syn region pythonBytes start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell - syn region pythonBytes start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell + syn region pythonBytes start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell + syn region pythonBytes start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell + syn region pythonBytes start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonBytes start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell - syn match pythonBytesError ".\+" display contained - syn match pythonBytesContent "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError + syn match pythonBytesError '.\+' display contained + syn match pythonBytesContent '[\u0000-\u00ff]\+' display contained contains=pythonBytesEscape,pythonBytesEscapeError endif syn match pythonBytesEscape +\\[abfnrtv'"\\]+ display contained -syn match pythonBytesEscape "\\\o\o\=\o\=" display contained -syn match pythonBytesEscapeError "\\\o\{,2}[89]" display contained -syn match pythonBytesEscape "\\x\x\{2}" display contained -syn match pythonBytesEscapeError "\\x\x\=\X" display contained -syn match pythonBytesEscape "\\$" - -syn match pythonUniEscape "\\u\x\{4}" display contained -syn match pythonUniEscapeError "\\u\x\{,3}\X" display contained -syn match pythonUniEscape "\\U\x\{8}" display contained -syn match pythonUniEscapeError "\\U\x\{,7}\X" display contained -syn match pythonUniEscape "\\N{[A-Z ]\+}" display contained -syn match pythonUniEscapeError "\\N{[^A-Z ]\+}" display contained +syn match pythonBytesEscape '\\\o\o\=\o\=' display contained +syn match pythonBytesEscapeError '\\\o\{,2}[89]' display contained +syn match pythonBytesEscape '\\x\x\{2}' display contained +syn match pythonBytesEscapeError '\\x\x\=\X' display contained +syn match pythonBytesEscape '\\$' + +syn match pythonUniEscape '\\u\x\{4}' display contained +syn match pythonUniEscapeError '\\u\x\{,3}\X' display contained +syn match pythonUniEscape '\\U\x\{8}' display contained +syn match pythonUniEscapeError '\\U\x\{,7}\X' display contained +syn match pythonUniEscape '\\N{[A-Z ]\+}' display contained +syn match pythonUniEscapeError '\\N{[^A-Z ]\+}' display contained if s:Python2Syntax() " Python 2 Unicode strings @@ -314,8 +314,8 @@ if s:Python2Syntax() syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell - syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained - syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained + syn match pythonUniRawEscape '\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}' display contained + syn match pythonUniRawEscapeError '\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X' display contained endif " Python 2/3 raw strings @@ -338,45 +338,45 @@ endif syn match pythonRawEscape +\\['"]+ display transparent contained -if s:Enabled("g:python_highlight_string_formatting") +if s:Enabled('g:python_highlight_string_formatting') " % operator string formatting if s:Python2Syntax() - syn match pythonStrFormatting "%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString - syn match pythonStrFormatting "%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else - syn match pythonStrFormatting "%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString - syn match pythonStrFormatting "%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonRawString + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString endif endif -if s:Enabled("g:python_highlight_string_format") +if s:Enabled('g:python_highlight_string_format') " str.format syntax if s:Python2Syntax() - syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString - syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrFormat '{{\|}}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else - syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString - syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString + syn match pythonStrFormat '{{\|}}' contained containedin=pythonString,pythonRawString + syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonRawString endif endif -if s:Enabled("g:python_highlight_string_templates") +if s:Enabled('g:python_highlight_string_templates') " string.Template format if s:Python2Syntax() - syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString - syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString - syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrTemplate '\$\$' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrTemplate '\${[a-zA-Z_][a-zA-Z0-9_]*}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrTemplate '\$[a-zA-Z_][a-zA-Z0-9_]*' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else - syn match pythonStrTemplate "\$\$" contained containedin=pythonString,pythonRawString - syn match pythonStrTemplate "\${[a-zA-Z_][a-zA-Z0-9_]*}" contained containedin=pythonString,pythonRawString - syn match pythonStrTemplate "\$[a-zA-Z_][a-zA-Z0-9_]*" contained containedin=pythonString,pythonRawString + syn match pythonStrTemplate '\$\$' contained containedin=pythonString,pythonRawString + syn match pythonStrTemplate '\${[a-zA-Z_][a-zA-Z0-9_]*}' contained containedin=pythonString,pythonRawString + syn match pythonStrTemplate '\$[a-zA-Z_][a-zA-Z0-9_]*' contained containedin=pythonString,pythonRawString endif endif -if s:Enabled("g:python_highlight_doctests") +if s:Enabled('g:python_highlight_doctests') " DocTests - syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained - syn region pythonDocTest2 start="^\s*>>>" end=+"""+he=s-1 end="^\s*$" contained + syn region pythonDocTest start='^\s*>>>' end=+'''+he=s-1 end='^\s*$' contained + syn region pythonDocTest2 start='^\s*>>>' end=+"""+he=s-1 end='^\s*$' contained endif " @@ -384,91 +384,91 @@ endif " if s:Python2Syntax() - syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\+\x*[lL]\=\>" display - syn match pythonOctError "\<0[oO]\=\o*\D\+\d*[lL]\=\>" display - syn match pythonBinError "\<0[bB][01]*\D\+\d*[lL]\=\>" display + syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\+\x*[lL]\=\>' display + syn match pythonOctError '\<0[oO]\=\o*\D\+\d*[lL]\=\>' display + syn match pythonBinError '\<0[bB][01]*\D\+\d*[lL]\=\>' display - syn match pythonHexNumber "\<0[xX]\x\+[lL]\=\>" display - syn match pythonOctNumber "\<0[oO]\o\+[lL]\=\>" display - syn match pythonBinNumber "\<0[bB][01]\+[lL]\=\>" display + syn match pythonHexNumber '\<0[xX]\x\+[lL]\=\>' display + syn match pythonOctNumber '\<0[oO]\o\+[lL]\=\>' display + syn match pythonBinNumber '\<0[bB][01]\+[lL]\=\>' display - syn match pythonNumberError "\<\d\+\D[lL]\=\>" display - syn match pythonNumber "\<\d[lL]\=\>" display - syn match pythonNumber "\<[0-9]\d\+[lL]\=\>" display - syn match pythonNumber "\<\d\+[lLjJ]\>" display + syn match pythonNumberError '\<\d\+\D[lL]\=\>' display + syn match pythonNumber '\<\d[lL]\=\>' display + syn match pythonNumber '\<[0-9]\d\+[lL]\=\>' display + syn match pythonNumber '\<\d\+[lLjJ]\>' display - syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*[lL]\=\>" display - syn match pythonBinError "\<0[bB][01]*[2-9]\d*[lL]\=\>" display + syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*[lL]\=\>' display + syn match pythonBinError '\<0[bB][01]*[2-9]\d*[lL]\=\>' display else - syn match pythonHexError "\<0[xX]\x*[g-zG-Z]\x*\>" display - syn match pythonOctError "\<0[oO]\=\o*\D\+\d*\>" display - syn match pythonBinError "\<0[bB][01]*\D\+\d*\>" display - - syn match pythonHexNumber "\<0[xX]\x\+\>" display - syn match pythonOctNumber "\<0[oO]\o\+\>" display - syn match pythonBinNumber "\<0[bB][01]\+\>" display - - syn match pythonNumberError "\<\d\+\D\>" display - syn match pythonNumberError "\<0\d\+\>" display - syn match pythonNumber "\<\d\>" display - syn match pythonNumber "\<[1-9]\d\+\>" display - syn match pythonNumber "\<\d\+[jJ]\>" display - - syn match pythonOctError "\<0[oO]\=\o*[8-9]\d*\>" display - syn match pythonBinError "\<0[bB][01]*[2-9]\d*\>" display + syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display + syn match pythonOctError '\<0[oO]\=\o*\D\+\d*\>' display + syn match pythonBinError '\<0[bB][01]*\D\+\d*\>' display + + syn match pythonHexNumber '\<0[xX]\x\+\>' display + syn match pythonOctNumber '\<0[oO]\o\+\>' display + syn match pythonBinNumber '\<0[bB][01]\+\>' display + + syn match pythonNumberError '\<\d\+\D\>' display + syn match pythonNumberError '\<0\d\+\>' display + syn match pythonNumber '\<\d\>' display + syn match pythonNumber '\<[1-9]\d\+\>' display + syn match pythonNumber '\<\d\+[jJ]\>' display + + syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*\>' display + syn match pythonBinError '\<0[bB][01]*[2-9]\d*\>' display endif -syn match pythonFloat "\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>" display -syn match pythonFloat "\<\d\+[eE][+-]\=\d\+[jJ]\=\>" display -syn match pythonFloat "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=" display +syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display +syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display +syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display " " Builtin objects and types " -if s:Enabled("g:python_highlight_builtin_objs") +if s:Enabled('g:python_highlight_builtin_objs') syn keyword pythonNone None - syn keyword pythonBoolean True False - syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v(\.)@' nextgroup=FunctionParameters - syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ - syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ + syn keyword pythonBoolean True False + syn keyword pythonBuiltinObj Ellipsis NotImplemented + syn match pythonBuiltinObj '\v(\.)@' nextgroup=FunctionParameters + syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ + syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif " " Builtin functions " -if s:Enabled("g:python_highlight_builtin_funcs") +if s:Enabled('g:python_highlight_builtin_funcs') if s:Python2Syntax() - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - if s:Enabled("g:python_print_as_function") - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + if s:Enabled('g:python_print_as_function') + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters endif else - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters endif - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters endif " " Builtin exceptions and warnings " -if s:Enabled("g:python_highlight_exceptions") +if s:Enabled('g:python_highlight_exceptions') if s:Python2Syntax() syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters else @@ -502,18 +502,18 @@ if s:Enabled("g:python_highlight_exceptions") syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters endif -if s:Enabled("g:python_slow_sync") +if s:Enabled('g:python_slow_sync') syn sync minlines=2000 else " This is fast but code inside triple quoted strings screws it up. It " is impossible to fix because the only way to know if you are inside a " triple quoted string is to start from the beginning of the file. - syn sync match pythonSync grouphere NONE "):$" + syn sync match pythonSync grouphere NONE '):$' syn sync maxlines=200 endif -if version >= 508 || !exists("did_python_syn_inits") - if version <= 508 +if v:version >= 508 || !exists('did_python_syn_inits') + if v:version <= 508 let did_python_syn_inits = 1 command -nargs=+ HiLink hi link else @@ -534,7 +534,7 @@ if version >= 508 || !exists("did_python_syn_inits") HiLink pythonDot Normal HiLink pythonComment Comment - if !s:Enabled("g:python_highlight_file_headers_as_comments") + if !s:Enabled('g:python_highlight_file_headers_as_comments') HiLink pythonCoding Special HiLink pythonRun Special endif @@ -595,4 +595,4 @@ if version >= 508 || !exists("did_python_syn_inits") delcommand HiLink endif -let b:current_syntax = "python" +let b:current_syntax = 'python' From b3c219a6e21d08a36e200ea19097e843adf63e5d Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 18:48:56 +0100 Subject: [PATCH 040/103] Add `AUTHORS` file --- AUTHORS | 25 +++++++++++++++++++++++++ LICENSE | 1 + syntax/python.vim | 23 ----------------------- 3 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..d974e01 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,25 @@ +# This is the list of python-syntax authors for copyright purposes. +# +# This does not necessarily list everyone who has contributed code, since in +# some cases, their employer may be the copyright holder. To see the full list +# of contributors, see the revision history in source control. + +Andrea Riciputi +Anton Butanaev +Antony Lee +Caleb Adamantine +David Briscoe +Dmitry Vasiliev +Elizabeth Myers +Ihor Gorobets +Jeroen Ruigrok van der Werven +John Eikenberry +Joongi Kim +lilydjwg +Marc Weber +Michael Doronin +Neil Schemenauer +Pedro Algarvio +Victor Salgado +Will Gray +Yuri Habrusiev diff --git a/LICENSE b/LICENSE index 348583e..bcaa459 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ The MIT License (MIT) Copyright (c) 2002-2014 Dmitry Vasiliev +Copyright (c) 2017- the python-syntax authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/syntax/python.vim b/syntax/python.vim index 97959b3..ec36042 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -12,29 +12,6 @@ " Please report bugs and feature requests to our issue tracker over at: " https://github.com/vim-python/python-syntax/issues " -" Contributors -" ============ -" -" List of the contributors in alphabetical order: -" -" Andrea Riciputi -" Anton Butanaev -" Antony Lee -" Caleb Adamantine -" David Briscoe -" Elizabeth Myers -" Ihor Gorobets -" Jeroen Ruigrok van der Werven -" John Eikenberry -" Joongi Kim -" lilydjwg -" Marc Weber -" Michael Doronin -" Pedro Algarvio -" Victor Salgado -" Will Gray -" Yuri Habrusiev -" " Options " ======= " From 96e84a46b03b0f96eb58edb2c990f473709626cb Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 19:17:41 +0100 Subject: [PATCH 041/103] AUTHORS: Remove non-author --- AUTHORS | 1 - 1 file changed, 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index d974e01..507400a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -15,7 +15,6 @@ Ihor Gorobets Jeroen Ruigrok van der Werven John Eikenberry Joongi Kim -lilydjwg Marc Weber Michael Doronin Neil Schemenauer From 80da95bd41258828c79fbfcfa29e35866bc5bf30 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 20:16:23 +0100 Subject: [PATCH 042/103] Move doc --- syntax.txt => doc/python-syntax.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename syntax.txt => doc/python-syntax.txt (100%) diff --git a/syntax.txt b/doc/python-syntax.txt similarity index 100% rename from syntax.txt rename to doc/python-syntax.txt From 624b675621de9d028185521947544f32feca5705 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 20:37:38 +0100 Subject: [PATCH 043/103] Update documentation --- README.rst | 191 +++++++++++++++++------------------------- doc/python-syntax.txt | 106 ++++++++++++----------- 2 files changed, 129 insertions(+), 168 deletions(-) diff --git a/README.rst b/README.rst index 49c39b5..25c6ae6 100644 --- a/README.rst +++ b/README.rst @@ -3,142 +3,105 @@ Python syntax highlighting script for Vim .. contents:: -About ------ - -Enhanced version of the original Python syntax highlighting script. Based on -``python.vim`` from Vim 6.1 distribution by Neil Schemenauer (nas at python dot -ca). Check also `python.vim page on vim.org -`_. - -Please report bugs and feature requests to our issue tracker over at: -https://github.com/vim-python/python-syntax/issues +This is an enhanced version of the original Python syntax highlighting script. Based on +``python.vim`` from Vim 6.1 distribution by Neil Schemenauer. Features -------- -Changes from the original ``python.vim`` are: - - Added support for Python 3 syntax highlighting -- Added ``:Python2Syntax`` and ``:Python3Syntax`` commands which allow to - switch between Python 2 and Python 3 syntaxes respectively without - reloads/restarts -- Updated strings highlighting +- Added commands ``Python2Syntax`` and ``Python3Syntax`` commands which allow to switch + between Python 2 and Python 3 syntaxes respectively without reloads/restarts +- Updated string highlighting - Enhanced special symbols highlighting inside strings - Enhanced highlighting of numeric constants - Added optional highlighting for %-formatting inside strings -- Added highlighting for magic comments: source code encoding and #! - (executable) strings +- Added highlighting for magic comments: source code encoding and #! (executable) strings - Added highlighting for new exceptions and builtins - Added highlighting for doctests - Added highlighting for new ``@decorator`` syntax introduced in Python 2.4a2 - Added highlighting for the following errors: + - Invalid symbols in source file + - Mixing spaces and tabs + - Invalid numeric constants + - Invalid %-formatting inside strings + - Invalid variable names + - Trailing spaces (triggered by the ``python_highlight_space_errors`` option) - - invalid symbols in source file - - mixing spaces and tabs - - invalid numeric constants - - invalid %-formatting inside strings - - invalid variable names - - trailing spaces (triggered by the ``python_highlight_space_errors`` option) - -Some of these features was later backported into the original ``python.vim``. - -Folding is done by the plugin `SimpylFold `_ +Folding is done by the plugin `SimpylFold `_. How to install -------------- -The easiest installation method is to place `syntax/python.vim -`_ script -into your ``~/.vim/syntax/`` directory. +Use one of the following plugin managers: + +- `dein `_ +- `vim-plug `_ +- `vundle `_ +- `pathogen `_ -You can also use `Pathogen `_ or `Vundle -`_ plugin managers in which case you can -install the whole `repository -`_ into the corresponding plugins -directory. +Or you can just manually place `syntax/python.vim +`_ +into ``~/.config/nvim/syntax/`` or ``~/.vim/syntax/``. Script options -------------- -There are two commands to enable or disable an option: +Enable option with:: + + let OPTION_NAME = 1 + +Disable option with:: -``:let OPTION_NAME = 1`` - Enable option -``:let OPTION_NAME = 0`` - 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 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -``python_version_2`` - 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: - -``:Python2Syntax`` - Switch to Python 2 highlighting mode -``:Python3Syntax`` - Switch to Python 3 highlighting mode - -Options used by the script -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -``python_highlight_builtins`` - Highlight builtin functions and objects -``python_highlight_builtin_objs`` - Highlight builtin objects only -``python_highlight_builtin_funcs`` - Highlight builtin functions only -``python_highlight_exceptions`` - Highlight standard exceptions -``python_highlight_string_formatting`` - Highlight ``%`` string formatting -``python_highlight_string_format`` - Highlight syntax of ``str.format`` syntax -``python_highlight_string_templates`` - Highlight syntax of ``string.Template`` -``python_highlight_indent_errors`` - Highlight indentation errors -``python_highlight_space_errors`` - Highlight trailing spaces -``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 any - previously set options* -``python_slow_sync`` - Can be set to 0 for slow machines - -Contributors ------------- - -List of the contributors in alphabetical order: - -- `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 `_ -- `Victor Salgado `_ -- `Will Gray `_ -- `Yuri Habrusiev `_ +following command in your ``~/.config/nvim/init.vim`` or ``~/.vimrc`` script:: + + let g:python_highlight_all = 1 + +Options and commands to select Python version +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``g:python_version_2`` or ``b:python_version_2`` + Enable highlighting for Python 2 (Python 3 highlighting is enabled by + default). + +The following commands can be used to switch between modes: + +``Python2Syntax`` + Switch to Python 2 +``Python3Syntax`` + Switch to Python 3 + +Other options +~~~~~~~~~~~~~ + +``g:python_highlight_builtins`` + Highlight builtin functions and objects +``g:python_highlight_builtin_objs`` + Highlight builtin objects only +``g:python_highlight_builtin_funcs`` + Highlight builtin functions only +``g:python_highlight_exceptions`` + Highlight standard exceptions +``g:python_highlight_string_formatting`` + Highlight ``%`` string formatting +``g:python_highlight_string_format`` + Highlight syntax of ``str.format`` syntax +``g:python_highlight_string_templates`` + Highlight syntax of ``string.Template`` +``g:python_highlight_indent_errors`` + Highlight indentation errors +``g:python_highlight_space_errors`` + Highlight trailing spaces +``g:python_highlight_doctests`` + Highlight doc-tests +``g:python_print_as_function`` + Highlight ``print`` statement as function for Python 2 +``g:python_highlight_file_headers_as_comments`` + Highlight shebang and coding headers as comments +``g:python_highlight_all`` + Enable all the options above - *NOTE: Doesn't override any previously set options* +``g:python_slow_sync`` + Disable for slow machines diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 294b11a..2b7ceb7 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -1,65 +1,63 @@ -PYTHON *python.vim* *ft-python-syntax* +*python-syntax* *ft-python-syntax* *python.vim* -There are two commands to enable or disable an option for python.vim +=============================================================================== +Configuration *python-syntax-configuration* - Enable option: > - :let option_name = 1 +Enable option with: > + + let OPTION_NAME = 1 < - Disable option: > - :let option_name = 0 +Disable option with: > + + let OPTION_NAME = 0 < For example to enable all syntax highlighting features you can place the -following command in your `~/.vimrc` script: > +following command in your `~/.config/nvim/init.vim` or `~/.vimrc` script: > - let python_highlight_all = 1 + let g:python_highlight_all = 1 < -Option and commands to select Python version: > +------------------------------------------------------------------------------- +Options and commands to select Python version *python-syntax-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. +`g:python_version_2` or `b:python_version_2` + Enable highlighting for Python 2 (Python 3 highlighting is enabled by + default). -The following local to buffer commands can be used to switch between two -highlighting modes: +The following commands can be used to switch between modes: - Switch to Python 2 highlighting mode > - :Python2Syntax -< - Switch to Python 3 highlighting mode > - :Python3Syntax -< -Options used by the script +`Python2Syntax` + Switch to Python 2 +`Python3Syntax` + Switch to Python 3 - 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: +------------------------------------------------------------------------------- +Options *python-syntax-options* + +`g:python_highlight_builtins` + Highlight builtin functions and objects +`g:python_highlight_builtin_objs` + Highlight builtin objects only +`g:python_highlight_builtin_funcs` + Highlight builtin functions only +`g:python_highlight_exceptions` + Highlight standard exceptions +`g:python_highlight_string_formatting` + Highlight `%` string formatting +`g:python_highlight_string_format` + Highlight syntax of `str.format` syntax +`g:python_highlight_string_templates` + Highlight syntax of `string.Template` +`g:python_highlight_indent_errors` + Highlight indentation errors +`g:python_highlight_space_errors` + Highlight trailing spaces +`g:python_highlight_doctests` + Highlight doc-tests +`g:python_print_as_function` + Highlight `print` statement as function for Python 2 +`g:python_highlight_file_headers_as_comments` + Highlight shebang and coding headers as comments +`g:python_highlight_all` + Enable all the options above - NOTE: Doesn't override any previously set options +`g:python_slow_sync` + Disable for slow machines From 621b04a9377786a95f6656b6fdef538c67bde43e Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 21:01:13 +0100 Subject: [PATCH 044/103] doc: Add introduction --- doc/python-syntax.txt | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 2b7ceb7..4980d3a 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -1,4 +1,34 @@ -*python-syntax* *ft-python-syntax* *python.vim* +*python-syntax.txt* Python syntax highlighting + +=============================================================================== +Introduction *python-syntax* *ft-python-syntax* *python.vim* + +This is an enhanced version of the original Python syntax highlighting script. Based on +`python.vim` from Vim 6.1 distribution by Neil Schemenauer. + +Features +-------- + +- Added support for Python 3 syntax highlighting +- Added commands `Python2Syntax` and `Python3Syntax` commands which allow to switch + between Python 2 and Python 3 syntaxes respectively without reloads/restarts +- Updated string highlighting +- Enhanced special symbols highlighting inside strings +- Enhanced highlighting of numeric constants +- Added optional highlighting for %-formatting inside strings +- Added highlighting for magic comments: source code encoding and #! (executable) strings +- Added highlighting for new exceptions and builtins +- Added highlighting for doctests +- Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 +- Added highlighting for the following errors: + - Invalid symbols in source file + - Mixing spaces and tabs + - Invalid numeric constants + - Invalid %-formatting inside strings + - Invalid variable names + - Trailing spaces (triggered by the `python_highlight_space_errors` option) + +Folding is done by the plugin `SimpylFold` (`https://github.com/tmhedberg/SimpylFold`) =============================================================================== Configuration *python-syntax-configuration* From 6d231116fa901bdf7ea09d3c6ba366e48dc56453 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 22:06:25 +0100 Subject: [PATCH 045/103] Minor documentation update --- README.rst | 22 ++++++++++++---------- doc/python-syntax.txt | 14 +++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/README.rst b/README.rst index 25c6ae6..a9335be 100644 --- a/README.rst +++ b/README.rst @@ -44,38 +44,40 @@ Or you can just manually place `syntax/python.vim `_ into ``~/.config/nvim/syntax/`` or ``~/.vim/syntax/``. -Script options +Configuration -------------- Enable option with:: - let OPTION_NAME = 1 + let VARIABLE = 1 Disable option with:: - let OPTION_NAME = 0 + let VARIABLE = 0 -For example to enable all syntax highlighting features you can place the -following command in your ``~/.config/nvim/init.vim`` or ``~/.vimrc`` script:: +For example to enable all syntax highlighting features you can add the +following command to your ``~/.config/nvim/init.vim`` or ``~/.vimrc``:: let g:python_highlight_all = 1 -Options and commands to select Python version -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Select Python version +~~~~~~~~~~~~~~~~~~~~~ + +Variables: ``g:python_version_2`` or ``b:python_version_2`` Enable highlighting for Python 2 (Python 3 highlighting is enabled by default). -The following commands can be used to switch between modes: +Commands to easily switch between modes: ``Python2Syntax`` Switch to Python 2 ``Python3Syntax`` Switch to Python 3 -Other options -~~~~~~~~~~~~~ +Option variables +~~~~~~~~~~~~~~~~ ``g:python_highlight_builtins`` Highlight builtin functions and objects diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 4980d3a..7fbb4f7 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -35,25 +35,25 @@ Configuration *python-syntax-configuration Enable option with: > - let OPTION_NAME = 1 + let VARIABLE = 1 < Disable option with: > - let OPTION_NAME = 0 + let VARIABLE = 0 < -For example to enable all syntax highlighting features you can place the -following command in your `~/.config/nvim/init.vim` or `~/.vimrc` script: > +For example to enable all syntax highlighting features you can add the +following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: > let g:python_highlight_all = 1 < ------------------------------------------------------------------------------- -Options and commands to select Python version *python-syntax-version* +Select Python version *python-syntax-version* `g:python_version_2` or `b:python_version_2` Enable highlighting for Python 2 (Python 3 highlighting is enabled by default). -The following commands can be used to switch between modes: +Commands to easily switch between modes: `Python2Syntax` Switch to Python 2 @@ -61,7 +61,7 @@ The following commands can be used to switch between modes: Switch to Python 3 ------------------------------------------------------------------------------- -Options *python-syntax-options* +Option variables *python-syntax-options* *python-syntax-variables* `g:python_highlight_builtins` Highlight builtin functions and objects From 187f89d1fd4d39a9730d1e4b94ddefd91100984a Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 22:07:40 +0100 Subject: [PATCH 046/103] README: Minor cleanup --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a9335be..5cafcd3 100644 --- a/README.rst +++ b/README.rst @@ -45,7 +45,7 @@ Or you can just manually place `syntax/python.vim into ``~/.config/nvim/syntax/`` or ``~/.vim/syntax/``. Configuration --------------- +------------- Enable option with:: From 49dd46fc99dbc9ff843acee96d5ca047e8dc63dd Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 22:11:43 +0100 Subject: [PATCH 047/103] Remove TODO and CHANGES --- CHANGES.txt | 224 ---------------------------------------------------- TODO.txt | 26 ------ 2 files changed, 250 deletions(-) delete mode 100644 CHANGES.txt delete mode 100644 TODO.txt diff --git a/CHANGES.txt b/CHANGES.txt deleted file mode 100644 index 2d3b520..0000000 --- a/CHANGES.txt +++ /dev/null @@ -1,224 +0,0 @@ -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 - Elizabeth Myers. - -Revision 3.3.5 (2013-08-31): - - - Highlight 'import', 'from' and 'as' as include statements. - 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 David Briscoe. - -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. - -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 - https://github.com/hdima/python-syntax - -Revision 3.3.0 (2013-03-10): - - - Merge Python 2 and Python 3 script versions into the single python.vim - script - -Revision 3.0.7 (2012-02-11): - - - Updated email and URL - -Revision 2.6.7 (2012-02-11): - - - Updated email and URL - -Revision 3.0.6 (2010-11-14): - - - Fixed highlighting for str.format syntax. Patch by Anton Butanaev. - -Revision 3.0.5 (2010-11-11): - - - Fixed highlighting for bytes. Patch by Anton Butanaev. - - Fixed highlighting for numbers. - -Revision 3.0.4 (2010-11-09): - - - Fixed highlighting for raw bytes literals. Patch by Anton Butanaev. - -Revision 3.0.3 (2010-04-09): - - - Applied patch by Andrea Riciputi with new configuration options - "python_highlight_builtin_objs" and "python_highlight_builtin_funcs" - -Revision 3.0.2 (2009-07-24): - - - Applied patch by Caleb Adamantine which fixes highlighting for decorators - -Revision 3.0.1 (2009-05-03): - - - Fixed compatibility with pyrex.vim - -Revision 3.0.0 (2008-12-07): - - - Added support for non-ASCII identifiers; - - Added support for new text strings and binary data (bytes); - - Updated support for numeric literals; - - Updated support for str.format; - - Added new builtins introduced in Python 2.6: "ascii", "exec", - "memoryview", "print"; - - Added new keyword "nonlocal"; - - Removed exception "StandardError"; - - Removed builtins: "apply", "basestring", "buffer", "callable", "coerce", - "execfile", "file", "help", "intern", "long", "raw_input", "reduce", - "reload", "unichr", "unicode", "xrange"; - -Revision 2.6.6 (2010-04-09): - - - Applied patch by Andrea Riciputi with new configuration options - "python_highlight_builtin_objs" and "python_highlight_builtin_funcs" - -Revision 2.6.5 (2009-07-24): - - - Applied patch by Caleb Adamantine which fixes highlighting for decorators - -Revision 2.6.4 (2009-05-03): - - - Fixed compatibility with pyrex.vim - -Revision 2.6.3 (2008-09-29): - - - Return back trailing 'L' support for numbers. Actually it was changed for - future Python 3.0 syntax but in wrong file; - -Revision 2.6.2 (2008-09-22): - - - Added "VMSError" exception; - - Added support for b"..." syntax; - - Added support for str.format brace escaping; - -Revision 2.6.1 (2008-09-21): - - - Added new builtins and exceptions introduced in Python 2.6: "bin", - "bytearray", "bytes", "format", "next", "BufferError", "BytesWarning"; - - Added builtin "__debug__"; - - Added global variables: "__doc__", "__file__", "__name__", "__package__"; - - Removed "OverflowWarning" (removed in Python 2.5); - - Added option "python_print_as_function" for highlight "print" as a - function; - - Added support for new integer literal syntax "0o" and "0b"; - - Added support for string.Template syntax controlled by - "python_highlight_string_templates" option; - - Added support for str.format syntax controlled by - "python_highlight_string_format" option; - - Removed highlighting for "--" and "++" because it's a valid Python - expressions which can be interpreted as "a + +b"; - -Revision 2.5.6 (2007-02-04): - - - Applied patch by Pedro Algarvio to enable spell checking only for - the right spots (strings and comments); - -Revision 2.5.5 (2006-09-26): - - - added new warnings (ImportWarning, UnicodeWarning) - introduced in Python 2.5; - -Revision 2.5.4 (2006-05-11): - - - added highlighting for erroneous operators: &&, ||, ++, --, === - (inspired by http://www.vim.org/tips/tip.php?tip_id=969, thanks - Jeroen Ruigrok van der Werven for the link); - - added highlighting for new 'with' statement and 'BaseException', - 'GeneratorExit' exceptions introduced in Python 2.5; - - added highlighting for 'OverflowWarning' exception which had been - forgotten; - - returned more robust recognition for function names; - -Revision 2.5.3: - - - fixed %-formatting highlighting for raw unicode strings; - -Revision 2.5.2: - - - slightly simplified option handling; - - fixed regexp for indentation errors; - - fixed highlighting for backslashed symbols inside strings; - - added highlighting for trailing-space errors (triggered by new - option: python_highlight_space_errors); - - added highlighting for variable name errors; - - added highlighting for hex number errors; - -Revision 2.5.1 (2005-03-13): - - - added new builtins 'all' and 'any' (Python 2.5a0) - -Revision 2.4.2 (2004-08-05): - - - added highlighting for new @decorator syntax introduced in python 2.4a2 - -Revision 2.4.1 (2004-03-17): - - - new versioning scheme (based on python version numbers); - - added highlighting for new types/builtins introduced in python 2.4 - (set, frozenset, reversed, sorted); - - new option added: python_slow_sync (set this for slow but more - robust syntax synchronization); - - added highlighting for doctests; - -Revision 1.19: - - - new option added: python_highlight_indent_errors; - - python_highlight_all now not override previously set options, - for example code: - let python_highlight_indent_errors = 0 - let python_highlight_all = 1 - set all highlight options except indentation errors highlighting option; - -Revision 1.17: - - - changed header, "Based on..." string added; - -Revision 1.16: - - - added basestring builtin; - -Revision 1.15 (first public revision). - - The changes since the original (vim6.1) python.vim are: - - - changed string highlighting; - - enhanced special symbols highlighting inside strings; - - enhanced constant numbers highlighting; - - added optional highlighting for %-formatting inside strings; - - added highlighting for error conditions (wrong symbols in source file, - mixing spaces and tabs, wrong number values, - wrong %-formatting inside strings); - - added highlighting for magic comments: source code encoding - and #! (executable) strings; - - added highlighting for new exceptions and builtins introduced - in python 2.3; diff --git a/TODO.txt b/TODO.txt deleted file mode 100644 index 605c45a..0000000 --- a/TODO.txt +++ /dev/null @@ -1,26 +0,0 @@ -Now -=== - -- It seems python.vim doesn't highlight special characters inside strings by - 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 - -- When we check spelling we don't need to check the whole strings only the - content. For example we don't need to check 'u' for spelling in strings - like this: u"Some text"; - -Later -===== - -- Need more accurate way to handle indentation errors. For example - mixing spaces and tabs may be used for pretty formatting; - -- Need more checks for errors like: absent brackets, absent quotes, - back slash at the end of strings; - -- pythonError tips from - http://blog.sontek.net/2008/05/11/python-with-a-modular-ide-vim/ (reported by - Giuliani Deon Sanches) From b9b0a787cf0228bc4d253de3a76ddfaaf28ca525 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 22:15:09 +0100 Subject: [PATCH 048/103] Remove docs from `syntax` file --- syntax/python.vim | 65 ----------------------------------------------- 1 file changed, 65 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index ec36042..cbde688 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -1,68 +1,3 @@ -" Vim syntax file -" Language: Python -" Current Maintainer: vim-python organization on GitHub -" URL: https://github.com/vim-python/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 -" -" Please report bugs and feature requests to our issue tracker over at: -" https://github.com/vim-python/python-syntax/issues -" -" Options -" ======= -" -" :let OPTION_NAME = 1 Enable option -" :let OPTION_NAME = 0 Disable option -" -" -" Option 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 buffer (b:python_version_2) -" variable. -" -" You can also use the following local to buffer commands to switch -" between two highlighting modes: -" -" :Python2Syntax Switch to Python 2 highlighting -" mode -" :Python3Syntax Switch to Python 3 highlighting -" mode -" -" Option names used by the script -" ------------------------------- -" -" python_highlight_builtins Highlight builtin functions and -" objects -" python_highlight_builtin_objs Highlight builtin objects only -" python_highlight_builtin_funcs Highlight builtin functions only -" python_highlight_exceptions Highlight standard exceptions -" python_highlight_string_formatting Highlight % string formatting -" python_highlight_string_format Highlight str.format syntax -" python_highlight_string_templates Highlight string.Template syntax -" python_highlight_indent_errors Highlight indentation errors -" python_highlight_space_errors Highlight trailing spaces -" 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 -" any previously set options -" -" python_slow_sync Can be set to 0 for slow machines -" - " For version 5.x: Clear all syntax items " For versions greater than 6.x: Quit when a syntax file was already loaded if v:version < 600 From 3c615fb1c7d1aeda53db7b40cc92a4ad744a36d5 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 16 Feb 2017 23:00:13 +0100 Subject: [PATCH 049/103] syntax: FunctionParameters: Don't include the parentheses in the match Fixes problem with Rainbow parentheses --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index cbde688..7463020 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -98,7 +98,7 @@ else syn match pythonStatement '\' endif -syn region FunctionParameters start='(' end=')' display contains= +syn region FunctionParameters start='(\zs' end='\ze)' display contains= \ FunctionParameters, \ OptionalParameters, \ pythonRepeat, From a8e5577c5815210ef151896fe06e2d482722ced4 Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 17 Feb 2017 00:21:57 +0100 Subject: [PATCH 050/103] docs: Fix list items --- README.rst | 43 ++++++++++++++++++++++--------------------- doc/python-syntax.txt | 34 +++++++++++++++++----------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/README.rst b/README.rst index 5cafcd3..2c83e38 100644 --- a/README.rst +++ b/README.rst @@ -9,24 +9,25 @@ This is an enhanced version of the original Python syntax highlighting script. B Features -------- -- Added support for Python 3 syntax highlighting -- Added commands ``Python2Syntax`` and ``Python3Syntax`` commands which allow to switch +* Added support for Python 3 syntax highlighting +* Added commands ``Python2Syntax`` and ``Python3Syntax`` commands which allow to switch between Python 2 and Python 3 syntaxes respectively without reloads/restarts -- Updated string highlighting -- Enhanced special symbols highlighting inside strings -- Enhanced highlighting of numeric constants -- Added optional highlighting for %-formatting inside strings -- Added highlighting for magic comments: source code encoding and #! (executable) strings -- Added highlighting for new exceptions and builtins -- Added highlighting for doctests -- Added highlighting for new ``@decorator`` syntax introduced in Python 2.4a2 -- Added highlighting for the following errors: - - Invalid symbols in source file - - Mixing spaces and tabs - - Invalid numeric constants - - Invalid %-formatting inside strings - - Invalid variable names - - Trailing spaces (triggered by the ``python_highlight_space_errors`` option) +* Updated string highlighting +* Enhanced special symbols highlighting inside strings +* Enhanced highlighting of numeric constants +* Added optional highlighting for %-formatting inside strings +* Added highlighting for magic comments: source code encoding and #! (executable) strings +* Added highlighting for new exceptions and builtins +* Added highlighting for doctests +* Added highlighting for new ``@decorator`` syntax introduced in Python 2.4a2 +* Added highlighting for the following errors: + + * Invalid symbols in source file + * Mixing spaces and tabs + * Invalid numeric constants + * Invalid %-formatting inside strings + * Invalid variable names + * Trailing spaces (triggered by the ``python_highlight_space_errors`` option) Folding is done by the plugin `SimpylFold `_. @@ -35,10 +36,10 @@ How to install Use one of the following plugin managers: -- `dein `_ -- `vim-plug `_ -- `vundle `_ -- `pathogen `_ +* `dein `_ +* `vim-plug `_ +* `vundle `_ +* `pathogen `_ Or you can just manually place `syntax/python.vim `_ diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 7fbb4f7..d008d5e 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -9,24 +9,24 @@ This is an enhanced version of the original Python syntax highlighting script. B Features -------- -- Added support for Python 3 syntax highlighting -- Added commands `Python2Syntax` and `Python3Syntax` commands which allow to switch +* Added support for Python 3 syntax highlighting +* Added commands `Python2Syntax` and `Python3Syntax` commands which allow to switch between Python 2 and Python 3 syntaxes respectively without reloads/restarts -- Updated string highlighting -- Enhanced special symbols highlighting inside strings -- Enhanced highlighting of numeric constants -- Added optional highlighting for %-formatting inside strings -- Added highlighting for magic comments: source code encoding and #! (executable) strings -- Added highlighting for new exceptions and builtins -- Added highlighting for doctests -- Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 -- Added highlighting for the following errors: - - Invalid symbols in source file - - Mixing spaces and tabs - - Invalid numeric constants - - Invalid %-formatting inside strings - - Invalid variable names - - Trailing spaces (triggered by the `python_highlight_space_errors` option) +* Updated string highlighting +* Enhanced special symbols highlighting inside strings +* Enhanced highlighting of numeric constants +* Added optional highlighting for %-formatting inside strings +* Added highlighting for magic comments: source code encoding and #! (executable) strings +* Added highlighting for new exceptions and builtins +* Added highlighting for doctests +* Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 +* Added highlighting for the following errors: + * Invalid symbols in source file + * Mixing spaces and tabs + * Invalid numeric constants + * Invalid %-formatting inside strings + * Invalid variable names + * Trailing spaces (triggered by the `python_highlight_space_errors` option) Folding is done by the plugin `SimpylFold` (`https://github.com/tmhedberg/SimpylFold`) From aaa002e48d0ef5bb530265e83ea6ea9b8669f9af Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 17 Feb 2017 00:26:56 +0100 Subject: [PATCH 051/103] docs: Fix lists for real --- README.rst | 12 ++++++------ doc/python-syntax.txt | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 2c83e38..736f79a 100644 --- a/README.rst +++ b/README.rst @@ -22,12 +22,12 @@ Features * Added highlighting for new ``@decorator`` syntax introduced in Python 2.4a2 * Added highlighting for the following errors: - * Invalid symbols in source file - * Mixing spaces and tabs - * Invalid numeric constants - * Invalid %-formatting inside strings - * Invalid variable names - * Trailing spaces (triggered by the ``python_highlight_space_errors`` option) + * Invalid symbols in source file + * Mixing spaces and tabs + * Invalid numeric constants + * Invalid %-formatting inside strings + * Invalid variable names + * Trailing spaces (triggered by the ``python_highlight_space_errors`` option) Folding is done by the plugin `SimpylFold `_. diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index d008d5e..f98bf53 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -21,12 +21,12 @@ Features * Added highlighting for doctests * Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 * Added highlighting for the following errors: - * Invalid symbols in source file - * Mixing spaces and tabs - * Invalid numeric constants - * Invalid %-formatting inside strings - * Invalid variable names - * Trailing spaces (triggered by the `python_highlight_space_errors` option) + * Invalid symbols in source file + * Mixing spaces and tabs + * Invalid numeric constants + * Invalid %-formatting inside strings + * Invalid variable names + * Trailing spaces (triggered by the `python_highlight_space_errors` option) Folding is done by the plugin `SimpylFold` (`https://github.com/tmhedberg/SimpylFold`) From 91430a49b67396da919dfe103284212ac638a723 Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 17 Feb 2017 06:52:34 +0100 Subject: [PATCH 052/103] README: Convert to markdown --- README.md | 78 ++++++++++++++++++++++++++++++ README.rst | 110 ------------------------------------------ doc/python-syntax.txt | 95 ++++++++++++++++++++---------------- 3 files changed, 131 insertions(+), 152 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..588ce32 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +Python syntax highlighting for Vim +========================================= + +This is an enhanced version of the original Vim 6.1 Python syntax highlighting +`python.vim` by Neil Schemenauer. + +Features +-------- + +* Added support for Python 3 syntax highlighting +* Added commands `Python2Syntax` and `Python3Syntax` allowing to easily switch + between Python 2 and Python 3. +* Updated string highlighting +* Enhanced special symbols highlighting inside strings +* Enhanced highlighting of numeric constants +* Added optional highlighting for %-formatting inside strings +* Added highlighting for magic comments: source code encoding and + shebangs (`#!`) +* Added highlighting for new exceptions and builtins +* Added highlighting for doctests +* Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 +* Added highlighting for the following errors: + * Invalid symbols in source file + * Mixing spaces and tabs + * Invalid numeric constants + * Invalid %-formatting inside strings + * Invalid variable names + * Trailing spaces (Enabled with `g:python_highlight_space_errors`) + +Folding is done by the plugin [SimpylFold](https://github.com/tmhedberg/SimpylFold). + +How to install +-------------- + +Use one of the following plugin managers: + +* [dein](https://github.com/Shougo/dein.vim) +* [vim-plug](https://github.com/junegunn/vim-plug) +* [vundle](https://github.com/VundleVim/Vundle.vim) +* [pathogen](https://github.com/tpope/vim-pathogen) + +Configuration +------------- + +### Option variables + +Set variable to `1` to enable or `0` to disable. + +For example to enable all syntax highlighting features you can add the +following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: +```vim +let g:python_highlight_all = 1 +``` +| Variable | Description | Default | +| --------------------------------------------- | -------------------------------------------------------------- | ------- | +| `g:python_version_2` | Python 2 mode | `0` | +| `b:python_version_2` | Python 2 mode (buffer local) | `0` | +| `g:python_highlight_builtins` | Highlight builtin functions and objects | `0` | +| `g:python_highlight_builtins` | Highlight builtin functions and objects | `0` | +| `g:python_highlight_builtin_objs` | Highlight builtin objects only | `0` | +| `g:python_highlight_builtin_funcs` | Highlight builtin functions only | `0` | +| `g:python_highlight_exceptions` | Highlight standard exceptions | `0` | +| `g:python_highlight_string_formatting` | Highlight `%` string formatting | `0` | +| `g:python_highlight_string_format` | Highlight syntax of `str.format` syntax | `0` | +| `g:python_highlight_string_templates` | Highlight syntax of `string.Template` | `0` | +| `g:python_highlight_indent_errors` | Highlight indentation errors | `0` | +| `g:python_highlight_space_errors` | Highlight trailing spaces | `0` | +| `g:python_highlight_doctests` | Highlight doc-tests | `0` | +| `g:python_highlight_all` | Enable all highlight options above, except for previously set. | `0` | +| `g:python_highlight_file_headers_as_comments` | Highlight shebang and coding headers as comments | `0` | +| `g:python_slow_sync` | Disable for slow machines | `1` | + +### Commands + +| Command | Description | +| --------------- | ------------------ | +| `Python2Syntax` | Switch to Python 2 | +| `Python3Syntax` | Switch to Python 3 | diff --git a/README.rst b/README.rst deleted file mode 100644 index 736f79a..0000000 --- a/README.rst +++ /dev/null @@ -1,110 +0,0 @@ -Python syntax highlighting script for Vim -========================================= - -.. contents:: - -This is an enhanced version of the original Python syntax highlighting script. Based on -``python.vim`` from Vim 6.1 distribution by Neil Schemenauer. - -Features --------- - -* Added support for Python 3 syntax highlighting -* Added commands ``Python2Syntax`` and ``Python3Syntax`` commands which allow to switch - between Python 2 and Python 3 syntaxes respectively without reloads/restarts -* Updated string highlighting -* Enhanced special symbols highlighting inside strings -* Enhanced highlighting of numeric constants -* Added optional highlighting for %-formatting inside strings -* Added highlighting for magic comments: source code encoding and #! (executable) strings -* Added highlighting for new exceptions and builtins -* Added highlighting for doctests -* Added highlighting for new ``@decorator`` syntax introduced in Python 2.4a2 -* Added highlighting for the following errors: - - * Invalid symbols in source file - * Mixing spaces and tabs - * Invalid numeric constants - * Invalid %-formatting inside strings - * Invalid variable names - * Trailing spaces (triggered by the ``python_highlight_space_errors`` option) - -Folding is done by the plugin `SimpylFold `_. - -How to install --------------- - -Use one of the following plugin managers: - -* `dein `_ -* `vim-plug `_ -* `vundle `_ -* `pathogen `_ - -Or you can just manually place `syntax/python.vim -`_ -into ``~/.config/nvim/syntax/`` or ``~/.vim/syntax/``. - -Configuration -------------- - -Enable option with:: - - let VARIABLE = 1 - -Disable option with:: - - let VARIABLE = 0 - -For example to enable all syntax highlighting features you can add the -following command to your ``~/.config/nvim/init.vim`` or ``~/.vimrc``:: - - let g:python_highlight_all = 1 - -Select Python version -~~~~~~~~~~~~~~~~~~~~~ - -Variables: - -``g:python_version_2`` or ``b:python_version_2`` - Enable highlighting for Python 2 (Python 3 highlighting is enabled by - default). - -Commands to easily switch between modes: - -``Python2Syntax`` - Switch to Python 2 -``Python3Syntax`` - Switch to Python 3 - -Option variables -~~~~~~~~~~~~~~~~ - -``g:python_highlight_builtins`` - Highlight builtin functions and objects -``g:python_highlight_builtin_objs`` - Highlight builtin objects only -``g:python_highlight_builtin_funcs`` - Highlight builtin functions only -``g:python_highlight_exceptions`` - Highlight standard exceptions -``g:python_highlight_string_formatting`` - Highlight ``%`` string formatting -``g:python_highlight_string_format`` - Highlight syntax of ``str.format`` syntax -``g:python_highlight_string_templates`` - Highlight syntax of ``string.Template`` -``g:python_highlight_indent_errors`` - Highlight indentation errors -``g:python_highlight_space_errors`` - Highlight trailing spaces -``g:python_highlight_doctests`` - Highlight doc-tests -``g:python_print_as_function`` - Highlight ``print`` statement as function for Python 2 -``g:python_highlight_file_headers_as_comments`` - Highlight shebang and coding headers as comments -``g:python_highlight_all`` - Enable all the options above - *NOTE: Doesn't override any previously set options* -``g:python_slow_sync`` - Disable for slow machines diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index f98bf53..2731c8e 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -3,20 +3,21 @@ =============================================================================== Introduction *python-syntax* *ft-python-syntax* *python.vim* -This is an enhanced version of the original Python syntax highlighting script. Based on -`python.vim` from Vim 6.1 distribution by Neil Schemenauer. +This is an enhanced version of the original Vim 6.1 Python syntax highlighting +`python.vim` by Neil Schemenauer. Features -------- * Added support for Python 3 syntax highlighting -* Added commands `Python2Syntax` and `Python3Syntax` commands which allow to switch - between Python 2 and Python 3 syntaxes respectively without reloads/restarts +* Added commands `Python2Syntax` and `Python3Syntax` allowing to easily switch + between Python 2 and Python 3. * Updated string highlighting * Enhanced special symbols highlighting inside strings * Enhanced highlighting of numeric constants * Added optional highlighting for %-formatting inside strings -* Added highlighting for magic comments: source code encoding and #! (executable) strings +* Added highlighting for magic comments: source code encoding and + shebangs (`#!`) * Added highlighting for new exceptions and builtins * Added highlighting for doctests * Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 @@ -26,68 +27,78 @@ Features * Invalid numeric constants * Invalid %-formatting inside strings * Invalid variable names - * Trailing spaces (triggered by the `python_highlight_space_errors` option) + * Trailing spaces (Enabled with `g:python_highlight_space_errors`) -Folding is done by the plugin `SimpylFold` (`https://github.com/tmhedberg/SimpylFold`) +Folding is done by the plugin SimpylFold +(https://github.com/tmhedberg/SimpylFold). =============================================================================== Configuration *python-syntax-configuration* -Enable option with: > +Option variables +---------------- - let VARIABLE = 1 -< -Disable option with: > +Set variable to `1` to enable or `0` to disable. - let VARIABLE = 0 -< For example to enable all syntax highlighting features you can add the following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: > let g:python_highlight_all = 1 < -------------------------------------------------------------------------------- -Select Python version *python-syntax-version* -`g:python_version_2` or `b:python_version_2` - Enable highlighting for Python 2 (Python 3 highlighting is enabled by - default). +`g:python_version_2` (default `0`) + Python 2 mode -Commands to easily switch between modes: - -`Python2Syntax` - Switch to Python 2 -`Python3Syntax` - Switch to Python 3 +`b:python_version_2` (default `0`) + Python 2 mode (buffer local) -------------------------------------------------------------------------------- -Option variables *python-syntax-options* *python-syntax-variables* +`g:python_highlight_builtins` (default `0`) + Highlight builtin functions and objects -`g:python_highlight_builtins` +`g:python_highlight_builtins` (default `0`) Highlight builtin functions and objects -`g:python_highlight_builtin_objs` + +`g:python_highlight_builtin_objs` (default `0`) Highlight builtin objects only -`g:python_highlight_builtin_funcs` + +`g:python_highlight_builtin_funcs` (default `0`) Highlight builtin functions only -`g:python_highlight_exceptions` + +`g:python_highlight_exceptions` (default `0`) Highlight standard exceptions -`g:python_highlight_string_formatting` + +`g:python_highlight_string_formatting` (default `0`) Highlight `%` string formatting -`g:python_highlight_string_format` + +`g:python_highlight_string_format` (default `0`) Highlight syntax of `str.format` syntax -`g:python_highlight_string_templates` + +`g:python_highlight_string_templates` (default `0`) Highlight syntax of `string.Template` -`g:python_highlight_indent_errors` + +`g:python_highlight_indent_errors` (default `0`) Highlight indentation errors -`g:python_highlight_space_errors` + +`g:python_highlight_space_errors` (default `0`) Highlight trailing spaces -`g:python_highlight_doctests` + +`g:python_highlight_doctests` (default `0`) Highlight doc-tests -`g:python_print_as_function` - Highlight `print` statement as function for Python 2 -`g:python_highlight_file_headers_as_comments` + +`g:python_highlight_all` (default `0`) + Enable all highlight options above, except for previously set. + +`g:python_highlight_file_headers_as_comments` (default `0`) Highlight shebang and coding headers as comments -`g:python_highlight_all` - Enable all the options above - NOTE: Doesn't override any previously set options -`g:python_slow_sync` + +`g:python_slow_sync` (default `1`) Disable for slow machines + +Commands +-------- + +`Python2Syntax` + Switch to Python 2 + +`Python3Syntax` + Switch to Python 3 From 8cc1bbb2950c509b8030f5811f7f40d58415aa99 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 17 Feb 2017 15:42:43 +0800 Subject: [PATCH 053/103] narrow decorator match to exclude matrix multiplication from hdima/python-syntax#47 --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 7463020..f5b6f14 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -130,7 +130,7 @@ syn match OptionalParameters /\i*\ze=/ display contained " Decorators (new in Python 2.4) " -syn match pythonDecorator '@' display nextgroup=pythonDottedName skipwhite +syn match pythonDecorator '^\s*\zs@' display nextgroup=pythonDottedName skipwhite if s:Python2Syntax() syn match pythonDottedName '[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*' display contained nextgroup=FunctionParameters else From f6aa2f6cae080c52b3a23cc207c2226598fda128 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 17 Feb 2017 15:51:53 +0800 Subject: [PATCH 054/103] better f-strings highlighting Taken from https://github.com/hdima/python-syntax/pull/60 --- syntax/python.vim | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index f5b6f14..81fd41d 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -96,6 +96,7 @@ else syn match pythonStatement '\' nextgroup=pythonFunction skipwhite syn match pythonStatement '\' syn match pythonStatement '\' + syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc endif syn region FunctionParameters start='(\zs' end='\ze)' display contains= @@ -213,10 +214,15 @@ if s:Python2Syntax() syn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell else " Python 3 strings - syn region pythonString start=+f\?'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+f\?"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+f\?"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell - syn region pythonString start=+f\?'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonString start=+'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + + syn region pythonFString start=+[fF]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonFString start=+[fF]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell + syn region pythonFString start=+[fF]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonFString start=+[fF]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell endif if s:Python2Syntax() @@ -267,8 +273,9 @@ if s:Enabled('g:python_highlight_string_format') syn match pythonStrFormat '{{\|}}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else - syn match pythonStrFormat '{{\|}}' contained containedin=pythonString,pythonRawString - syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonRawString + syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString + syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString + syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString contains=pythonStrInterpRegion,@pythonExpression endif endif @@ -474,6 +481,8 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonBytesError Error HiLink pythonBytesEscape Special HiLink pythonBytesEscapeError Error + HiLink pythonFString String + HiLink pythonStrInterpRegion Special endif HiLink pythonStrFormatting Special From f8d6b63f95b9366322a0b25316e99e6b5931115a Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 17 Feb 2017 16:07:25 +0800 Subject: [PATCH 055/103] support underscores in numbers mostly taken from https://github.com/hdima/python-syntax/pull/60 --- syntax/python.vim | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 81fd41d..1ee46bc 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -318,28 +318,37 @@ if s:Python2Syntax() syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*[lL]\=\>' display syn match pythonBinError '\<0[bB][01]*[2-9]\d*[lL]\=\>' display + + syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display + syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display else - syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display syn match pythonOctError '\<0[oO]\=\o*\D\+\d*\>' display + " pythonHexError comes after pythonOctError so that 0xffffl is pythonHexError + syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display syn match pythonBinError '\<0[bB][01]*\D\+\d*\>' display - syn match pythonHexNumber '\<0[xX]\x\+\>' display - syn match pythonOctNumber '\<0[oO]\o\+\>' display - syn match pythonBinNumber '\<0[bB][01]\+\>' display + syn match pythonHexNumber '\<0[xX][_0-9a-fA-F]*\x\>' display + syn match pythonOctNumber '\<0[oO][_0-7]*\o\>' display + syn match pythonBinNumber '\<0[bB][_01]*[01]\>' display - syn match pythonNumberError '\<\d\+\D\>' display - syn match pythonNumberError '\<0\d\+\>' display + syn match pythonNumberError '\<\d[_0-9]*\D\>' display + syn match pythonNumberError '\<0[_0-9]\+\>' display + syn match pythonNumberError '\<0_x\S*\>' display + syn match pythonNumberError '\<0[bBxXoO][_0-9a-fA-F]*_\>' display + syn match pythonNumberError '\<\d[_0-9]*_\>' display syn match pythonNumber '\<\d\>' display - syn match pythonNumber '\<[1-9]\d\+\>' display - syn match pythonNumber '\<\d\+[jJ]\>' display + syn match pythonNumber '\<[1-9][_0-9]*\d\>' display + syn match pythonNumber '\<\d[jJ]\>' display + syn match pythonNumber '\<[1-9][_0-9]*\d[jJ]\>' display syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*\>' display syn match pythonBinError '\<0[bB][01]*[2-9]\d*\>' display -endif -syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display -syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display -syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display + syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display +endif " " Builtin objects and types From 06788bf72e1af5cb8d4f4b5fb93bda7e2c91fc91 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 17 Feb 2017 16:13:36 +0800 Subject: [PATCH 056/103] update test.py --- tests/test.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test.py b/tests/test.py index df81a9a..ff52fd6 100644 --- a/tests/test.py +++ b/tests/test.py @@ -11,6 +11,8 @@ 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 +from test import var as name + yield from def functionname @@ -61,11 +63,13 @@ async def Test # Numbers -0 1 2 9 10 0x1f .3 12.34 0j 0j 34.2E-3 0b10 0o77 1023434 0x0 +0 1 2 9 10 0x1f .3 12.34 0j 124j 34.2E-3 0b10 0o77 1023434 0x0 +1_1 1_1.2_2 1_2j 0x_1f 0x1_f 34_56e-3 34_56e+3_1 0o7_7 # Erroneous numbers -077 100L 0xfffffffL 0L 08 0xk 0x 0b102 0o78 0o123LaB +077 100L 0xfffffffL 0L 08 0xk 0x 0b102 0o78 0o123LaB +0_ 0_1 0_x1f 0x1f_ 0_b77 0b77_ .2_ 1_j # Strings @@ -103,6 +107,10 @@ async def Test "${test} ${test ${test}aname $$$ $test+nope" b"${test} ${test ${test}aname $$$ $test+nope" +f"{var}...{arr[123]} normal {var['{'] // 0xff} \"xzcb\" 'xzcb' {var['}'] + 1} text" +f"{expr1 if True or False else expr2} wow {','.join(c.lower() for c in 'asdf')}" +f"hello {expr:.2f} yes {(lambda: 0b1)():#03x} lol {var!r}" + # Doctests. """ From 47e958df05d13dfbceb4df6b06deb8d86b3b1fac Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 17 Feb 2017 16:41:58 +0800 Subject: [PATCH 057/103] align strings, remove tabs --- syntax/python.vim | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 1ee46bc..2ddb1ab 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -319,35 +319,35 @@ if s:Python2Syntax() syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*[lL]\=\>' display syn match pythonBinError '\<0[bB][01]*[2-9]\d*[lL]\=\>' display - syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display - syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display + syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display + syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display else syn match pythonOctError '\<0[oO]\=\o*\D\+\d*\>' display " pythonHexError comes after pythonOctError so that 0xffffl is pythonHexError syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display syn match pythonBinError '\<0[bB][01]*\D\+\d*\>' display - syn match pythonHexNumber '\<0[xX][_0-9a-fA-F]*\x\>' display + syn match pythonHexNumber '\<0[xX][_0-9a-fA-F]*\x\>' display syn match pythonOctNumber '\<0[oO][_0-7]*\o\>' display syn match pythonBinNumber '\<0[bB][_01]*[01]\>' display - syn match pythonNumberError '\<\d[_0-9]*\D\>' display - syn match pythonNumberError '\<0[_0-9]\+\>' display - syn match pythonNumberError '\<0_x\S*\>' display - syn match pythonNumberError '\<0[bBxXoO][_0-9a-fA-F]*_\>' display - syn match pythonNumberError '\<\d[_0-9]*_\>' display + syn match pythonNumberError '\<\d[_0-9]*\D\>' display + syn match pythonNumberError '\<0[_0-9]\+\>' display + syn match pythonNumberError '\<0_x\S*\>' display + syn match pythonNumberError '\<0[bBxXoO][_0-9a-fA-F]*_\>' display + syn match pythonNumberError '\<\d[_0-9]*_\>' display syn match pythonNumber '\<\d\>' display - syn match pythonNumber '\<[1-9][_0-9]*\d\>' display - syn match pythonNumber '\<\d[jJ]\>' display - syn match pythonNumber '\<[1-9][_0-9]*\d[jJ]\>' display + syn match pythonNumber '\<[1-9][_0-9]*\d\>' display + syn match pythonNumber '\<\d[jJ]\>' display + syn match pythonNumber '\<[1-9][_0-9]*\d[jJ]\>' display syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*\>' display syn match pythonBinError '\<0[bB][01]*[2-9]\d*\>' display - syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display + syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display endif " From 13616ab8a9243d5001166a22ea712795864a6c1a Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 17 Feb 2017 16:43:00 +0800 Subject: [PATCH 058/103] AUTHORS: Update --- AUTHORS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AUTHORS b/AUTHORS index 507400a..605a3bf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -15,9 +15,11 @@ Ihor Gorobets Jeroen Ruigrok van der Werven John Eikenberry Joongi Kim +lilydjwg Marc Weber Michael Doronin Neil Schemenauer +nfnty Pedro Algarvio Victor Salgado Will Gray From 643005bd235982e9cfce1672bd8db24cc1f26a1f Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 17 Feb 2017 15:21:07 +0100 Subject: [PATCH 059/103] docs: Add Python 3.6 to features --- README.md | 5 +++-- doc/python-syntax.txt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 588ce32..c75d621 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,10 @@ This is an enhanced version of the original Vim 6.1 Python syntax highlighting Features -------- -* Added support for Python 3 syntax highlighting +* Added support for Python 3 syntax highlighting, including 3.6 f-strings + and numbers with underscores * Added commands `Python2Syntax` and `Python3Syntax` allowing to easily switch - between Python 2 and Python 3. + between Python 2 and Python 3 * Updated string highlighting * Enhanced special symbols highlighting inside strings * Enhanced highlighting of numeric constants diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 2731c8e..ca81a6a 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -9,9 +9,10 @@ This is an enhanced version of the original Vim 6.1 Python syntax highlighting Features -------- -* Added support for Python 3 syntax highlighting +* Added support for Python 3 syntax highlighting, including 3.6 f-strings + and numbers with underscores * Added commands `Python2Syntax` and `Python3Syntax` allowing to easily switch - between Python 2 and Python 3. + between Python 2 and Python 3 * Updated string highlighting * Enhanced special symbols highlighting inside strings * Enhanced highlighting of numeric constants From b557c4607874ed735beddbe533ac5963a9d09bb7 Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 17 Feb 2017 15:40:09 +0100 Subject: [PATCH 060/103] docs: Update `Features` list formatting --- README.md | 28 ++++++++++++++-------------- doc/python-syntax.txt | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index c75d621..3bff3c2 100644 --- a/README.md +++ b/README.md @@ -7,26 +7,26 @@ This is an enhanced version of the original Vim 6.1 Python syntax highlighting Features -------- -* Added support for Python 3 syntax highlighting, including 3.6 f-strings - and numbers with underscores -* Added commands `Python2Syntax` and `Python3Syntax` allowing to easily switch - between Python 2 and Python 3 -* Updated string highlighting -* Enhanced special symbols highlighting inside strings -* Enhanced highlighting of numeric constants -* Added optional highlighting for %-formatting inside strings -* Added highlighting for magic comments: source code encoding and - shebangs (`#!`) -* Added highlighting for new exceptions and builtins -* Added highlighting for doctests -* Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 -* Added highlighting for the following errors: +* Enhanced highlighting for: + * Strings + * Special symbols inside strings + * Numeric constants +* Added support for: + * Python 3 + * Numbers with underscores + * String %-formatting and f-strings + * Magic comments: source code encoding and shebangs + * New exceptions and builtins + * Doctests + * `@decorator` syntax +* Highlighting of the following errors: * Invalid symbols in source file * Mixing spaces and tabs * Invalid numeric constants * Invalid %-formatting inside strings * Invalid variable names * Trailing spaces (Enabled with `g:python_highlight_space_errors`) +* Commands for easy switching between versions Folding is done by the plugin [SimpylFold](https://github.com/tmhedberg/SimpylFold). diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index ca81a6a..9c573d7 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -9,26 +9,26 @@ This is an enhanced version of the original Vim 6.1 Python syntax highlighting Features -------- -* Added support for Python 3 syntax highlighting, including 3.6 f-strings - and numbers with underscores -* Added commands `Python2Syntax` and `Python3Syntax` allowing to easily switch - between Python 2 and Python 3 -* Updated string highlighting -* Enhanced special symbols highlighting inside strings -* Enhanced highlighting of numeric constants -* Added optional highlighting for %-formatting inside strings -* Added highlighting for magic comments: source code encoding and - shebangs (`#!`) -* Added highlighting for new exceptions and builtins -* Added highlighting for doctests -* Added highlighting for new `@decorator` syntax introduced in Python 2.4a2 -* Added highlighting for the following errors: +* Enhanced highlighting for: + * Strings + * Special symbols inside strings + * Numeric constants +* Added support for: + * Python 3 + * Numbers with underscores + * String %-formatting and f-strings + * Magic comments: source code encoding and shebangs + * New exceptions and builtins + * Doctests + * `@decorator` syntax +* Highlighting of the following errors: * Invalid symbols in source file * Mixing spaces and tabs * Invalid numeric constants * Invalid %-formatting inside strings * Invalid variable names * Trailing spaces (Enabled with `g:python_highlight_space_errors`) +* Commands for easy switching between versions Folding is done by the plugin SimpylFold (https://github.com/tmhedberg/SimpylFold). From 08324146d496d1a8bc88c9f87ce8e800bbfbbe21 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 19 Feb 2017 12:36:50 +0100 Subject: [PATCH 061/103] `pythonClassVaraible` -> `pythonClassVariable` Fixes #4 --- syntax/python.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 2ddb1ab..ee2c6b5 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -59,7 +59,7 @@ endif " syn keyword pythonInstanceVariable self -syn keyword pythonClassVaraible cls +syn keyword pythonClassVariable cls syn keyword pythonStatement break continue del syn keyword pythonStatement exec return syn keyword pythonStatement pass yield @@ -104,7 +104,7 @@ syn region FunctionParameters start='(\zs' end='\ze)' display contains= \ OptionalParameters, \ pythonRepeat, \ pythonInstanceVariable, - \ pythonClassVaraible, + \ pythonClassVariable, \ pythonConditional, \ pythonComment, \ pythonOperator, @@ -519,7 +519,7 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonExClass Structure HiLink pythonInstanceVariable htmlTagN - HiLink pythonClassVaraible htmlTagN + HiLink pythonClassVariable htmlTagN HiLink OptionalParameters htmlTagN delcommand HiLink From 82836bb8116c5b38dc106512446c815643bc9565 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 19 Feb 2017 13:40:57 +0100 Subject: [PATCH 062/103] Move comment to right position --- syntax/python.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index ee2c6b5..afd6a8d 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -70,15 +70,15 @@ 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 pythonException try except finally syn keyword pythonOperator and in is not or syn match pythonStatement '\s*\([.,]\)\@' +" 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 match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters -syn match pythonRaiseFromStatement 'from\>' +syn match pythonRaiseFromStatement '\' syn match pythonImport '^\s*\zsfrom\>' From 82e689a2520fcdf14a6dc88553999d08aca4d4de Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 19 Feb 2017 13:49:51 +0100 Subject: [PATCH 063/103] docs: Use a line length of max 78 characters --- doc/python-syntax.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 9c573d7..50c4d3b 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -1,7 +1,7 @@ *python-syntax.txt* Python syntax highlighting -=============================================================================== -Introduction *python-syntax* *ft-python-syntax* *python.vim* +============================================================================== +Introduction *python-syntax* *ft-python-syntax* *python.vim* This is an enhanced version of the original Vim 6.1 Python syntax highlighting `python.vim` by Neil Schemenauer. @@ -33,8 +33,8 @@ Features Folding is done by the plugin SimpylFold (https://github.com/tmhedberg/SimpylFold). -=============================================================================== -Configuration *python-syntax-configuration* +============================================================================== +Configuration *python-syntax-configuration* Option variables ---------------- From 15c69d6c70ea5a7c242caf52298f57e97f8a6e59 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 19 Feb 2017 14:17:38 +0100 Subject: [PATCH 064/103] tests: Remove `from` from keywords Fixes #5 --- tests/test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test.py b/tests/test.py index ff52fd6..83e43cc 100644 --- a/tests/test.py +++ b/tests/test.py @@ -9,10 +9,12 @@ # Keywords. 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 +for while if elif else import as try except finally and in is not or from test import var as name +raise Exception from ex + yield from def functionname From 826ece295de3093b89db34d8a96e72920661df09 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 19 Feb 2017 14:27:32 +0100 Subject: [PATCH 065/103] tests: Fix builtin functions, Separate builtin functions and types Fixes #5 --- tests/test.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/test.py b/tests/test.py index 83e43cc..65fa4c3 100644 --- a/tests/test.py +++ b/tests/test.py @@ -31,15 +31,18 @@ async def Test True False Ellipsis None NotImplemented -# Builtin function and types. - -__import__ abs all any apply basestring bool buffer callable chr classmethod -cmp coerce compile complex delattr dict dir divmod enumerate eval execfile file -filter float frozenset getattr globals hasattr hash help hex id input int -intern isinstance issubclass iter len list locals long map max min object oct -open ord pow property range raw_input reduce reload repr reversed round set -setattr slice sorted staticmethod str sum super tuple type unichr unicode vars -xrange zip +# Bultin types + +bool float frozenset dict int list object str tuple set + +# Builtin functions + +__import__() abs() all() any() apply() basestring() buffer() callable() chr() classmethod() +cmp() coerce() compile() complex() delattr() dir() divmod() enumerate() eval() execfile() file() +filter() getattr() globals() hasattr() hash() help() hex() id() input() intern() isinstance() +issubclass() iter() len() locals() long() map() max() min() oct() open() ord() pow() property() +range() raw_input() reduce() reload() repr() reversed() round() setattr() slice() sorted() +staticmethod() sum() super() type() unichr() unicode() vars() xrange() zip() # Builtin exceptions and warnings. From 51f3be4ec0a9b123e21a8709fc4b371fcac67cb3 Mon Sep 17 00:00:00 2001 From: nfnty Date: Tue, 21 Feb 2017 16:36:47 +0100 Subject: [PATCH 066/103] syntax: `(\.)@ `\.@' + syn match pythonStatement '\v\.@' syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters display contained syn match pythonStatement '\' nextgroup=pythonFunction skipwhite syn match pythonStatement '\' @@ -358,7 +358,7 @@ if s:Enabled('g:python_highlight_builtin_objs') syn keyword pythonNone None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v(\.)@' nextgroup=FunctionParameters + syn match pythonBuiltinObj '\v\.@' nextgroup=FunctionParameters syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif @@ -369,27 +369,27 @@ endif if s:Enabled('g:python_highlight_builtin_funcs') if s:Python2Syntax() - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters if s:Enabled('g:python_print_as_function') - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters endif else - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters endif - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v(\.)@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters endif " @@ -398,36 +398,36 @@ endif if s:Enabled('g:python_highlight_exceptions') if s:Python2Syntax() - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters else - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters endif - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters - syn match pythonExClass '\v(\.)@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters endif if s:Enabled('g:python_slow_sync') From 8f6af0397797b39cb3e6611ff61dd29c768eccc3 Mon Sep 17 00:00:00 2001 From: nfnty Date: Tue, 21 Feb 2017 16:46:11 +0100 Subject: [PATCH 067/103] syntax: Remove unneeded capture groups, Always use non-capture --- syntax/python.vim | 96 +++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 0b4697c..1f6ed50 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -72,7 +72,7 @@ syn keyword pythonRepeat for while syn keyword pythonConditional if elif else syn keyword pythonException try except finally syn keyword pythonOperator and in is not or -syn match pythonStatement '\s*\([.,]\)\@' +syn match pythonStatement '\s*[.,]\@' " 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 @@ -232,8 +232,8 @@ if s:Python2Syntax() syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell - syn match pythonUniRawEscape '\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}' display contained - syn match pythonUniRawEscapeError '\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X' display contained + syn match pythonUniRawEscape '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{4}' display contained + syn match pythonUniRawEscapeError '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{,3}\X' display contained endif " Python 2/3 raw strings @@ -358,7 +358,7 @@ if s:Enabled('g:python_highlight_builtin_objs') syn keyword pythonNone None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v\.@' nextgroup=FunctionParameters + syn match pythonBuiltinObj '\v\.@' nextgroup=FunctionParameters syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif @@ -369,27 +369,27 @@ endif if s:Enabled('g:python_highlight_builtin_funcs') if s:Python2Syntax() - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters if s:Enabled('g:python_print_as_function') - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters endif else - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters endif - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters endif " @@ -398,36 +398,36 @@ endif if s:Enabled('g:python_highlight_exceptions') if s:Python2Syntax() - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters else - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters endif - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + syn match pythonExClass '\v\.@' nextgroup=FunctionParameters endif if s:Enabled('g:python_slow_sync') From 750e4f1d67454a5a66718521ece7599f3dffbae8 Mon Sep 17 00:00:00 2001 From: nfnty Date: Tue, 21 Feb 2017 16:50:45 +0100 Subject: [PATCH 068/103] syntax: Remove duplicate line, Minor reorder --- syntax/python.vim | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 1f6ed50..6208ab8 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -177,7 +177,6 @@ endif if s:Python2Syntax() " Python 2 strings syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+[bB]\="""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell @@ -185,8 +184,8 @@ else " Python 3 byte strings syn region pythonBytes start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell syn region pythonBytes start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell - syn region pythonBytes start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell syn region pythonBytes start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell + syn region pythonBytes start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell syn match pythonBytesError '.\+' display contained syn match pythonBytesContent '[\u0000-\u00ff]\+' display contained contains=pythonBytesEscape,pythonBytesEscapeError @@ -210,27 +209,27 @@ if s:Python2Syntax() " Python 2 Unicode strings syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonUniString start=+[uU]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonUniString start=+[uU]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell else " Python 3 strings syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonString start=+'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonFString start=+[fF]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonFString start=+[fF]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonFString start=+[fF]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonFString start=+[fF]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonFString start=+[fF]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell endif if s:Python2Syntax() " Python 2 Unicode raw strings syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell - syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn match pythonUniRawEscape '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{4}' display contained syn match pythonUniRawEscapeError '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{,3}\X' display contained @@ -240,18 +239,18 @@ endif if s:Python2Syntax() syn region pythonRawString start=+[bB]\=[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawString start=+[bB]\=[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawString start=+[bB]\=[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell syn region pythonRawString start=+[bB]\=[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawString start=+[bB]\=[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell else syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawString start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell syn region pythonRawString start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawString start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell syn region pythonRawBytes start=+[bB][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawBytes start=+[bB][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawBytes start=+[bB][rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell syn region pythonRawBytes start=+[bB][rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawBytes start=+[bB][rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell endif syn match pythonRawEscape +\\['"]+ display transparent contained From f5b242e57b4263c9a5fcfa0ad4e9d416db552ce1 Mon Sep 17 00:00:00 2001 From: nfnty Date: Tue, 21 Feb 2017 17:24:11 +0100 Subject: [PATCH 069/103] syntax: Combine regexes Improves performance --- syntax/python.vim | 58 ++++++++++++----------------------------------- tests/test.py | 2 +- 2 files changed, 15 insertions(+), 45 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 6208ab8..282e58a 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -367,28 +367,19 @@ endif " if s:Enabled('g:python_highlight_builtin_funcs') + let s:funcs_re = '__import__|abs|all|any|bin|chr|classmethod|cmp|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|min|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' + if s:Python2Syntax() - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + let s:funcs_re .= '|apply|basestring|buffer|callable|coerce|execfile|file|help|intern|long|raw_input|reduce|reload|unichr|unicode|xrange' if s:Enabled('g:python_print_as_function') - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + let s:funcs_re .= '|print' endif else - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + let s:funcs_re .= '|ascii|exec|memoryview|print' endif - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters - syn match pythonBuiltinFunc '\v\.@\ze\(' nextgroup=FunctionParameters + + execute 'syn match pythonBuiltinFunc ''\v\.@\ze\('' nextgroup=FunctionParameters' + unlet s:funcs_re endif " @@ -396,37 +387,16 @@ endif " if s:Enabled('g:python_highlight_exceptions') + let s:exs_re = 'BaseException|Exception|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|BufferError|EOFError|FloatingPointError|GeneratorExit|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|ReferenceError|RuntimeError|StopIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|VMSError|WindowsError|ZeroDivisionError|Warning|UserWarning|BytesWarning|DeprecationWarning|PendingDepricationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning' + if s:Python2Syntax() - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + let s:exs_re .= '|StandardError' else - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + let s:exs_re .= '|BlockingIOError|ChildProcessError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|FileExistsError|FileNotFoundError|InterruptedError|IsADirectoryError|NotADirectoryError|PermissionError|ProcessLookupError|TimeoutError|StopAsyncIteration|ResourceWarning' endif - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters - syn match pythonExClass '\v\.@' nextgroup=FunctionParameters + execute 'syn match pythonExClass ''\v\.@'' nextgroup=FunctionParameters' + unlet s:exs_re endif if s:Enabled('g:python_slow_sync') diff --git a/tests/test.py b/tests/test.py index 65fa4c3..03ce8b6 100644 --- a/tests/test.py +++ b/tests/test.py @@ -40,7 +40,7 @@ async def Test __import__() abs() all() any() apply() basestring() buffer() callable() chr() classmethod() cmp() coerce() compile() complex() delattr() dir() divmod() enumerate() eval() execfile() file() filter() getattr() globals() hasattr() hash() help() hex() id() input() intern() isinstance() -issubclass() iter() len() locals() long() map() max() min() oct() open() ord() pow() property() +issubclass() iter() len() locals() long() map() max() min() oct() open() ord() pow() print() property() range() raw_input() reduce() reload() repr() reversed() round() setattr() slice() sorted() staticmethod() sum() super() type() unichr() unicode() vars() xrange() zip() From d7c1b4a9cdb7d179bedb2ae86735374349cb7311 Mon Sep 17 00:00:00 2001 From: nfnty Date: Tue, 21 Feb 2017 17:31:37 +0100 Subject: [PATCH 070/103] syntax: Skip escaped triple quotes --- syntax/python.vim | 40 ++++++++++++++++++++-------------------- tests/test.py | 9 +++++++-- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 282e58a..804b7a8 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -178,14 +178,14 @@ if s:Python2Syntax() " Python 2 strings syn region pythonString start=+[bB]\='+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+[bB]\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+[bB]\="""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell - syn region pythonString start=+[bB]\='''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonString start=+[bB]\="""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonString start=+[bB]\='''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell else " Python 3 byte strings syn region pythonBytes start=+[bB]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell syn region pythonBytes start=+[bB]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesError,pythonBytesContent,@Spell - syn region pythonBytes start=+[bB]'''+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell - syn region pythonBytes start=+[bB]"""+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonBytes start=+[bB]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest,pythonSpaceError,@Spell + syn region pythonBytes start=+[bB]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesError,pythonBytesContent,pythonDocTest2,pythonSpaceError,@Spell syn match pythonBytesError '.\+' display contained syn match pythonBytesContent '[\u0000-\u00ff]\+' display contained contains=pythonBytesEscape,pythonBytesEscapeError @@ -209,27 +209,27 @@ if s:Python2Syntax() " Python 2 Unicode strings syn region pythonUniString start=+[uU]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonUniString start=+[uU]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonUniString start=+[uU]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell - syn region pythonUniString start=+[uU]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonUniString start=+[uU]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonUniString start=+[uU]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell else " Python 3 strings syn region pythonString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonString start=+'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell - syn region pythonString start=+"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonString start=+'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonString start=+"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn region pythonFString start=+[fF]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell syn region pythonFString start=+[fF]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell - syn region pythonFString start=+[fF]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell - syn region pythonFString start=+[fF]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonFString start=+[fF]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonFString start=+[fF]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell endif if s:Python2Syntax() " Python 2 Unicode raw strings syn region pythonUniRawString start=+[uU][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell syn region pythonUniRawString start=+[uU][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,pythonUniRawEscape,pythonUniRawEscapeError,@Spell - syn region pythonUniRawString start=+[uU][rR]'''+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell - syn region pythonUniRawString start=+[uU][rR]"""+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell + syn region pythonUniRawString start=+[uU][rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest,pythonSpaceError,@Spell + syn region pythonUniRawString start=+[uU][rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonUniRawEscape,pythonUniRawEscapeError,pythonDocTest2,pythonSpaceError,@Spell syn match pythonUniRawEscape '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{4}' display contained syn match pythonUniRawEscapeError '\%([^\\]\%(\\\\\)*\)\@<=\\u\x\{,3}\X' display contained @@ -239,18 +239,18 @@ endif if s:Python2Syntax() syn region pythonRawString start=+[bB]\=[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawString start=+[bB]\=[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawString start=+[bB]\=[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell - syn region pythonRawString start=+[bB]\=[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell + syn region pythonRawString start=+[bB]\=[rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawString start=+[bB]\=[rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell else syn region pythonRawString start=+[rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawString start=+[rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawString start=+[rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell - syn region pythonRawString start=+[rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell + syn region pythonRawString start=+[rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawString start=+[rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell syn region pythonRawBytes start=+[bB][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawBytes start=+[bB][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawBytes start=+[bB][rR]'''+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell - syn region pythonRawBytes start=+[bB][rR]"""+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell + syn region pythonRawBytes start=+[bB][rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawBytes start=+[bB][rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell endif syn match pythonRawEscape +\\['"]+ display transparent contained @@ -293,8 +293,8 @@ endif if s:Enabled('g:python_highlight_doctests') " DocTests - syn region pythonDocTest start='^\s*>>>' end=+'''+he=s-1 end='^\s*$' contained - syn region pythonDocTest2 start='^\s*>>>' end=+"""+he=s-1 end='^\s*$' contained + syn region pythonDocTest start='^\s*>>>' skip=+\\'+ end=+'''+he=s-1 end='^\s*$' contained + syn region pythonDocTest2 start='^\s*>>>' skip=+\\"+ end=+"""+he=s-1 end='^\s*$' contained endif " diff --git a/tests/test.py b/tests/test.py index 03ce8b6..59a2981 100644 --- a/tests/test.py +++ b/tests/test.py @@ -79,12 +79,17 @@ async def Test # Strings " test " ' test ' +"test\ +test" +'test\ +test' + """ test -""" +\"""" ''' test -''' +\'''' " \a\b\c\"\'\n\r \x34\077 \08 \xag" r" \" \' " From 4eee0bdaa192015c20f9b88dc938267a7a8663db Mon Sep 17 00:00:00 2001 From: nfnty Date: Tue, 21 Feb 2017 23:24:01 +0100 Subject: [PATCH 071/103] syntax: Remove duplicate `yield` Fixes #6 --- syntax/python.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 804b7a8..855f6fc 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -72,7 +72,6 @@ syn keyword pythonRepeat for while syn keyword pythonConditional if elif else syn keyword pythonException try except finally syn keyword pythonOperator and in is not or -syn match pythonStatement '\s*[.,]\@' " 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 From 5ffc69c38fb334cbb5bf1471287e676de7c06473 Mon Sep 17 00:00:00 2001 From: monkoose Date: Wed, 22 Feb 2017 12:40:59 +0200 Subject: [PATCH 072/103] Add option variable for class variables --- README.md | 1 + doc/python-syntax.txt | 3 +++ syntax/python.vim | 16 ++++++++-------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3bff3c2..fcfb310 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ let g:python_highlight_all = 1 | `g:python_highlight_indent_errors` | Highlight indentation errors | `0` | | `g:python_highlight_space_errors` | Highlight trailing spaces | `0` | | `g:python_highlight_doctests` | Highlight doc-tests | `0` | +| `g:python_highlight_class_vars` | Highlight class variables `self` and `cls` | `0` | | `g:python_highlight_all` | Enable all highlight options above, except for previously set. | `0` | | `g:python_highlight_file_headers_as_comments` | Highlight shebang and coding headers as comments | `0` | | `g:python_slow_sync` | Disable for slow machines | `1` | diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 50c4d3b..6a10348 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -86,6 +86,9 @@ following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: > `g:python_highlight_doctests` (default `0`) Highlight doc-tests +`g:python_highlight_class_vars` (default `0`) + Highlight class variables `self` and `cls` + `g:python_highlight_all` (default `0`) Enable all highlight options above, except for previously set. diff --git a/syntax/python.vim b/syntax/python.vim index 855f6fc..86de455 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -52,14 +52,13 @@ if s:Enabled('g:python_highlight_all') call s:EnableByDefault('g:python_highlight_space_errors') call s:EnableByDefault('g:python_highlight_doctests') call s:EnableByDefault('g:python_print_as_function') + call s:EnableByDefault('g:python_highlight_class_vars') endif " " Keywords " -syn keyword pythonInstanceVariable self -syn keyword pythonClassVariable cls syn keyword pythonStatement break continue del syn keyword pythonStatement exec return syn keyword pythonStatement pass yield @@ -68,6 +67,9 @@ syn keyword pythonStatement global assert syn keyword pythonStatement lambda syn keyword pythonStatement with syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite +if s:Enabled('g:python_highlight_class_vars') + syn keyword pythonClassVar self cls +endif syn keyword pythonRepeat for while syn keyword pythonConditional if elif else syn keyword pythonException try except finally @@ -102,8 +104,7 @@ syn region FunctionParameters start='(\zs' end='\ze)' display contains= \ FunctionParameters, \ OptionalParameters, \ pythonRepeat, - \ pythonInstanceVariable, - \ pythonClassVariable, + \ pythonClassVar, \ pythonConditional, \ pythonComment, \ pythonOperator, @@ -125,7 +126,7 @@ syn region FunctionParameters start='(\zs' end='\ze)' display contains= \ pythonNone, \ pythonBuiltinFunc, \ pythonBoolean nextgroup=pythonRaiseFromStatement display contained -syn match OptionalParameters /\i*\ze=/ display contained +syn match OptionalParameters /\i\+\ze=/ display contained " " Decorators (new in Python 2.4) " @@ -486,9 +487,8 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonBuiltinFunc Function HiLink pythonExClass Structure - HiLink pythonInstanceVariable htmlTagN - HiLink pythonClassVariable htmlTagN - HiLink OptionalParameters htmlTagN + HiLink pythonClassVar Identifier + HiLink OptionalParameters Identifier delcommand HiLink endif From 32de302135ad15a1c37dbd9d03946e4472c17efe Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 23 Feb 2017 07:47:56 +0100 Subject: [PATCH 073/103] docs: Remove duplicate option variable --- README.md | 1 - doc/python-syntax.txt | 3 --- 2 files changed, 4 deletions(-) diff --git a/README.md b/README.md index fcfb310..615218c 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,6 @@ let g:python_highlight_all = 1 | `g:python_version_2` | Python 2 mode | `0` | | `b:python_version_2` | Python 2 mode (buffer local) | `0` | | `g:python_highlight_builtins` | Highlight builtin functions and objects | `0` | -| `g:python_highlight_builtins` | Highlight builtin functions and objects | `0` | | `g:python_highlight_builtin_objs` | Highlight builtin objects only | `0` | | `g:python_highlight_builtin_funcs` | Highlight builtin functions only | `0` | | `g:python_highlight_exceptions` | Highlight standard exceptions | `0` | diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 6a10348..9b97d18 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -56,9 +56,6 @@ following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: > `g:python_highlight_builtins` (default `0`) Highlight builtin functions and objects -`g:python_highlight_builtins` (default `0`) - Highlight builtin functions and objects - `g:python_highlight_builtin_objs` (default `0`) Highlight builtin objects only From 013c9ff33f884f68448ba7014bd5ddb68ff354b4 Mon Sep 17 00:00:00 2001 From: nfnty Date: Thu, 23 Feb 2017 08:21:16 +0100 Subject: [PATCH 074/103] syntax: Fix function args --- syntax/python.vim | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 86de455..7951f2b 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -78,7 +78,7 @@ syn keyword pythonOperator and in is not or " we provide a dummy group here to avoid crashing pyrex.vim. syn keyword pythonInclude import syn keyword pythonImport import -syn match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters +syn match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=pythonFunctionArgs syn match pythonRaiseFromStatement '\' syn match pythonImport '^\s*\zsfrom\>' @@ -89,53 +89,28 @@ if s:Python2Syntax() syn keyword pythonStatement print endif syn keyword pythonImport as - syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters display contained + syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=pythonFunctionArgs display contained else syn keyword pythonStatement as nonlocal syn match pythonStatement '\v\.@' - syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=FunctionParameters display contained + syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=pythonFunctionArgs display contained syn match pythonStatement '\' nextgroup=pythonFunction skipwhite syn match pythonStatement '\' syn match pythonStatement '\' syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc endif -syn region FunctionParameters start='(\zs' end='\ze)' display contains= - \ FunctionParameters, - \ OptionalParameters, - \ pythonRepeat, - \ pythonClassVar, - \ pythonConditional, - \ pythonComment, - \ pythonOperator, - \ pythonNumber, - \ pythonNumberError, - \ pythonFloat, - \ pythonHexNumber, - \ pythonStatement, - \ pythonOctNumber, - \ pythonString, - \ pythonRawString, - \ pythonUniString, - \ pythonExClass, - \ pythonUniRawString, - \ pythonNumber, - \ pythonRawString, - \ pythonBytes, - \ pythonBuiltinObj, - \ pythonNone, - \ pythonBuiltinFunc, - \ pythonBoolean nextgroup=pythonRaiseFromStatement display contained -syn match OptionalParameters /\i\+\ze=/ display contained +syn region pythonFunctionArgs start='('rs=s+1 end=')'re=e-1 contains=pythonFunctionArgs,pythonFunctionKwargs,pythonRepeat,pythonClassVar,pythonConditional,pythonComment,pythonOperator,pythonNumber,pythonNumberError,pythonFloat,pythonHexNumber,pythonStatement,pythonOctNumber,pythonString,pythonRawString,pythonUniString,pythonExClass,pythonUniRawString,pythonNumber,pythonRawString,pythonBytes,pythonBuiltinObj,pythonNone,pythonBuiltinFunc,pythonBoolean nextgroup=pythonRaiseFromStatement display contained +syn match pythonFunctionKwargs /\i\+\ze=/ display contained " " Decorators (new in Python 2.4) " syn match pythonDecorator '^\s*\zs@' display nextgroup=pythonDottedName skipwhite if s:Python2Syntax() - syn match pythonDottedName '[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*' display contained nextgroup=FunctionParameters + syn match pythonDottedName '[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*' display contained nextgroup=pythonFunctionArgs else - syn match pythonDottedName '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*' display contained nextgroup=FunctionParameters + syn match pythonDottedName '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*' display contained nextgroup=pythonFunctionArgs endif syn match pythonDot '\.' display containedin=pythonDottedName @@ -357,7 +332,7 @@ if s:Enabled('g:python_highlight_builtin_objs') syn keyword pythonNone None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v\.@' nextgroup=FunctionParameters + syn match pythonBuiltinObj '\v\.@' nextgroup=pythonFunctionArgs syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif @@ -378,7 +353,7 @@ if s:Enabled('g:python_highlight_builtin_funcs') let s:funcs_re .= '|ascii|exec|memoryview|print' endif - execute 'syn match pythonBuiltinFunc ''\v\.@\ze\('' nextgroup=FunctionParameters' + execute 'syn match pythonBuiltinFunc ''\v\.@\ze\('' nextgroup=pythonFunctionArgs' unlet s:funcs_re endif @@ -395,7 +370,7 @@ if s:Enabled('g:python_highlight_exceptions') let s:exs_re .= '|BlockingIOError|ChildProcessError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|FileExistsError|FileNotFoundError|InterruptedError|IsADirectoryError|NotADirectoryError|PermissionError|ProcessLookupError|TimeoutError|StopAsyncIteration|ResourceWarning' endif - execute 'syn match pythonExClass ''\v\.@'' nextgroup=FunctionParameters' + execute 'syn match pythonExClass ''\v\.@'' nextgroup=pythonFunctionArgs' unlet s:exs_re endif @@ -488,7 +463,7 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonExClass Structure HiLink pythonClassVar Identifier - HiLink OptionalParameters Identifier + HiLink pythonFunctionKwargs Identifier delcommand HiLink endif From c8300301fb9e2c18988eac4f15c0e15e4abd48bd Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 24 Feb 2017 10:47:27 +0100 Subject: [PATCH 075/103] Highlight builtin functions without braces --- syntax/python.vim | 2 +- tests/test.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 7951f2b..bdc9033 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -353,7 +353,7 @@ if s:Enabled('g:python_highlight_builtin_funcs') let s:funcs_re .= '|ascii|exec|memoryview|print' endif - execute 'syn match pythonBuiltinFunc ''\v\.@\ze\('' nextgroup=pythonFunctionArgs' + execute 'syn match pythonBuiltinFunc ''\v\.@'' nextgroup=pythonFunctionArgs' unlet s:funcs_re endif diff --git a/tests/test.py b/tests/test.py index 59a2981..964eacd 100644 --- a/tests/test.py +++ b/tests/test.py @@ -37,12 +37,12 @@ async def Test # Builtin functions -__import__() abs() all() any() apply() basestring() buffer() callable() chr() classmethod() -cmp() coerce() compile() complex() delattr() dir() divmod() enumerate() eval() execfile() file() -filter() getattr() globals() hasattr() hash() help() hex() id() input() intern() isinstance() -issubclass() iter() len() locals() long() map() max() min() oct() open() ord() pow() print() property() -range() raw_input() reduce() reload() repr() reversed() round() setattr() slice() sorted() -staticmethod() sum() super() type() unichr() unicode() vars() xrange() zip() +__import__ abs all any apply basestring buffer callable chr classmethod +cmp coerce compile complex delattr dir divmod enumerate eval execfile file +filter getattr globals hasattr hash help hex id input intern isinstance +issubclass iter len locals long map max min oct open ord pow print property +range raw_input reduce reload repr reversed round setattr slice sorted +staticmethod sum super type unichr unicode vars xrange zip # Builtin exceptions and warnings. From 51ea0dab8418a111a91ba4a7b483a912eb96ad6e Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 24 Feb 2017 12:50:51 +0100 Subject: [PATCH 076/103] syntax: Remove `pythonFunctionArgs` as it's poorly implemented --- syntax/python.vim | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index bdc9033..27681c3 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -78,7 +78,7 @@ syn keyword pythonOperator and in is not or " we provide a dummy group here to avoid crashing pyrex.vim. syn keyword pythonInclude import syn keyword pythonImport import -syn match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=pythonFunctionArgs +syn match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' syn match pythonRaiseFromStatement '\' syn match pythonImport '^\s*\zsfrom\>' @@ -89,28 +89,26 @@ if s:Python2Syntax() syn keyword pythonStatement print endif syn keyword pythonImport as - syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=pythonFunctionArgs display contained + syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' display contained else syn keyword pythonStatement as nonlocal syn match pythonStatement '\v\.@' - syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' nextgroup=pythonFunctionArgs display contained + syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' display contained syn match pythonStatement '\' nextgroup=pythonFunction skipwhite syn match pythonStatement '\' syn match pythonStatement '\' syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc endif -syn region pythonFunctionArgs start='('rs=s+1 end=')'re=e-1 contains=pythonFunctionArgs,pythonFunctionKwargs,pythonRepeat,pythonClassVar,pythonConditional,pythonComment,pythonOperator,pythonNumber,pythonNumberError,pythonFloat,pythonHexNumber,pythonStatement,pythonOctNumber,pythonString,pythonRawString,pythonUniString,pythonExClass,pythonUniRawString,pythonNumber,pythonRawString,pythonBytes,pythonBuiltinObj,pythonNone,pythonBuiltinFunc,pythonBoolean nextgroup=pythonRaiseFromStatement display contained -syn match pythonFunctionKwargs /\i\+\ze=/ display contained " " Decorators (new in Python 2.4) " syn match pythonDecorator '^\s*\zs@' display nextgroup=pythonDottedName skipwhite if s:Python2Syntax() - syn match pythonDottedName '[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*' display contained nextgroup=pythonFunctionArgs + 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 nextgroup=pythonFunctionArgs + 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 @@ -332,7 +330,7 @@ if s:Enabled('g:python_highlight_builtin_objs') syn keyword pythonNone None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v\.@' nextgroup=pythonFunctionArgs + syn match pythonBuiltinObj '\v\.@' syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif @@ -353,7 +351,7 @@ if s:Enabled('g:python_highlight_builtin_funcs') let s:funcs_re .= '|ascii|exec|memoryview|print' endif - execute 'syn match pythonBuiltinFunc ''\v\.@'' nextgroup=pythonFunctionArgs' + execute 'syn match pythonBuiltinFunc ''\v\.@''' unlet s:funcs_re endif @@ -370,7 +368,7 @@ if s:Enabled('g:python_highlight_exceptions') let s:exs_re .= '|BlockingIOError|ChildProcessError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|FileExistsError|FileNotFoundError|InterruptedError|IsADirectoryError|NotADirectoryError|PermissionError|ProcessLookupError|TimeoutError|StopAsyncIteration|ResourceWarning' endif - execute 'syn match pythonExClass ''\v\.@'' nextgroup=pythonFunctionArgs' + execute 'syn match pythonExClass ''\v\.@''' unlet s:exs_re endif @@ -463,7 +461,6 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonExClass Structure HiLink pythonClassVar Identifier - HiLink pythonFunctionKwargs Identifier delcommand HiLink endif From f7105bd8604bbf82fa3f013c379cb6bd9c90cff4 Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 24 Feb 2017 13:55:46 +0100 Subject: [PATCH 077/103] Impplement operator highlighting Fixes #7 Closes #9 --- README.md | 1 + doc/python-syntax.txt | 3 +++ syntax/python.vim | 62 ++++++++++++++++++++++++------------------- tests/test.py | 24 ++++++++++++++--- 4 files changed, 58 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 615218c..6865100 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ let g:python_highlight_all = 1 | `g:python_highlight_space_errors` | Highlight trailing spaces | `0` | | `g:python_highlight_doctests` | Highlight doc-tests | `0` | | `g:python_highlight_class_vars` | Highlight class variables `self` and `cls` | `0` | +| `g:python_highlight_operators` | Highlight all operators | `0` | | `g:python_highlight_all` | Enable all highlight options above, except for previously set. | `0` | | `g:python_highlight_file_headers_as_comments` | Highlight shebang and coding headers as comments | `0` | | `g:python_slow_sync` | Disable for slow machines | `1` | diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index 9b97d18..c2688f6 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -86,6 +86,9 @@ following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: > `g:python_highlight_class_vars` (default `0`) Highlight class variables `self` and `cls` +`g:python_highlight_operators` (default `0`) + Highlight all operators + `g:python_highlight_all` (default `0`) Enable all highlight options above, except for previously set. diff --git a/syntax/python.vim b/syntax/python.vim index 27681c3..882d9e2 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -53,6 +53,7 @@ if s:Enabled('g:python_highlight_all') call s:EnableByDefault('g:python_highlight_doctests') call s:EnableByDefault('g:python_print_as_function') call s:EnableByDefault('g:python_highlight_class_vars') + call s:EnableByDefault('g:python_highlight_operators') endif " @@ -73,7 +74,6 @@ endif syn keyword pythonRepeat for while syn keyword pythonConditional if elif else syn keyword pythonException try except finally -syn keyword pythonOperator and in is not or " 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 @@ -83,7 +83,6 @@ syn match pythonRaiseFromStatement '\' syn match pythonImport '^\s*\zsfrom\>' - if s:Python2Syntax() if !s:Enabled('g:python_print_as_function') syn keyword pythonStatement print @@ -100,6 +99,16 @@ else syn cluster pythonExpression contains=pythonStatement,pythonRepeat,pythonConditional,pythonOperator,pythonNumber,pythonHexNumber,pythonOctNumber,pythonBinNumber,pythonFloat,pythonString,pythonBytes,pythonBoolean,pythonBuiltinObj,pythonBuiltinFunc endif + +" +" Operators +" +syn keyword pythonOperator and in is not or +if s:Enabled('g:python_highlight_operators') + syn match pythonOperator '\V=\|-\|+\|*\|@\|/\|%\|&\||\|^\|~\|<\|>\|!=' +endif +syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([-=+*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|[]\+=\{2,}\|[]\{2,}=\+' display + " " Decorators (new in Python 2.4) " @@ -127,10 +136,7 @@ syn keyword pythonTodo TODO FIXME XXX contained " Errors " -syn match pythonError '\<\d\+\D\+\>' display -syn match pythonError '[$?]' display -syn match pythonError '[&|]\{2,}' display -syn match pythonError '[=]\{3,}' display +syn match pythonError '\<\d\+[^0-9[:space:]]\+\>' display " Mixing spaces and tabs also may be used for pretty formatting multiline " statements @@ -275,34 +281,34 @@ endif " if s:Python2Syntax() - syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\+\x*[lL]\=\>' display - syn match pythonOctError '\<0[oO]\=\o*\D\+\d*[lL]\=\>' display - syn match pythonBinError '\<0[bB][01]*\D\+\d*[lL]\=\>' display + syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\+\x*[lL]\=\>' display + syn match pythonOctError '\<0[oO]\=\o*\D\+\d*[lL]\=\>' display + syn match pythonBinError '\<0[bB][01]*\D\+\d*[lL]\=\>' display - syn match pythonHexNumber '\<0[xX]\x\+[lL]\=\>' display - syn match pythonOctNumber '\<0[oO]\o\+[lL]\=\>' display - syn match pythonBinNumber '\<0[bB][01]\+[lL]\=\>' display + syn match pythonHexNumber '\<0[xX]\x\+[lL]\=\>' display + syn match pythonOctNumber '\<0[oO]\o\+[lL]\=\>' display + syn match pythonBinNumber '\<0[bB][01]\+[lL]\=\>' display syn match pythonNumberError '\<\d\+\D[lL]\=\>' display syn match pythonNumber '\<\d[lL]\=\>' display syn match pythonNumber '\<[0-9]\d\+[lL]\=\>' display syn match pythonNumber '\<\d\+[lLjJ]\>' display - syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*[lL]\=\>' display - syn match pythonBinError '\<0[bB][01]*[2-9]\d*[lL]\=\>' display + syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*[lL]\=\>' display + syn match pythonBinError '\<0[bB][01]*[2-9]\d*[lL]\=\>' display - syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display - syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display + syn match pythonFloat '\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\+[eE][+-]\=\d\+[jJ]\=\>' display + syn match pythonFloat '\<\d\+\.\d*\%([eE][+-]\=\d\+\)\=[jJ]\=' display else - syn match pythonOctError '\<0[oO]\=\o*\D\+\d*\>' display + syn match pythonOctError '\<0[oO]\=\o*\D\+\d*\>' display " pythonHexError comes after pythonOctError so that 0xffffl is pythonHexError - syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display - syn match pythonBinError '\<0[bB][01]*\D\+\d*\>' display + syn match pythonHexError '\<0[xX]\x*[g-zG-Z]\x*\>' display + syn match pythonBinError '\<0[bB][01]*\D\+\d*\>' display - syn match pythonHexNumber '\<0[xX][_0-9a-fA-F]*\x\>' display - syn match pythonOctNumber '\<0[oO][_0-7]*\o\>' display - syn match pythonBinNumber '\<0[bB][_01]*[01]\>' display + syn match pythonHexNumber '\<0[xX][_0-9a-fA-F]*\x\>' display + syn match pythonOctNumber '\<0[oO][_0-7]*\o\>' display + syn match pythonBinNumber '\<0[bB][_01]*[01]\>' display syn match pythonNumberError '\<\d[_0-9]*\D\>' display syn match pythonNumberError '\<0[_0-9]\+\>' display @@ -314,12 +320,12 @@ else syn match pythonNumber '\<\d[jJ]\>' display syn match pythonNumber '\<[1-9][_0-9]*\d[jJ]\>' display - syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*\>' display - syn match pythonBinError '\<0[bB][01]*[2-9]\d*\>' display + syn match pythonOctError '\<0[oO]\=\o*[8-9]\d*\>' display + syn match pythonBinError '\<0[bB][01]*[2-9]\d*\>' display - syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display + syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display endif " diff --git a/tests/test.py b/tests/test.py index 964eacd..12b8fc8 100644 --- a/tests/test.py +++ b/tests/test.py @@ -9,7 +9,7 @@ # Keywords. with break continue del exec return pass print raise global assert lambda yield -for while if elif else import as try except finally and in is not or +for while if elif else import as try except finally from test import var as name @@ -66,6 +66,23 @@ async def Test @ декоратор @ декоратор.décorateur +# Operators + +and or in is not += +- + * ** @ / // % +& | ^ ~ << >> +< <= == != >= > + +# Erroneous operators + +$ ? +=== +-- ++ *** @@ /// %% +&& || ^^ ~~ <<< >>> +<== <<= !== !!= >== >>= +%- +- -+ + # Numbers 0 1 2 9 10 0x1f .3 12.34 0j 124j 34.2E-3 0b10 0o77 1023434 0x0 @@ -141,11 +158,10 @@ async def Test Test ''' -# Erroneous symbols or bad variable names. +# Erroneous variable names -$ ? 6xav +6xav -&& || === # Indentation errors. From b56fc25c55eb79bb3104f5d2804e52901e4ae282 Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 24 Feb 2017 16:02:37 +0100 Subject: [PATCH 078/103] docs: Update `Features` --- README.md | 5 ++++- doc/python-syntax.txt | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6865100..6b65699 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,15 @@ Features * New exceptions and builtins * Doctests * `@decorator` syntax + * Class variables such as `self` and `cls` + * Operators * Highlighting of the following errors: * Invalid symbols in source file - * Mixing spaces and tabs * Invalid numeric constants * Invalid %-formatting inside strings * Invalid variable names + * Invalid operators + * Mixing spaces and tabs * Trailing spaces (Enabled with `g:python_highlight_space_errors`) * Commands for easy switching between versions diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index c2688f6..f310e7a 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -21,12 +21,15 @@ Features * New exceptions and builtins * Doctests * `@decorator` syntax + * Class variables such as `self` and `cls` + * Operators * Highlighting of the following errors: * Invalid symbols in source file - * Mixing spaces and tabs * Invalid numeric constants * Invalid %-formatting inside strings * Invalid variable names + * Invalid operators + * Mixing spaces and tabs * Trailing spaces (Enabled with `g:python_highlight_space_errors`) * Commands for easy switching between versions From 39ba0d8a0484756fbd26b14219b7aa2312e0b49e Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 24 Feb 2017 22:55:41 +0100 Subject: [PATCH 079/103] Fix operators `<<=` and `>>=` --- syntax/python.vim | 2 +- tests/test.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 882d9e2..c0ea4e9 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -107,7 +107,7 @@ syn keyword pythonOperator and in is not or if s:Enabled('g:python_highlight_operators') syn match pythonOperator '\V=\|-\|+\|*\|@\|/\|%\|&\||\|^\|~\|<\|>\|!=' endif -syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([-=+*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|[]\+=\{2,}\|[]\{2,}=\+' display +syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([-=+*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|[]\+=\{2,}\|!\{2,}=\+' display " " Decorators (new in Python 2.4) diff --git a/tests/test.py b/tests/test.py index 12b8fc8..667ccb7 100644 --- a/tests/test.py +++ b/tests/test.py @@ -69,18 +69,22 @@ async def Test # Operators and or in is not -= + - + * ** @ / // % & | ^ ~ << >> < <= == != >= > += +-= += *= **= @= /= //= %= +&= |= ^= ~= <<= >>= + # Erroneous operators $ ? === -- ++ *** @@ /// %% && || ^^ ~~ <<< >>> -<== <<= !== !!= >== >>= +<== !== !!= >== %- +- -+ # Numbers From 941b582782fb0488f8e8212b60a3a3a93ca993d0 Mon Sep 17 00:00:00 2001 From: monkoose Date: Sun, 26 Feb 2017 00:21:07 +0200 Subject: [PATCH 080/103] syntax: Fix unicode function names --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index c0ea4e9..06c64a4 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -92,7 +92,7 @@ if s:Python2Syntax() else syn keyword pythonStatement as nonlocal syn match pythonStatement '\v\.@' - syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' display contained + syn match pythonFunction '\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*' display contained syn match pythonStatement '\' nextgroup=pythonFunction skipwhite syn match pythonStatement '\' syn match pythonStatement '\' From 26f2a6beb838da7a523daa029ccbe414107fb8ed Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 26 Feb 2017 09:53:33 +0100 Subject: [PATCH 081/103] syntax: Remove `pythonIdentifier` --- syntax/python.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 06c64a4..e4efe74 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -63,7 +63,7 @@ endif syn keyword pythonStatement break continue del syn keyword pythonStatement exec return syn keyword pythonStatement pass yield -syn keyword pythonStatement raise nextgroup=pythonIdentifier,pythonExClass skipwhite +syn keyword pythonStatement raise nextgroup=pythonExClass skipwhite syn keyword pythonStatement global assert syn keyword pythonStatement lambda syn keyword pythonStatement with @@ -78,7 +78,6 @@ syn keyword pythonException try except finally " we provide a dummy group here to avoid crashing pyrex.vim. syn keyword pythonInclude import syn keyword pythonImport import -syn match pythonIdentifier '\v[a-zA-Z_][a-zA-Z0-9_]*' syn match pythonRaiseFromStatement '\' syn match pythonImport '^\s*\zsfrom\>' From c85d026015ab18d39346bc27d69eb0ff2b72ea4f Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 26 Feb 2017 23:35:41 +0100 Subject: [PATCH 082/103] Update statements and functions --- syntax/python.vim | 14 ++++------- tests/test.py | 61 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index e4efe74..d9a2946 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -60,13 +60,8 @@ endif " Keywords " -syn keyword pythonStatement break continue del -syn keyword pythonStatement exec return -syn keyword pythonStatement pass yield +syn keyword pythonStatement break continue del return pass yield global assert lambda with syn keyword pythonStatement raise nextgroup=pythonExClass skipwhite -syn keyword pythonStatement global assert -syn keyword pythonStatement lambda -syn keyword pythonStatement with syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite if s:Enabled('g:python_highlight_class_vars') syn keyword pythonClassVar self cls @@ -86,6 +81,7 @@ if s:Python2Syntax() if !s:Enabled('g:python_print_as_function') syn keyword pythonStatement print endif + syn keyword pythonStatement exec syn keyword pythonImport as syn match pythonFunction '[a-zA-Z_][a-zA-Z0-9_]*' display contained else @@ -345,15 +341,15 @@ endif " if s:Enabled('g:python_highlight_builtin_funcs') - let s:funcs_re = '__import__|abs|all|any|bin|chr|classmethod|cmp|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|min|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' + let s:funcs_re = '__import__|abs|all|any|bin|callable|chr|classmethod|cmp|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|min|memoryview|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' if s:Python2Syntax() - let s:funcs_re .= '|apply|basestring|buffer|callable|coerce|execfile|file|help|intern|long|raw_input|reduce|reload|unichr|unicode|xrange' + let s:funcs_re .= '|apply|basestring|buffer|coerce|execfile|file|intern|long|raw_input|reduce|reload|unichr|unicode|xrange' if s:Enabled('g:python_print_as_function') let s:funcs_re .= '|print' endif else - let s:funcs_re .= '|ascii|exec|memoryview|print' + let s:funcs_re .= '|ascii|exec|print' endif execute 'syn match pythonBuiltinFunc ''\v\.@''' diff --git a/tests/test.py b/tests/test.py index 667ccb7..4547ab5 100644 --- a/tests/test.py +++ b/tests/test.py @@ -8,7 +8,7 @@ # Keywords. -with break continue del exec return pass print raise global assert lambda yield +with break continue del return pass raise global assert lambda yield for while if elif else import as try except finally from test import var as name @@ -22,6 +22,13 @@ class Classname def функция class Класс +# Keywords: Python 2 + +exec +print + +# Keywords: Python 3 + await async def Test async with @@ -33,16 +40,48 @@ async def Test # Bultin types -bool float frozenset dict int list object str tuple set - -# Builtin functions - -__import__ abs all any apply basestring buffer callable chr classmethod -cmp coerce compile complex delattr dir divmod enumerate eval execfile file -filter getattr globals hasattr hash help hex id input intern isinstance -issubclass iter len locals long map max min oct open ord pow print property -range raw_input reduce reload repr reversed round setattr slice sorted -staticmethod sum super type unichr unicode vars xrange zip +bool bytearray dict float frozenset int list object set str tuple + +# Builtin functions: Python 2 + +abs() divmod() input() open() staticmethod() +all() enumerate() int() ord() str() +any() eval() isinstance() pow() sum() +basestring() execfile() issubclass() print() super() +bin() file() iter() property() tuple() +bool() filter() len() range() type() +bytearray() float() list() raw_input() unichr() +callable() format() locals() reduce() unicode() +chr() frozenset() long() reload() vars() +classmethod() getattr() map() repr() xrange() +cmp() globals() max() reversed() zip() +compile() hasattr() memoryview() round() __import__() +complex() hash() min() set() +delattr() help() next() setattr() +dict() hex() object() slice() +dir() id() oct() sorted() + +apply() +buffer() +coerce() +intern() + +# Builtin functions: Python 3 + +abs() dict() help() min() setattr() +all() dir() hex() next() slice() +any() divmod() id() object() sorted() +ascii() enumerate() input() oct() staticmethod() +bin() eval() int() open() str() +bool() exec() isinstance() ord() sum() +bytearray() filter() issubclass() pow() super() +bytes() float() iter() print() tuple() +callable() format() len() property() type() +chr() frozenset() list() range() vars() +classmethod() getattr() locals() repr() zip() +compile() globals() map() reversed() __import__() +complex() hasattr() max() round() +delattr() hash() memoryview() set() # Builtin exceptions and warnings. From 0959f6d130c5f558b11652b3719196c5507a0c6a Mon Sep 17 00:00:00 2001 From: nfnty Date: Mon, 27 Feb 2017 00:07:03 +0100 Subject: [PATCH 083/103] Do not error highlight PEP 3017 operator Fixes #11 --- syntax/python.vim | 2 +- tests/test.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index d9a2946..c7d72a0 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -102,7 +102,7 @@ syn keyword pythonOperator and in is not or if s:Enabled('g:python_highlight_operators') syn match pythonOperator '\V=\|-\|+\|*\|@\|/\|%\|&\||\|^\|~\|<\|>\|!=' endif -syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([-=+*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|[]\+=\{2,}\|!\{2,}=\+' display +syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([+=*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|-[+*@/%&|^~<]\|[]\+=\{2,}\|!\{2,}=\+' display " " Decorators (new in Python 2.4) diff --git a/tests/test.py b/tests/test.py index 4547ab5..26f4771 100644 --- a/tests/test.py +++ b/tests/test.py @@ -117,6 +117,8 @@ async def Test -= += *= **= @= /= //= %= &= |= ^= ~= <<= >>= +-> + # Erroneous operators $ ? From 95fcb49f5bf02962158e8d6e434dbaee1f9d9ca1 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 4 Mar 2017 08:14:05 -0800 Subject: [PATCH 084/103] syntax: `cmp` is not a builtin function in Python 3 --- syntax/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index c7d72a0..4f7be3c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -341,10 +341,10 @@ endif " if s:Enabled('g:python_highlight_builtin_funcs') - let s:funcs_re = '__import__|abs|all|any|bin|callable|chr|classmethod|cmp|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|min|memoryview|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' + let s:funcs_re = '__import__|abs|all|any|bin|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|min|memoryview|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' if s:Python2Syntax() - let s:funcs_re .= '|apply|basestring|buffer|coerce|execfile|file|intern|long|raw_input|reduce|reload|unichr|unicode|xrange' + let s:funcs_re .= '|apply|basestring|buffer|cmp|coerce|execfile|file|intern|long|raw_input|reduce|reload|unichr|unicode|xrange' if s:Enabled('g:python_print_as_function') let s:funcs_re .= '|print' endif From e036a4c41a5d20b5177fc83aa234394e5922d934 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sat, 4 Mar 2017 22:45:25 +0100 Subject: [PATCH 085/103] Be explicit about builtin functions --- syntax/python.vim | 2 +- tests/test.py | 115 +++++++++++++++++++++++++++++++++------------- 2 files changed, 85 insertions(+), 32 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 4f7be3c..c243501 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -341,7 +341,7 @@ endif " if s:Enabled('g:python_highlight_builtin_funcs') - let s:funcs_re = '__import__|abs|all|any|bin|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|min|memoryview|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' + let s:funcs_re = '__import__|abs|all|any|bin|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|memoryview|min|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' if s:Python2Syntax() let s:funcs_re .= '|apply|basestring|buffer|cmp|coerce|execfile|file|intern|long|raw_input|reduce|reload|unichr|unicode|xrange' diff --git a/tests/test.py b/tests/test.py index 26f4771..a9d088d 100644 --- a/tests/test.py +++ b/tests/test.py @@ -42,46 +42,99 @@ async def Test bool bytearray dict float frozenset int list object set str tuple -# Builtin functions: Python 2 +# Builtin functions + +__import__() +abs() +all() +any() +bin() +bool() +bytearray() +callable() +chr() +classmethod() +compile() +complex() +delattr() +dict() +dir() +divmod() +enumerate() +eval() +filter() +float() +format() +frozenset() +getattr() +globals() +hasattr() +hash() +help() +hex() +id() +input() +int() +isinstance() +issubclass() +iter() +len() +list() +locals() +map() +max() +memoryview() +min() +next() +object() +oct() +open() +ord() +pow() +property() +range() +repr() +reversed() +round() +set() +setattr() +slice() +sorted() +staticmethod() +str() +sum() +super() +tuple() +type() +vars() +zip() -abs() divmod() input() open() staticmethod() -all() enumerate() int() ord() str() -any() eval() isinstance() pow() sum() -basestring() execfile() issubclass() print() super() -bin() file() iter() property() tuple() -bool() filter() len() range() type() -bytearray() float() list() raw_input() unichr() -callable() format() locals() reduce() unicode() -chr() frozenset() long() reload() vars() -classmethod() getattr() map() repr() xrange() -cmp() globals() max() reversed() zip() -compile() hasattr() memoryview() round() __import__() -complex() hash() min() set() -delattr() help() next() setattr() -dict() hex() object() slice() -dir() id() oct() sorted() +# Builtin functions: Python 2 apply() +basestring() buffer() +cmp() coerce() +execfile() +file() intern() +long() +raw_input() +reduce() +reload() +unichr() +unicode() +xrange() + +print() # Builtin functions: Python 3 -abs() dict() help() min() setattr() -all() dir() hex() next() slice() -any() divmod() id() object() sorted() -ascii() enumerate() input() oct() staticmethod() -bin() eval() int() open() str() -bool() exec() isinstance() ord() sum() -bytearray() filter() issubclass() pow() super() -bytes() float() iter() print() tuple() -callable() format() len() property() type() -chr() frozenset() list() range() vars() -classmethod() getattr() locals() repr() zip() -compile() globals() map() reversed() __import__() -complex() hasattr() max() round() -delattr() hash() memoryview() set() +ascii() +bytes() +exec() +print() # Builtin exceptions and warnings. From 453162092e15571d8bab62c944444cec87d18562 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 4 Mar 2017 08:57:14 -0800 Subject: [PATCH 086/103] syntax: Fix string formatting highlight for byte strings --- syntax/python.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index c243501..7cb55ca 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -232,11 +232,11 @@ syn match pythonRawEscape +\\['"]+ display transparent contained if s:Enabled('g:python_highlight_string_formatting') " % operator string formatting if s:Python2Syntax() - syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString - syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent else - syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString - syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent endif endif From aacf27d1a3b368fee96b2f54767eb97734250c75 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 5 Mar 2017 10:41:45 +0100 Subject: [PATCH 087/103] Implement option to disable highlighting builtin functions as kwarg Fixes #17 --- README.md | 1 + doc/python-syntax.txt | 3 +++ syntax/python.vim | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b65699..8c35ec2 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ let g:python_highlight_all = 1 | `g:python_highlight_builtins` | Highlight builtin functions and objects | `0` | | `g:python_highlight_builtin_objs` | Highlight builtin objects only | `0` | | `g:python_highlight_builtin_funcs` | Highlight builtin functions only | `0` | +| `g:python_highlight_builtin_funcs_kwarg` | Highlight builtin functions when used as kwarg | `1` | | `g:python_highlight_exceptions` | Highlight standard exceptions | `0` | | `g:python_highlight_string_formatting` | Highlight `%` string formatting | `0` | | `g:python_highlight_string_format` | Highlight syntax of `str.format` syntax | `0` | diff --git a/doc/python-syntax.txt b/doc/python-syntax.txt index f310e7a..a1ccf16 100644 --- a/doc/python-syntax.txt +++ b/doc/python-syntax.txt @@ -65,6 +65,9 @@ following command to your `~/.config/nvim/init.vim` or `~/.vimrc`: > `g:python_highlight_builtin_funcs` (default `0`) Highlight builtin functions only +`g:python_highlight_builtin_funcs_kwarg` (default `1`) + Highlight builtin functions when used as kwarg + `g:python_highlight_exceptions` (default `0`) Highlight standard exceptions diff --git a/syntax/python.vim b/syntax/python.vim index 7cb55ca..3ea261c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -37,6 +37,7 @@ endfunction " call s:EnableByDefault('g:python_slow_sync') +call s:EnableByDefault('g:python_highlight_builtin_funcs_kwarg') if s:Enabled('g:python_highlight_all') call s:EnableByDefault('g:python_highlight_builtins') @@ -352,7 +353,13 @@ if s:Enabled('g:python_highlight_builtin_funcs') let s:funcs_re .= '|ascii|exec|print' endif - execute 'syn match pythonBuiltinFunc ''\v\.@''' + let s:funcs_re = 'syn match pythonBuiltinFunc ''\v\.@' + + if !s:Enabled('g:python_highlight_builtin_funcs_kwarg') + let s:funcs_re .= '\=@!' + endif + + execute s:funcs_re . '''' unlet s:funcs_re endif From d1b4de242bb4902a0379bed919050e3ac3a03f8e Mon Sep 17 00:00:00 2001 From: nfnty Date: Wed, 15 Mar 2017 13:25:42 +0100 Subject: [PATCH 088/103] Fix operator error highlighting for `=` prefix Fixes #20 --- syntax/python.vim | 2 +- tests/test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 3ea261c..8be831b 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -103,7 +103,7 @@ syn keyword pythonOperator and in is not or if s:Enabled('g:python_highlight_operators') syn match pythonOperator '\V=\|-\|+\|*\|@\|/\|%\|&\||\|^\|~\|<\|>\|!=' endif -syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([+=*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|-[+*@/%&|^~<]\|[]\+=\{2,}\|!\{2,}=\+' display +syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([+*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|=[*@/%&|^<>]\|-[+*@/%&|^~<]\|[]\+=\{2,}\|!\{2,}=\+' display " " Decorators (new in Python 2.4) diff --git a/tests/test.py b/tests/test.py index a9d088d..ff87a35 100644 --- a/tests/test.py +++ b/tests/test.py @@ -166,7 +166,7 @@ async def Test & | ^ ~ << >> < <= == != >= > -= += =- =+ =~ -= += *= **= @= /= //= %= &= |= ^= ~= <<= >>= From 26f711e9cd29a538e5479f95fb473b81aa5cd6ce Mon Sep 17 00:00:00 2001 From: nfnty Date: Sat, 18 Mar 2017 15:45:04 +0100 Subject: [PATCH 089/103] syntax: Fix `pythonRawBytes` prefix --- syntax/python.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 8be831b..420196c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -222,10 +222,10 @@ else syn region pythonRawString start=+[rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell syn region pythonRawString start=+[rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell - syn region pythonRawBytes start=+[bB][rR]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawBytes start=+[bB][rR]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell - syn region pythonRawBytes start=+[bB][rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell - syn region pythonRawBytes start=+[bB][rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell + syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell + syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell + syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell endif syn match pythonRawEscape +\\['"]+ display transparent contained From ea34354750aa6020518a8002e4e32c6d5008e581 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sat, 18 Mar 2017 15:59:23 +0100 Subject: [PATCH 090/103] syntax: Implement raw format strings Fixes #21 --- syntax/python.vim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 420196c..f7bb86a 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -222,13 +222,18 @@ else syn region pythonRawString start=+[rR]'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell syn region pythonRawString start=+[rR]"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell + syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell + syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell + syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawFString start=+\%([fF][rR]\|[rR][fF]\)"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest,pythonSpaceError,@Spell + syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonRawEscape,@Spell syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)'''+ skip=+\\'+ end=+'''+ keepend contains=pythonDocTest,pythonSpaceError,@Spell syn region pythonRawBytes start=+\%([bB][rR]\|[rR][bB]\)"""+ skip=+\\"+ end=+"""+ keepend contains=pythonDocTest2,pythonSpaceError,@Spell endif -syn match pythonRawEscape +\\['"]+ display transparent contained +syn match pythonRawEscape +\\['"]+ display contained if s:Enabled('g:python_highlight_string_formatting') " % operator string formatting @@ -247,9 +252,9 @@ if s:Enabled('g:python_highlight_string_format') syn match pythonStrFormat '{{\|}}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else - syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString + syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString,pythonRawFString syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString - syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString contains=pythonStrInterpRegion,@pythonExpression + syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString,pythonRawFString contains=pythonStrInterpRegion,@pythonExpression endif endif @@ -424,6 +429,7 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonString String HiLink pythonRawString String + HiLink pythonRawEscape Special HiLink pythonUniEscape Special HiLink pythonUniEscapeError Error @@ -441,6 +447,7 @@ if v:version >= 508 || !exists('did_python_syn_inits') HiLink pythonBytesEscape Special HiLink pythonBytesEscapeError Error HiLink pythonFString String + HiLink pythonRawFString String HiLink pythonStrInterpRegion Special endif From 3a6000e56012ffc539fa943774f74394ecf9b991 Mon Sep 17 00:00:00 2001 From: nfnty Date: Sun, 21 May 2017 12:08:12 +0200 Subject: [PATCH 091/103] Fix exponent operator error highlighting Fixes #25 --- syntax/python.vim | 2 +- tests/test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index f7bb86a..ffd88f9 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -103,7 +103,7 @@ syn keyword pythonOperator and in is not or if s:Enabled('g:python_highlight_operators') syn match pythonOperator '\V=\|-\|+\|*\|@\|/\|%\|&\||\|^\|~\|<\|>\|!=' endif -syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([+*@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|=[*@/%&|^<>]\|-[+*@/%&|^~<]\|[]\+=\{2,}\|!\{2,}=\+' display +syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,}\|\([+@/%&|^~<>]\)\3\@![-+*@/%&|^~<>]\|\*\*[*@/%&|^<>]\|=[*@/%&|^<>]\|-[+*@/%&|^~<]\|[]\+=\{2,}\|!\{2,}=\+' display " " Decorators (new in Python 2.4) diff --git a/tests/test.py b/tests/test.py index ff87a35..058f3f7 100644 --- a/tests/test.py +++ b/tests/test.py @@ -162,7 +162,7 @@ async def Test and or in is not -- + * ** @ / // % +- + * ** **- **+ **~ @ / // % & | ^ ~ << >> < <= == != >= > From 35841908e469f8529894592566f45a49b17a6824 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Thu, 27 Jul 2017 16:28:05 +0800 Subject: [PATCH 092/103] move {{ and }} matching so that it gets highlighted correctly --- syntax/python.vim | 4 ++-- tests/test.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index ffd88f9..83173de 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -252,9 +252,9 @@ if s:Enabled('g:python_highlight_string_format') syn match pythonStrFormat '{{\|}}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else - syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString,pythonRawFString syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString - syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString,pythonRawFString contains=pythonStrInterpRegion,@pythonExpression + syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString contains=pythonStrInterpRegion,@pythonExpression + syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString,pythonRawFString endif endif diff --git a/tests/test.py b/tests/test.py index 058f3f7..76b8316 100644 --- a/tests/test.py +++ b/tests/test.py @@ -235,6 +235,7 @@ async def Test f"{var}...{arr[123]} normal {var['{'] // 0xff} \"xzcb\" 'xzcb' {var['}'] + 1} text" f"{expr1 if True or False else expr2} wow {','.join(c.lower() for c in 'asdf')}" f"hello {expr:.2f} yes {(lambda: 0b1)():#03x} lol {var!r}" +f'brackets: {{ 1 + 2 }} and {{{{ 3 + 4 }}}}' # Doctests. From 58d6e019d3cdce2b1537b7a65d4dd0b62fbd9cae Mon Sep 17 00:00:00 2001 From: nfnty Date: Fri, 4 Aug 2017 13:51:08 +0200 Subject: [PATCH 093/103] Fix raw f-string interpolation Fixes #32 --- syntax/python.vim | 2 +- tests/test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 83173de..913da9d 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -253,7 +253,7 @@ if s:Enabled('g:python_highlight_string_format') syn match pythonStrFormat '{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString else syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString - syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString contains=pythonStrInterpRegion,@pythonExpression + syn region pythonStrInterpRegion start="{"he=e+1,rs=e+1 end="\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}"hs=s-1,re=s-1 extend contained containedin=pythonFString,pythonRawFString contains=pythonStrInterpRegion,@pythonExpression syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString,pythonFString,pythonRawFString endif endif diff --git a/tests/test.py b/tests/test.py index 76b8316..08d5a69 100644 --- a/tests/test.py +++ b/tests/test.py @@ -236,6 +236,7 @@ async def Test f"{expr1 if True or False else expr2} wow {','.join(c.lower() for c in 'asdf')}" f"hello {expr:.2f} yes {(lambda: 0b1)():#03x} lol {var!r}" f'brackets: {{ 1 + 2 }} and {{{{ 3 + 4 }}}}' +fr'this {that}' # Doctests. From 3e1969e40fd2d6c52c47e426f954fbf0f6b6e4d1 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 2 Apr 2018 20:18:13 -0700 Subject: [PATCH 094/103] Fix '...; from ... import ...'. With the semicolon, we can distinguish it from 'raise ... from ...'. --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 913da9d..abc7c89 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -75,7 +75,7 @@ syn keyword pythonException try except finally syn keyword pythonInclude import syn keyword pythonImport import syn match pythonRaiseFromStatement '\' -syn match pythonImport '^\s*\zsfrom\>' +syn match pythonImport '\v(^|;)\s*\zsfrom>' if s:Python2Syntax() From 39a5526672f9d4d04c2cef73a88ccb77640c77b0 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 2 Apr 2018 20:19:49 -0700 Subject: [PATCH 095/103] '1.' is a float. --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index abc7c89..9851c2d 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -326,7 +326,7 @@ else syn match pythonFloat '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display syn match pythonFloat '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display - syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display + syn match pythonFloat '\<\d\%([_0-9]*\d\)\=\.\d\=\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display endif " From 3cffd97931955929364eee626e0fdba76f4a5216 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 2 Apr 2018 20:20:58 -0700 Subject: [PATCH 096/103] Don't highlight '%[hlL]'. --- syntax/python.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index 9851c2d..fed3f13 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -238,11 +238,11 @@ syn match pythonRawEscape +\\['"]+ display contained if s:Enabled('g:python_highlight_string_formatting') " % operator string formatting if s:Python2Syntax() - syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent - syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent else - syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent - syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent endif endif From 52af92432848e95c879f07e492320bd0ad7baa54 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 2 Apr 2018 20:25:00 -0700 Subject: [PATCH 097/103] Don't confuse decorators with matrix multiplication. --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index fed3f13..164b6cb 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -109,7 +109,7 @@ syn match pythonError '[$?]\|\([-+@%&|^~]\)\1\{1,}\|\([=*/<>]\)\2\{2,} " Decorators (new in Python 2.4) " -syn match pythonDecorator '^\s*\zs@' display nextgroup=pythonDottedName skipwhite +syn match pythonDecorator '^\s*\zs@\ze\h' display nextgroup=pythonDottedName skipwhite if s:Python2Syntax() syn match pythonDottedName '[a-zA-Z_][a-zA-Z0-9_]*\%(\.[a-zA-Z_][a-zA-Z0-9_]*\)*' display contained else From aa25a34515a27b4d139e2def910cd0bb486c10a1 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 2 Apr 2018 21:24:20 -0700 Subject: [PATCH 098/103] Better builtin isolator. --- syntax/python.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 164b6cb..cce29b8 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -358,7 +358,14 @@ if s:Enabled('g:python_highlight_builtin_funcs') let s:funcs_re .= '|ascii|exec|print' endif - let s:funcs_re = 'syn match pythonBuiltinFunc ''\v\.@' + " (Exclude if preceded by a dot, possibly on the line before, except if that + " dot is in a comment or Ellipsis. Would fail if the previous line contained + " '#' in a string, though. (Thus, directly check for the current line, too.) + " Exclude if immediately followed by an equal sign, as this would typically + " correspond to a keyword argument.) + let s:funcs_re = + \ 'syn match pythonBuiltinFunc ''\v(^[^#]*[^.#]\s*\.(\s|\n)*|\.\s*)@160' if !s:Enabled('g:python_highlight_builtin_funcs_kwarg') let s:funcs_re .= '\=@!' From 731b55c8ae6853cc2eab661b2046bccead0bb6f1 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 17 Apr 2018 21:38:26 -0700 Subject: [PATCH 099/103] b"%b". --- syntax/python.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index cce29b8..daa8b0c 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -241,8 +241,10 @@ if s:Enabled('g:python_highlight_string_formatting') syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent else - syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent - syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrsa%]' contained containedin=pythonString,pythonRawString + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrsa%]' contained containedin=pythonString,pythonRawString + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcbsar%]' contained containedin=pythonBytesContent + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcbsar%]' contained containedin=pythonBytesContent endif endif From 44a64aa6c7c218e65b0348f455ba8c6b2956fc80 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 12 May 2018 01:58:17 -0700 Subject: [PATCH 100/103] br"%X". --- syntax/python.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/syntax/python.vim b/syntax/python.vim index daa8b0c..4f18a36 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -238,13 +238,13 @@ syn match pythonRawEscape +\\['"]+ display contained if s:Enabled('g:python_highlight_string_formatting') " % operator string formatting if s:Python2Syntax() - syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent - syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent,pythonRawBytes + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrs%]' contained containedin=pythonString,pythonUniString,pythonUniRawString,pythonRawString,pythonBytesContent,pythonRawBytes else syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcrsa%]' contained containedin=pythonString,pythonRawString syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcrsa%]' contained containedin=pythonString,pythonRawString - syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcbsar%]' contained containedin=pythonBytesContent - syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcbsar%]' contained containedin=pythonBytesContent + syn match pythonStrFormatting '%\%(([^)]\+)\)\=[-#0 +]*\d*\%(\.\d\+\)\=[diouxXeEfFgGcbsar%]' contained containedin=pythonBytesContent,pythonRawBytes + syn match pythonStrFormatting '%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)\=[diouxXeEfFgGcbsar%]' contained containedin=pythonBytesContent,pythonRawBytes endif endif From 974fa0834d3b0ae8a033034ecb622030e8e9113a Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 7 Jul 2018 23:32:16 +0200 Subject: [PATCH 101/103] Fix typo in warning name. --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index 4f18a36..b28c0d6 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -382,7 +382,7 @@ endif " if s:Enabled('g:python_highlight_exceptions') - let s:exs_re = 'BaseException|Exception|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|BufferError|EOFError|FloatingPointError|GeneratorExit|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|ReferenceError|RuntimeError|StopIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|VMSError|WindowsError|ZeroDivisionError|Warning|UserWarning|BytesWarning|DeprecationWarning|PendingDepricationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning' + let s:exs_re = 'BaseException|Exception|ArithmeticError|LookupError|EnvironmentError|AssertionError|AttributeError|BufferError|EOFError|FloatingPointError|GeneratorExit|IOError|ImportError|IndexError|KeyError|KeyboardInterrupt|MemoryError|NameError|NotImplementedError|OSError|OverflowError|ReferenceError|RuntimeError|StopIteration|SyntaxError|IndentationError|TabError|SystemError|SystemExit|TypeError|UnboundLocalError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ValueError|VMSError|WindowsError|ZeroDivisionError|Warning|UserWarning|BytesWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning' if s:Python2Syntax() let s:exs_re .= '|StandardError' From 1e052f1562e4844819ca3150ac75339ebd4c8675 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 8 Sep 2018 16:59:31 +0200 Subject: [PATCH 102/103] Don't recognize builtins as kwargs. --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index b28c0d6..a496f02 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -339,7 +339,7 @@ if s:Enabled('g:python_highlight_builtin_objs') syn keyword pythonNone None syn keyword pythonBoolean True False syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn match pythonBuiltinObj '\v\.@' + syn match pythonBuiltinObj '\v\.@\=@!' syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ endif From 814c269fffae576caef047286f86202ce437a2bd Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 8 Sep 2018 16:59:47 +0200 Subject: [PATCH 103/103] Add breakpoint to builtins. --- syntax/python.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/python.vim b/syntax/python.vim index a496f02..3d23f88 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -349,7 +349,7 @@ endif " if s:Enabled('g:python_highlight_builtin_funcs') - let s:funcs_re = '__import__|abs|all|any|bin|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|memoryview|min|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' + let s:funcs_re = '__import__|abs|all|any|bin|breakpoint|callable|chr|classmethod|compile|complex|delattr|dir|divmod|enumerate|eval|filter|format|getattr|globals|hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|locals|map|max|memoryview|min|next|oct|open|ord|pow|property|range|repr|reversed|round|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip' if s:Python2Syntax() let s:funcs_re .= '|apply|basestring|buffer|cmp|coerce|execfile|file|intern|long|raw_input|reduce|reload|unichr|unicode|xrange'