highlights.scm 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. ;; Keywords
  2. "return" @keyword.return
  3. [
  4. "goto"
  5. "in"
  6. "local"
  7. ] @keyword
  8. (label_statement) @label
  9. (break_statement) @keyword
  10. (do_statement
  11. [
  12. "do"
  13. "end"
  14. ] @keyword)
  15. (while_statement
  16. [
  17. "while"
  18. "do"
  19. "end"
  20. ] @repeat)
  21. (repeat_statement
  22. [
  23. "repeat"
  24. "until"
  25. ] @repeat)
  26. (if_statement
  27. [
  28. "if"
  29. "elseif"
  30. "else"
  31. "then"
  32. "end"
  33. ] @conditional)
  34. (elseif_statement
  35. [
  36. "elseif"
  37. "then"
  38. "end"
  39. ] @conditional)
  40. (else_statement
  41. [
  42. "else"
  43. "end"
  44. ] @conditional)
  45. (for_statement
  46. [
  47. "for"
  48. "do"
  49. "end"
  50. ] @repeat)
  51. (function_declaration
  52. [
  53. "function"
  54. "end"
  55. ] @keyword.function)
  56. (function_definition
  57. [
  58. "function"
  59. "end"
  60. ] @keyword.function)
  61. ;; Operators
  62. [
  63. "and"
  64. "not"
  65. "or"
  66. ] @keyword.operator
  67. [
  68. "+"
  69. "-"
  70. "*"
  71. "/"
  72. "%"
  73. "^"
  74. "#"
  75. "=="
  76. "~="
  77. "<="
  78. ">="
  79. "<"
  80. ">"
  81. "="
  82. "&"
  83. "~"
  84. "|"
  85. "<<"
  86. ">>"
  87. "//"
  88. ".."
  89. ] @operator
  90. ;; Punctuations
  91. [
  92. ";"
  93. ":"
  94. ","
  95. "."
  96. ] @punctuation.delimiter
  97. ;; Brackets
  98. [
  99. "("
  100. ")"
  101. "["
  102. "]"
  103. "{"
  104. "}"
  105. ] @punctuation.bracket
  106. ;; Variables
  107. (identifier) @variable
  108. ((identifier) @variable.builtin
  109. (#eq? @variable.builtin "self"))
  110. ;; Constants
  111. ((identifier) @constant
  112. (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
  113. (vararg_expression) @constant
  114. (nil) @constant.builtin
  115. [
  116. (false)
  117. (true)
  118. ] @boolean
  119. ;; Tables
  120. (field name: (identifier) @field)
  121. (dot_index_expression field: (identifier) @field)
  122. (table_constructor
  123. [
  124. "{"
  125. "}"
  126. ] @constructor)
  127. ;; Functions
  128. (parameters (identifier) @parameter)
  129. (function_call name: (identifier) @function.call)
  130. (function_declaration name: (identifier) @function)
  131. (function_call name: (dot_index_expression field: (identifier) @function.call))
  132. (function_declaration name: (dot_index_expression field: (identifier) @function))
  133. (method_index_expression method: (identifier) @method)
  134. (function_call
  135. (identifier) @function.builtin
  136. (#any-of? @function.builtin
  137. ;; built-in functions in Lua 5.1
  138. "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs"
  139. "load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print"
  140. "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable"
  141. "tonumber" "tostring" "type" "unpack" "xpcall"))
  142. ;; Others
  143. (comment) @comment
  144. (comment) @spell
  145. (hash_bang_line) @comment
  146. (number) @number
  147. (string) @string
  148. (string) @spell
  149. ;; Error
  150. (ERROR) @error