highlights.scm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ; Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. ; Exceptions. See /LICENSE for license information.
  3. ; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. ; This maps syntax node patterns to highlighting scopes.
  5. ; The scopes are used themes and editors to select style for that node.
  6. (comment) @comment
  7. (builtin_type) @type.builtin
  8. (bool_literal) @constant.builtin
  9. (escape_sequence) @constant.character.escape
  10. (string_literal) @string
  11. (numeric_literal) @constant.builtin
  12. (numeric_type_literal) @type.builtin
  13. ; function declaration or call expression => function
  14. (function_declaration (declared_name (ident) @function))
  15. (call_expression (ident) @function)
  16. ; TODO: add more specific rules
  17. ; upper case => type
  18. ((ident) @type
  19. (#match? @type "^[A-Z]"))
  20. ; lower case => variable
  21. ((ident) @variable
  22. (#match? @variable "^[a-z_]"))
  23. [
  24. "("
  25. ")"
  26. "{"
  27. "}"
  28. "["
  29. "]"
  30. ] @punctuation.bracket
  31. [
  32. "."
  33. ";"
  34. ","
  35. ":"
  36. ":!"
  37. "=>"
  38. ] @punctuation.delimiter
  39. "->" @punctuation
  40. [
  41. "+"
  42. "-"
  43. (binary_star)
  44. "/"
  45. "%"
  46. "=="
  47. "!="
  48. "<"
  49. "<="
  50. ">"
  51. ">="
  52. "not"
  53. "and"
  54. "or"
  55. "|"
  56. "&"
  57. "^"
  58. ">>"
  59. "<<"
  60. "*" ; prefix star
  61. (postfix_star)
  62. "++"
  63. "--"
  64. ] @operator
  65. ; keywords not used in grammar.js are commented out
  66. [
  67. "abstract"
  68. ; "adapt"
  69. "addr"
  70. "alias"
  71. "and"
  72. "api"
  73. "as"
  74. "auto"
  75. "base"
  76. "break"
  77. "case"
  78. "choice"
  79. "class"
  80. "constraint"
  81. "continue"
  82. "default"
  83. "destructor"
  84. "else"
  85. "extend"
  86. ; "final"
  87. "fn"
  88. "for"
  89. "forall"
  90. ; "friend"
  91. "if"
  92. "impl"
  93. "impls"
  94. "import"
  95. "in"
  96. "interface"
  97. "let"
  98. "library"
  99. ; "like"
  100. "match"
  101. "namespace"
  102. "not"
  103. ; "observe"
  104. "or"
  105. ; "override"
  106. "package"
  107. ; "partial"
  108. ; "private"
  109. ; "protected"
  110. "require"
  111. "return"
  112. "returned"
  113. "Self"
  114. "template"
  115. "then"
  116. "type"
  117. "var"
  118. "virtual"
  119. "where"
  120. "while"
  121. ] @keyword