highlights.scm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. (identifier) @variable
  2. ((identifier) @constant
  3. (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
  4. ; Keywords
  5. [
  6. "if"
  7. "else"
  8. "elseif"
  9. "endif"
  10. ] @keyword.conditional
  11. [
  12. "try"
  13. "catch"
  14. "finally"
  15. "endtry"
  16. "throw"
  17. ] @keyword.exception
  18. [
  19. "for"
  20. "endfor"
  21. "in"
  22. "while"
  23. "endwhile"
  24. "break"
  25. "continue"
  26. ] @keyword.repeat
  27. [
  28. "function"
  29. "endfunction"
  30. ] @keyword.function
  31. ; Function related
  32. (function_declaration
  33. name: (_) @function)
  34. (call_expression
  35. function: (identifier) @function.call)
  36. (call_expression
  37. function: (scoped_identifier
  38. (identifier) @function.call))
  39. (parameters
  40. (identifier) @variable.parameter)
  41. (default_parameter
  42. (identifier) @variable.parameter)
  43. [
  44. (bang)
  45. (spread)
  46. ] @punctuation.special
  47. [
  48. (no_option)
  49. (inv_option)
  50. (default_option)
  51. (option_name)
  52. ] @variable.builtin
  53. [
  54. (scope)
  55. "a:"
  56. "$"
  57. ] @module
  58. ; Commands and user defined commands
  59. [
  60. "let"
  61. "unlet"
  62. "const"
  63. "call"
  64. "execute"
  65. "normal"
  66. "set"
  67. "setfiletype"
  68. "setlocal"
  69. "silent"
  70. "echo"
  71. "echon"
  72. "echohl"
  73. "echomsg"
  74. "echoerr"
  75. "autocmd"
  76. "augroup"
  77. "return"
  78. "syntax"
  79. "filetype"
  80. "source"
  81. "lua"
  82. "ruby"
  83. "perl"
  84. "python"
  85. "highlight"
  86. "command"
  87. "delcommand"
  88. "comclear"
  89. "colorscheme"
  90. "scriptencoding"
  91. "startinsert"
  92. "stopinsert"
  93. "global"
  94. "runtime"
  95. "wincmd"
  96. "cnext"
  97. "cprevious"
  98. "cNext"
  99. "vertical"
  100. "leftabove"
  101. "aboveleft"
  102. "rightbelow"
  103. "belowright"
  104. "topleft"
  105. "botright"
  106. (unknown_command_name)
  107. "edit"
  108. "enew"
  109. "find"
  110. "ex"
  111. "visual"
  112. "view"
  113. "eval"
  114. "sign"
  115. "abort"
  116. ] @keyword
  117. (map_statement
  118. cmd: _ @keyword)
  119. (keycode) @character.special
  120. (command_name) @function.macro
  121. ; Filetype command
  122. (filetype_statement
  123. [
  124. "detect"
  125. "plugin"
  126. "indent"
  127. "on"
  128. "off"
  129. ] @keyword)
  130. ; Syntax command
  131. (syntax_statement
  132. (keyword) @string)
  133. (syntax_statement
  134. [
  135. "enable"
  136. "on"
  137. "off"
  138. "reset"
  139. "case"
  140. "spell"
  141. "foldlevel"
  142. "iskeyword"
  143. "keyword"
  144. "match"
  145. "cluster"
  146. "region"
  147. "clear"
  148. "include"
  149. ] @keyword)
  150. (syntax_argument
  151. name: _ @keyword)
  152. [
  153. "<buffer>"
  154. "<nowait>"
  155. "<silent>"
  156. "<script>"
  157. "<expr>"
  158. "<unique>"
  159. ] @constant.builtin
  160. (augroup_name) @module
  161. (au_event) @constant
  162. (normal_statement
  163. (commands) @constant)
  164. ; Highlight command
  165. (hl_attribute
  166. key: _ @property
  167. val: _ @constant)
  168. (hl_group) @type
  169. (highlight_statement
  170. [
  171. "default"
  172. "link"
  173. "clear"
  174. ] @keyword)
  175. ; Command command
  176. (command) @string
  177. (command_attribute
  178. name: _ @property
  179. val: (behavior
  180. name: _ @constant
  181. val: (identifier)? @function)?)
  182. ; Edit command
  183. (plus_plus_opt
  184. val: _? @constant) @property
  185. (plus_cmd
  186. "+" @property) @property
  187. ; Runtime command
  188. (runtime_statement
  189. (where) @keyword.operator)
  190. ; Colorscheme command
  191. (colorscheme_statement
  192. (name) @string)
  193. ; Scriptencoding command
  194. (scriptencoding_statement
  195. (encoding) @string.special)
  196. ; Literals
  197. (string_literal) @string
  198. (integer_literal) @number
  199. (float_literal) @number.float
  200. (comment) @comment @spell
  201. (line_continuation_comment) @comment @spell
  202. (pattern) @string.special
  203. (pattern_multi) @string.regexp
  204. (filename) @string.special.path
  205. (heredoc
  206. (body) @string)
  207. (heredoc
  208. (parameter) @keyword)
  209. [
  210. (marker_definition)
  211. (endmarker)
  212. ] @label
  213. (literal_dictionary
  214. (literal_key) @property)
  215. ((scoped_identifier
  216. (scope) @_scope
  217. .
  218. (identifier) @boolean)
  219. (#eq? @_scope "v:")
  220. (#any-of? @boolean "true" "false"))
  221. ; Operators
  222. [
  223. "||"
  224. "&&"
  225. "&"
  226. "+"
  227. "-"
  228. "*"
  229. "/"
  230. "%"
  231. ".."
  232. "=="
  233. "!="
  234. ">"
  235. ">="
  236. "<"
  237. "<="
  238. "=~"
  239. "!~"
  240. "="
  241. "^="
  242. "+="
  243. "-="
  244. "*="
  245. "/="
  246. "%="
  247. ".="
  248. "..="
  249. "<<"
  250. "=<<"
  251. "->"
  252. (match_case)
  253. ] @operator
  254. [
  255. "is"
  256. "isnot"
  257. ] @keyword.operator
  258. ; Some characters have different meanings based on the context
  259. (unary_operation
  260. "!" @operator)
  261. (binary_operation
  262. "." @operator)
  263. ; Punctuation
  264. [
  265. "("
  266. ")"
  267. "{"
  268. "}"
  269. "["
  270. "]"
  271. "#{"
  272. ] @punctuation.bracket
  273. (field_expression
  274. "." @punctuation.delimiter)
  275. [
  276. ","
  277. ":"
  278. ] @punctuation.delimiter
  279. (ternary_expression
  280. [
  281. "?"
  282. ":"
  283. ] @keyword.conditional.ternary)
  284. ; Options
  285. ((set_value) @number
  286. (#lua-match? @number "^[%d]+(%.[%d]+)?$"))
  287. (inv_option
  288. "!" @operator)
  289. (set_item
  290. "?" @operator)
  291. ((set_item
  292. option: (option_name) @_option
  293. value: (set_value) @function)
  294. (#any-of? @_option "tagfunc" "tfu" "completefunc" "cfu" "omnifunc" "ofu" "operatorfunc" "opfunc"))