highlights.scm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ; Identifier naming conventions
  2. ((identifier) @constructor
  3. (#match? @constructor "^[A-Z]"))
  4. ((identifier) @constant
  5. (#match? @constant "^[A-Z][A-Z_]*$"))
  6. ; Builtin functions
  7. ((call
  8. function: (identifier) @function.builtin)
  9. (#match?
  10. @function.builtin
  11. "^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|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|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))
  12. ; Function calls
  13. (decorator) @function
  14. (call
  15. function: (attribute attribute: (identifier) @function.method))
  16. (call
  17. function: (identifier) @function)
  18. ; Function definitions
  19. (function_definition
  20. name: (identifier) @function)
  21. (identifier) @variable
  22. (attribute attribute: (identifier) @property)
  23. (type (identifier) @type)
  24. ; Literals
  25. [
  26. (none)
  27. (true)
  28. (false)
  29. ] @constant.builtin
  30. [
  31. (integer)
  32. (float)
  33. ] @number
  34. (comment) @comment
  35. (string) @string
  36. (escape_sequence) @escape
  37. (interpolation
  38. "{" @punctuation.special
  39. "}" @punctuation.special) @embedded
  40. [
  41. "-"
  42. "-="
  43. "!="
  44. "*"
  45. "**"
  46. "**="
  47. "*="
  48. "/"
  49. "//"
  50. "//="
  51. "/="
  52. "&"
  53. "%"
  54. "%="
  55. "^"
  56. "+"
  57. "->"
  58. "+="
  59. "<"
  60. "<<"
  61. "<="
  62. "<>"
  63. "="
  64. ":="
  65. "=="
  66. ">"
  67. ">="
  68. ">>"
  69. "|"
  70. "~"
  71. "and"
  72. "in"
  73. "is"
  74. "not"
  75. "or"
  76. ] @operator
  77. [
  78. "as"
  79. "assert"
  80. "async"
  81. "await"
  82. "break"
  83. "class"
  84. "continue"
  85. "def"
  86. "del"
  87. "elif"
  88. "else"
  89. "except"
  90. "exec"
  91. "finally"
  92. "for"
  93. "from"
  94. "global"
  95. "if"
  96. "import"
  97. "lambda"
  98. "nonlocal"
  99. "pass"
  100. "print"
  101. "raise"
  102. "return"
  103. "try"
  104. "while"
  105. "with"
  106. "yield"
  107. "match"
  108. "case"
  109. ] @keyword