PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/antares/src/bin/vim/runtime/syntax/python.vim

https://github.com/mmanley/Antares
Vim Script | 171 lines | 136 code | 4 blank | 31 comment | 3 complexity | e1b9b36fb33a7429be07ff20988ad14a MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, MPL-2.0-no-copyleft-exception, GPL-3.0, ISC, LGPL-2.0, LGPL-3.0
  1. " Vim syntax file
  2. " Language: Python
  3. " Maintainer: Neil Schemenauer <nas@python.ca>
  4. " Updated: 2002-10-18
  5. "
  6. " Options to control Python syntax highlighting:
  7. "
  8. " For highlighted numbers:
  9. "
  10. " let python_highlight_numbers = 1
  11. "
  12. " For highlighted builtin functions:
  13. "
  14. " let python_highlight_builtins = 1
  15. "
  16. " For highlighted standard exceptions:
  17. "
  18. " let python_highlight_exceptions = 1
  19. "
  20. " Highlight erroneous whitespace:
  21. "
  22. " let python_highlight_space_errors = 1
  23. "
  24. " If you want all possible Python highlighting (the same as setting the
  25. " preceding options):
  26. "
  27. " let python_highlight_all = 1
  28. "
  29. " For version 5.x: Clear all syntax items
  30. " For version 6.x: Quit when a syntax file was already loaded
  31. if version < 600
  32. syntax clear
  33. elseif exists("b:current_syntax")
  34. finish
  35. endif
  36. syn keyword pythonStatement break continue del
  37. syn keyword pythonStatement except exec finally
  38. syn keyword pythonStatement pass print raise
  39. syn keyword pythonStatement return try
  40. syn keyword pythonStatement global assert
  41. syn keyword pythonStatement lambda yield
  42. syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
  43. syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained
  44. syn keyword pythonRepeat for while
  45. syn keyword pythonConditional if elif else
  46. syn keyword pythonOperator and in is not or
  47. syn keyword pythonPreCondit import from
  48. syn match pythonComment "#.*$" contains=pythonTodo
  49. syn keyword pythonTodo TODO FIXME XXX contained
  50. " strings
  51. syn region pythonString matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=pythonEscape
  52. syn region pythonString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=pythonEscape
  53. syn region pythonString matchgroup=Normal start=+[uU]\="""+ end=+"""+ contains=pythonEscape
  54. syn region pythonString matchgroup=Normal start=+[uU]\='''+ end=+'''+ contains=pythonEscape
  55. syn region pythonRawString matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+
  56. syn region pythonRawString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+
  57. syn region pythonRawString matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+
  58. syn region pythonRawString matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+
  59. syn match pythonEscape +\\[abfnrtv'"\\]+ contained
  60. syn match pythonEscape "\\\o\{1,3}" contained
  61. syn match pythonEscape "\\x\x\{2}" contained
  62. syn match pythonEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained
  63. syn match pythonEscape "\\$"
  64. if exists("python_highlight_all")
  65. let python_highlight_numbers = 1
  66. let python_highlight_builtins = 1
  67. let python_highlight_exceptions = 1
  68. let python_highlight_space_errors = 1
  69. endif
  70. if exists("python_highlight_numbers")
  71. " numbers (including longs and complex)
  72. syn match pythonNumber "\<0x\x\+[Ll]\=\>"
  73. syn match pythonNumber "\<\d\+[LljJ]\=\>"
  74. syn match pythonNumber "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  75. syn match pythonNumber "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  76. syn match pythonNumber "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  77. endif
  78. if exists("python_highlight_builtins")
  79. " builtin functions, types and objects, not really part of the syntax
  80. syn keyword pythonBuiltin Ellipsis None NotImplemented __import__ abs
  81. syn keyword pythonBuiltin apply buffer callable chr classmethod cmp
  82. syn keyword pythonBuiltin coerce compile complex delattr dict dir divmod
  83. syn keyword pythonBuiltin eval execfile file filter float getattr globals
  84. syn keyword pythonBuiltin hasattr hash hex id input int intern isinstance
  85. syn keyword pythonBuiltin issubclass iter len list locals long map max
  86. syn keyword pythonBuiltin min object oct open ord pow property range
  87. syn keyword pythonBuiltin raw_input reduce reload repr round setattr
  88. syn keyword pythonBuiltin slice staticmethod str super tuple type unichr
  89. syn keyword pythonBuiltin unicode vars xrange zip
  90. endif
  91. if exists("python_highlight_exceptions")
  92. " builtin exceptions and warnings
  93. syn keyword pythonException ArithmeticError AssertionError AttributeError
  94. syn keyword pythonException DeprecationWarning EOFError EnvironmentError
  95. syn keyword pythonException Exception FloatingPointError IOError
  96. syn keyword pythonException ImportError IndentationError IndexError
  97. syn keyword pythonException KeyError KeyboardInterrupt LookupError
  98. syn keyword pythonException MemoryError NameError NotImplementedError
  99. syn keyword pythonException OSError OverflowError OverflowWarning
  100. syn keyword pythonException ReferenceError RuntimeError RuntimeWarning
  101. syn keyword pythonException StandardError StopIteration SyntaxError
  102. syn keyword pythonException SyntaxWarning SystemError SystemExit TabError
  103. syn keyword pythonException TypeError UnboundLocalError UnicodeError
  104. syn keyword pythonException UserWarning ValueError Warning WindowsError
  105. syn keyword pythonException ZeroDivisionError
  106. endif
  107. if exists("python_highlight_space_errors")
  108. " trailing whitespace
  109. syn match pythonSpaceError display excludenl "\S\s\+$"ms=s+1
  110. " mixed tabs and spaces
  111. syn match pythonSpaceError display " \+\t"
  112. syn match pythonSpaceError display "\t\+ "
  113. endif
  114. " This is fast but code inside triple quoted strings screws it up. It
  115. " is impossible to fix because the only way to know if you are inside a
  116. " triple quoted string is to start from the beginning of the file. If
  117. " you have a fast machine you can try uncommenting the "sync minlines"
  118. " and commenting out the rest.
  119. syn sync match pythonSync grouphere NONE "):$"
  120. syn sync maxlines=200
  121. "syn sync minlines=2000
  122. if version >= 508 || !exists("did_python_syn_inits")
  123. if version <= 508
  124. let did_python_syn_inits = 1
  125. command -nargs=+ HiLink hi link <args>
  126. else
  127. command -nargs=+ HiLink hi def link <args>
  128. endif
  129. " The default methods for highlighting. Can be overridden later
  130. HiLink pythonStatement Statement
  131. HiLink pythonFunction Function
  132. HiLink pythonConditional Conditional
  133. HiLink pythonRepeat Repeat
  134. HiLink pythonString String
  135. HiLink pythonRawString String
  136. HiLink pythonEscape Special
  137. HiLink pythonOperator Operator
  138. HiLink pythonPreCondit PreCondit
  139. HiLink pythonComment Comment
  140. HiLink pythonTodo Todo
  141. if exists("python_highlight_numbers")
  142. HiLink pythonNumber Number
  143. endif
  144. if exists("python_highlight_builtins")
  145. HiLink pythonBuiltin Function
  146. endif
  147. if exists("python_highlight_exceptions")
  148. HiLink pythonException Exception
  149. endif
  150. if exists("python_highlight_space_errors")
  151. HiLink pythonSpaceError Error
  152. endif
  153. delcommand HiLink
  154. endif
  155. let b:current_syntax = "python"
  156. " vim: ts=8