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) 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" diff --git a/syntax/python.vim b/syntax/python.vim index e963628..de978e0 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -1,158 +1,13 @@ -" Vim syntax file -" Language: Python -" Current Maintainer: Dmitry Vasiliev -" Previous Maintainer: Neil Schemenauer -" URL: https://github.com/hdima/python-syntax -" Last Change: 2015-11-01 -" Filenames: *.py -" Version: 3.6.0 -" -" Based on python.vim (from Vim 6.1 distribution) -" by Neil Schemenauer -" -" 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 -" `__ -" -" 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 -" -" 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 version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -" -" Commands -" -command! -buffer Python2Syntax let b:python_version_2 = 1 | let &syntax=&syntax -command! -buffer Python3Syntax let b:python_version_2 = 0 | let &syntax=&syntax - -" Enable option if it's not defined -function! s:EnableByDefault(name) - if !exists(a:name) - let {a:name} = 1 - endif -endfunction - -" Check if option is enabled -function! s:Enabled(name) - return exists(a:name) && {a:name} -endfunction - -" Is it Python 2 syntax? -function! s:Python2Syntax() - if exists("b:python_version_2") - return b:python_version_2 - endif - return s:Enabled("g:python_version_2") -endfunction - -" -" Default options -" - -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") - 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") +if exists("b:current_syntax") + finish endif -" -" Keywords -" - +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 yield +syn keyword pythonStatement raise nextgroup=pythonIdentifier,pythonExClass skipwhite syn keyword pythonStatement global assert syn keyword pythonStatement lambda syn keyword pythonStatement with @@ -161,94 +16,45 @@ syn keyword pythonRepeat for while syn keyword pythonConditional if elif else " The standard pyrex.vim unconditionally removes the pythonInclude group, so " we provide a dummy group here to avoid crashing pyrex.vim. -syn keyword pythonInclude import -syn keyword pythonImport import syn keyword pythonException try except finally syn keyword pythonOperator and in is not or - -syn match pythonStatement "\" display -syn match pythonImport "\" display - -if s:Python2Syntax() - 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_]*" display contained -else - syn keyword pythonStatement as nonlocal None - syn match pythonStatement "\" display - syn keyword pythonBoolean True False - syn match pythonFunction "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained - syn keyword pythonStatement await - syn match pythonStatement "\" nextgroup=pythonFunction skipwhite - syn match pythonStatement "\" display - syn match pythonStatement "\" display -endif - -" -" Decorators (new in Python 2.4) -" +syn match pythonStatement "\s*\([.,]\)\@" +syn keyword pythonInclude import +syn keyword pythonImport import +syn match pythonIdentifier "\v[a-zA-Z_][a-zA-Z0-9_]*" +syn match pythonRaiseFromStatement "from\>" +syn match pythonImport "^\s*\zsfrom\>" +syn keyword pythonStatement as nonlocal +syn match pythonStatement "\v(\.)@" +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 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 -else - syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained -endif +syn match pythonDottedName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\)*" display contained nextgroup=FunctionParameters 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-_.]\+.*$" -endif +syn match pythonRun "\%^#!.*$" +syn match pythonCoding "\%^.*\%(\n.*\)\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$" 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 pythonIndentError "^\s*\%( \t\|\t \)\s*\S"me=e-1 display +syn match pythonSpaceError "\s\+$" 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 -endif - -" Trailing space errors -if s:Enabled("g:python_highlight_space_errors") - syn match pythonSpaceError "\s\+$" display -endif -" -" 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 -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 -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 match pythonBytesError ".\+" display contained - syn match pythonBytesContent "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError -endif +syn match pythonBytesError ".\+" display contained +syn match pythonBytesContent "[\u0000-\u00ff]\+" display contained contains=pythonBytesEscape,pythonBytesEscapeError syn match pythonBytesEscape +\\[abfnrtv'"\\]+ display contained syn match pythonBytesEscape "\\\o\o\=\o\=" display contained @@ -264,305 +70,173 @@ 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 - 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 -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 -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 pythonSingleQuoteString start=+'+ skip=+\\'+ excludenl end=+'+ end=+$+ keepend contains=pythonEol +syn region pythonDoubleQuoteString start=+"+ skip=+\\"+ excludenl end=+"+ end=+$+ keepend contains=pythonEol - syn match pythonUniRawEscape "\([^\\]\(\\\\\)*\)\@<=\\u\x\{4}" display contained - syn match pythonUniRawEscapeError "\([^\\]\(\\\\\)*\)\@<=\\u\x\{,3}\X" display contained -endif +syn region pythonSingleQuoteFString start=+fr\?'+ skip=+\\'+ excludenl end=+'+ end=+$+ keepend contains=pythonEol,pythonSingleQuoteFStringFormat +syn region pythonDoubleQuoteFString start=+fr\?"+ skip=+\\"+ excludenl end=+"+ end=+$+ keepend contains=pythonEol,pythonDoubleQuoteFStringFormat -" Python 2/3 raw strings -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 -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 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 -endif +syn region pythonTripleSingleQuoteString start=+'''+ skip=+\\'+ excludenl end=+'''+ keepend contains=pythonEol +syn region pythonTripleDoubleQuoteString start=+"""+ skip=+\\"+ excludenl end=+"""+ keepend contains=pythonEol -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 - 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 - endif -endif -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 - 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 - endif -endif +syn region pythonTripleSingleQuoteFString start=+f'''+ skip=+\\'+ excludenl end=+'''+ contains=pythonEol,pythonSingleQuoteFStringFormat +syn region pythonTripleDoubleQuoteFString start=+f"""+ skip=+\\"+ excludenl end=+"""+ contains=pythonEol,pythonDoubleQuoteFStringFormat -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 - 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 - endif -endif +syn match pythonEol "\\n" display contained -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 -endif +syn region pythonSingleQuoteFStringFormat matchgroup=Special start=+{+ end=+}+ contains=pythonStatement,pythonConditional,pythonBoolean,pythonDoubleQuoteString,pythonRepeat,pythonNumber,pythonFloat,pythonOperator,pythonInstanceVariable,pythonClassVaraible contained containedin=pythonSingleQuoteFString +syn region pythonDoubleQuoteFStringFormat matchgroup=Special start=+{+ end=+}+ contains=pythonStatement,pythonConditional,pythonBoolean,pythonSingleQuoteString,pythonRepeat,pythonNumber,pythonFloat,pythonOperator,pythonInstanceVariable,pythonClassVaraible contained containedin=pythonDoubleQuoteFString -" -" Numbers (ints, longs, floats, complex) -" +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 -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 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 -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 -endif +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 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:Python2Syntax() - syn keyword pythonBuiltinObj None - syn keyword pythonBoolean True False - endif - syn keyword pythonBuiltinObj Ellipsis NotImplemented - syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ -endif +syn keyword pythonNone None +syn keyword pythonBoolean True False +syn keyword pythonBuiltinObj Ellipsis NotImplemented +syn match pythonBuiltinObj '\v(\.)@' +syn keyword pythonBuiltinObj __debug__ __doc__ __file__ __name__ __package__ +syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__ " " Builtin functions " -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 - if s:Enabled("g:python_print_as_function") - syn keyword pythonBuiltinFunc print - endif - else - syn keyword pythonBuiltinFunc 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 dict dir divmod enumerate eval - syn keyword pythonBuiltinFunc filter float format frozenset 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 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 type vars zip -endif - -" -" Builtin exceptions and warnings -" - -if s:Enabled("g:python_highlight_exceptions") - if s:Python2Syntax() - syn keyword pythonExClass StandardError - 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 ResourceWarning - 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 -endif - -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 maxlines=200 -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 Include - HiLink pythonFunction Function - HiLink pythonConditional Conditional - HiLink pythonRepeat Repeat - HiLink pythonException Exception - HiLink pythonOperator Operator - - HiLink pythonDecorator Define - HiLink pythonDottedName Function - HiLink pythonDot Normal - - HiLink pythonComment Comment - if !s:Enabled("g:python_highlight_file_headers_as_comments") - HiLink pythonCoding Special - HiLink pythonRun Special - endif - HiLink pythonTodo Todo - - HiLink pythonError Error - HiLink pythonIndentError Error - HiLink pythonSpaceError Error - - HiLink pythonString String - HiLink pythonRawString String - - HiLink pythonUniEscape Special - HiLink pythonUniEscapeError Error - - if s:Python2Syntax() - HiLink pythonUniString String - HiLink pythonUniRawString String - HiLink pythonUniRawEscape Special - HiLink pythonUniRawEscapeError Error - else - HiLink pythonBytes String - HiLink pythonRawBytes String - HiLink pythonBytesContent String - HiLink pythonBytesError Error - HiLink pythonBytesEscape Special - HiLink pythonBytesEscapeError Error - endif - - HiLink pythonStrFormatting Special - HiLink pythonStrFormat Special - HiLink pythonStrTemplate Special - - HiLink pythonDocTest Special - HiLink pythonDocTest2 Special - - HiLink pythonNumber Number - HiLink pythonHexNumber Number - HiLink pythonOctNumber Number - HiLink pythonBinNumber Number - HiLink pythonFloat Float - HiLink pythonNumberError Error - HiLink pythonOctError Error - HiLink pythonHexError Error - HiLink pythonBinError Error - - HiLink pythonBoolean Boolean - - HiLink pythonBuiltinObj Structure - HiLink pythonBuiltinFunc Function - - HiLink pythonExClass Structure - - delcommand HiLink -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 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 + +" 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 maxlines=200 + +hi def link pythonStatement Statement +hi def link pythonRaiseFromStatement Statement +hi def link pythonImport Include +hi def link pythonFunction Function +hi def link pythonConditional Conditional +hi def link pythonRepeat Repeat +hi def link pythonException Exception +hi def link pythonOperator Operator + +hi def link pythonStarArguments Keyword + +hi def link pythonDecorator Define +hi def link pythonDottedName Function +hi def link pythonDot Normal + +hi def link pythonComment Comment +hi def link pythonCoding Special +hi def link pythonRun Special +hi def link pythonTodo Todo + +hi def link pythonError Error +hi def link pythonIndentError Error +hi def link pythonSpaceError Error + +hi def link pythonRawString String + +hi def link pythonUniEscape Special +hi def link pythonUniEscapeError Error + +hi def link pythonBytes String +hi def link pythonRawBytes String +hi def link pythonBytesContent String +hi def link pythonBytesError Error +hi def link pythonBytesEscape Special +hi def link pythonBytesEscapeError Error + +hi def link pythonEol Special + +hi def link pythonDocTest Special +hi def link pythonDocTest2 Special + +hi def link pythonNumber Number +hi def link pythonHexNumber Number +hi def link pythonOctNumber Number +hi def link pythonBinNumber Number +hi def link pythonFloat Float +hi def link pythonNumberError Error +hi def link pythonOctError Error +hi def link pythonHexError Error +hi def link pythonBinError Error + +hi def link pythonBoolean Boolean +hi def link pythonNone Constant + +hi def link pythonBuiltinObj Structure +hi def link pythonBuiltinFunc Function + +hi def link pythonExClass Structure +hi def link pythonInstanceVariable htmlTagN +hi def link pythonClassVaraible htmlTagN +hi def link OptionalParameters htmlTagN + +hi def link pythonSingleQuoteFString String +hi def link pythonDoubleQuoteFString String +hi def link pythonSingleQuoteString String +hi def link pythonDoubleQuoteString String +hi def link pythonTripleSingleQuoteString String +hi def link pythonTripleDoubleQuoteString String +hi def link pythonTripleSingleQuoteFString String +hi def link pythonTripleDoubleQuoteFString String let b:current_syntax = "python"