tree-sitter-javascript.cson 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. name: 'JavaScript'
  2. scopeName: 'source.js'
  3. type: 'tree-sitter'
  4. parser: 'tree-sitter-javascript'
  5. fileTypes: ['js', 'jsx']
  6. injectionRegex: '^js$|^JS$|javascript|JavaScript'
  7. firstLineRegex: [
  8. # shebang line
  9. '^#!.*\\b(node)\\r?\\n'
  10. # vim modeline
  11. 'vim\\b.*\\bset\\b.*\\b(filetype|ft|syntax)=(js|javascript)'
  12. ]
  13. folds: [
  14. {
  15. type: 'comment'
  16. }
  17. {
  18. type: ['jsx_element', 'template_string'],
  19. start: {index: 0}
  20. end: {index: -1}
  21. }
  22. {
  23. type: 'jsx_self_closing_element'
  24. start: {index: 1}
  25. end: {index: -2}
  26. }
  27. {
  28. start: {index: 0, type: '{'}
  29. end: {index: -1, type: '}'}
  30. }
  31. {
  32. start: {index: 0, type: '['}
  33. end: {index: -1, type: ']'}
  34. }
  35. {
  36. start: {index: 0, type: '('}
  37. end: {index: -1, type: ')'}
  38. }
  39. {
  40. type: ['switch_case', 'switch_default']
  41. start: {index: 0}
  42. end: {type: 'break_statement', index: -1}
  43. }
  44. {
  45. type: ['switch_case', 'switch_default']
  46. start: {index: 0}
  47. }
  48. ]
  49. comments:
  50. start: '// '
  51. scopes:
  52. 'program': 'source.js'
  53. 'property_identifier': [
  54. {
  55. match: '^[\$A-Z_]+$',
  56. scopes: 'constant.other.property.js'
  57. }
  58. 'variable.other.object.property'
  59. ]
  60. 'member_expression > property_identifier': 'variable.other.object.property.unquoted'
  61. 'formal_parameters > identifier': 'variable.parameter.function'
  62. 'formal_parameters > rest_parameter > identifier': 'variable.parameter.rest.function'
  63. 'shorthand_property_identifier': [
  64. {
  65. match: '^[\$A-Z_]{2,}$',
  66. scopes: 'constant.other'
  67. }
  68. ]
  69. '
  70. class > identifier,
  71. new_expression > identifier
  72. ': 'meta.class'
  73. '
  74. jsx_opening_element > identifier,
  75. jsx_closing_element > identifier,
  76. jsx_self_closing_element > identifier
  77. ': [
  78. {
  79. match: '^[A-Z]',
  80. scopes: 'meta.class.component.jsx'
  81. }
  82. ]
  83. 'call_expression > identifier': {match: '^[A-Z]', scopes: 'meta.class'}
  84. 'arrow_function > identifier:nth-child(0)': 'variable.parameter.function'
  85. 'function > identifier': 'entity.name.function'
  86. 'function_declaration > identifier': 'entity.name.function'
  87. 'generator_function > identifier': 'entity.name.function'
  88. 'call_expression > identifier': [
  89. {match: '^require$', scopes: 'support.function'},
  90. 'entity.name.function'
  91. ]
  92. 'call_expression > super': 'support.function.super'
  93. 'method_definition > property_identifier': 'entity.name.function'
  94. 'call_expression > member_expression > property_identifier': 'entity.name.function'
  95. 'identifier': [
  96. {
  97. match: '^(global|globalThis|module|exports|__filename|__dirname)$',
  98. scopes: 'support.variable'
  99. },
  100. {
  101. match: '^(window|self|frames|event|document|performance|screen|navigator|console)$'
  102. scopes: 'support.variable.dom'
  103. },
  104. {
  105. exact: 'require',
  106. scopes: 'support.function'
  107. },
  108. {
  109. match: '^[\$A-Z_]{2,}$',
  110. scopes: 'constant.other'
  111. },
  112. {
  113. match: '^[A-Z]',
  114. scopes: 'meta.class'
  115. },
  116. ]
  117. 'number': 'constant.numeric'
  118. 'string': 'string.quoted'
  119. 'regex': 'string.regexp'
  120. 'escape_sequence': 'constant.character.escape'
  121. 'template_string': 'string.quoted.template'
  122. 'undefined': 'constant.language'
  123. 'null': 'constant.language.null'
  124. 'true': 'constant.language.boolean.true'
  125. 'false': 'constant.language.boolean.false'
  126. 'comment': [
  127. {
  128. match: "^//",
  129. scopes: 'comment.line'
  130. },
  131. 'comment.block'
  132. ]
  133. 'hash_bang_line': 'comment.block'
  134. '
  135. jsx_expression > "{",
  136. jsx_expression > "}",
  137. template_substitution > "${",
  138. template_substitution > "}"
  139. ': 'punctuation.section.embedded'
  140. 'template_substitution': 'embedded.source'
  141. '"("': 'punctuation.definition.parameters.begin.bracket.round'
  142. '")"': 'punctuation.definition.parameters.end.bracket.round'
  143. '"{"': 'punctuation.definition.function.body.begin.bracket.curly'
  144. '"}"': 'punctuation.definition.function.body.end.bracket.curly'
  145. '";"': 'punctuation.terminator.statement.semicolon'
  146. '"["': 'punctuation.definition.array.begin.bracket.square'
  147. '"]"': 'punctuation.definition.array.end.bracket.square'
  148. '"var"': 'storage.type'
  149. '"let"': 'storage.type'
  150. '"class"': 'storage.type'
  151. '"extends"': 'storage.modifier'
  152. '"const"': 'storage.modifier'
  153. '"static"': 'storage.modifier'
  154. '"function"': 'storage.type.function'
  155. '"=>"': 'storage.type.function.arrow'
  156. '"="': 'keyword.operator.js'
  157. '"+="': 'keyword.operator.js'
  158. '"-="': 'keyword.operator.js'
  159. '"*="': 'keyword.operator.js'
  160. '"/="': 'keyword.operator.js'
  161. '"%="': 'keyword.operator.js'
  162. '"**="': 'keyword.operator.js'
  163. '"<<="': 'keyword.operator.js'
  164. '">>="': 'keyword.operator.js'
  165. '">>>="': 'keyword.operator.js'
  166. '"&&="': 'keyword.operator.js'
  167. '"||="': 'keyword.operator.js'
  168. '"??="': 'keyword.operator.js'
  169. '"&="': 'keyword.operator.js'
  170. '"^="': 'keyword.operator.js'
  171. '"|="': 'keyword.operator.js'
  172. '"!"': 'keyword.operator.js'
  173. '"+"': 'keyword.operator.js'
  174. '"-"': 'keyword.operator.js'
  175. '"*"': 'keyword.operator.js'
  176. '"/"': 'keyword.operator.js'
  177. '"%"': 'keyword.operator.js'
  178. '"**"': 'keyword.operator.js'
  179. '"=="': 'keyword.operator.js'
  180. '"==="': 'keyword.operator.js'
  181. '"!="': 'keyword.operator.js'
  182. '"!=="': 'keyword.operator.js'
  183. '">="': 'keyword.operator.js'
  184. '"<="': 'keyword.operator.js'
  185. '">"': 'keyword.operator.js'
  186. '"<"': 'keyword.operator.js'
  187. '"&&"': 'keyword.operator.js'
  188. '"||"': 'keyword.operator.js'
  189. '"??"': 'keyword.operator.js'
  190. '"&"': 'keyword.operator.js'
  191. '"^"': 'keyword.operator.js'
  192. '"|"': 'keyword.operator.js'
  193. '"~"': 'keyword.operator.js'
  194. '">>"': 'keyword.operator.js'
  195. '">>>"': 'keyword.operator.js'
  196. '"<<"': 'keyword.operator.js'
  197. '"++"': 'keyword.operator.js'
  198. '"--"': 'keyword.operator.js'
  199. '"..."': 'keyword.operator.spread.js'
  200. '"?"': 'keyword.operator.js'
  201. '":"': 'keyword.operator.js'
  202. '"in"': 'keyword.operator.in'
  203. '"instanceof"': 'keyword.operator.instanceof'
  204. '"of"': 'keyword.operator.of'
  205. '"new"': 'keyword.operator.new'
  206. '"delete"': 'keyword.operator.delete'
  207. '"void"': 'keyword.operator.void'
  208. '"typeof"': 'keyword.operator.typeof'
  209. '"get"': 'keyword.operator.setter'
  210. '"set"': 'keyword.operator.setter'
  211. '"."': 'meta.delimiter.period'
  212. '","': 'meta.delimiter.comma'
  213. '"as"': 'keyword.control'
  214. '"if"': 'keyword.control'
  215. '"do"': 'keyword.control'
  216. '"else"': 'keyword.control'
  217. '"while"': 'keyword.control'
  218. '"for"': 'keyword.control'
  219. '"return"': 'keyword.control'
  220. '"break"': 'keyword.control'
  221. '"continue"': 'keyword.control'
  222. '"throw"': 'keyword.control'
  223. '"try"': 'keyword.control'
  224. '"catch"': 'keyword.control'
  225. '"finally"': 'keyword.control'
  226. '"switch"': 'keyword.control'
  227. '"case"': 'keyword.control'
  228. '"default"': 'keyword.control'
  229. '"export"': 'keyword.control'
  230. '"import"': 'keyword.control'
  231. '"from"': 'keyword.control'
  232. '"yield"': 'keyword.control'
  233. '"async"': 'keyword.control'
  234. '"await"': 'keyword.control'
  235. '"debugger"': 'keyword.control'
  236. 'jsx_attribute > property_identifier': 'entity.other.attribute-name'
  237. 'jsx_opening_element > identifier': 'entity.name.tag'
  238. 'jsx_closing_element > identifier': 'entity.name.tag'
  239. 'jsx_self_closing_element > identifier': 'entity.name.tag'