123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- name: 'JavaScript'
- scopeName: 'source.js'
- type: 'tree-sitter'
- parser: 'tree-sitter-javascript'
- fileTypes: ['js', 'jsx']
- injectionRegex: '^js$|^JS$|javascript|JavaScript'
- firstLineRegex: [
- # shebang line
- '^#!.*\\b(node)\\r?\\n'
- # vim modeline
- 'vim\\b.*\\bset\\b.*\\b(filetype|ft|syntax)=(js|javascript)'
- ]
- folds: [
- {
- type: 'comment'
- }
- {
- type: ['jsx_element', 'template_string'],
- start: {index: 0}
- end: {index: -1}
- }
- {
- type: 'jsx_self_closing_element'
- start: {index: 1}
- end: {index: -2}
- }
- {
- start: {index: 0, type: '{'}
- end: {index: -1, type: '}'}
- }
- {
- start: {index: 0, type: '['}
- end: {index: -1, type: ']'}
- }
- {
- start: {index: 0, type: '('}
- end: {index: -1, type: ')'}
- }
- {
- type: ['switch_case', 'switch_default']
- start: {index: 0}
- end: {type: 'break_statement', index: -1}
- }
- {
- type: ['switch_case', 'switch_default']
- start: {index: 0}
- }
- ]
- comments:
- start: '// '
- scopes:
- 'program': 'source.js'
- 'property_identifier': [
- {
- match: '^[\$A-Z_]+$',
- scopes: 'constant.other.property.js'
- }
- 'variable.other.object.property'
- ]
- 'member_expression > property_identifier': 'variable.other.object.property.unquoted'
- 'formal_parameters > identifier': 'variable.parameter.function'
- 'formal_parameters > rest_parameter > identifier': 'variable.parameter.rest.function'
- 'shorthand_property_identifier': [
- {
- match: '^[\$A-Z_]{2,}$',
- scopes: 'constant.other'
- }
- ]
- '
- class > identifier,
- new_expression > identifier
- ': 'meta.class'
- '
- jsx_opening_element > identifier,
- jsx_closing_element > identifier,
- jsx_self_closing_element > identifier
- ': [
- {
- match: '^[A-Z]',
- scopes: 'meta.class.component.jsx'
- }
- ]
- 'call_expression > identifier': {match: '^[A-Z]', scopes: 'meta.class'}
- 'arrow_function > identifier:nth-child(0)': 'variable.parameter.function'
- 'function > identifier': 'entity.name.function'
- 'function_declaration > identifier': 'entity.name.function'
- 'generator_function > identifier': 'entity.name.function'
- 'call_expression > identifier': [
- {match: '^require$', scopes: 'support.function'},
- 'entity.name.function'
- ]
- 'call_expression > super': 'support.function.super'
- 'method_definition > property_identifier': 'entity.name.function'
- 'call_expression > member_expression > property_identifier': 'entity.name.function'
- 'identifier': [
- {
- match: '^(global|globalThis|module|exports|__filename|__dirname)$',
- scopes: 'support.variable'
- },
- {
- match: '^(window|self|frames|event|document|performance|screen|navigator|console)$'
- scopes: 'support.variable.dom'
- },
- {
- exact: 'require',
- scopes: 'support.function'
- },
- {
- match: '^[\$A-Z_]{2,}$',
- scopes: 'constant.other'
- },
- {
- match: '^[A-Z]',
- scopes: 'meta.class'
- },
- ]
- 'number': 'constant.numeric'
- 'string': 'string.quoted'
- 'regex': 'string.regexp'
- 'escape_sequence': 'constant.character.escape'
- 'template_string': 'string.quoted.template'
- 'undefined': 'constant.language'
- 'null': 'constant.language.null'
- 'true': 'constant.language.boolean.true'
- 'false': 'constant.language.boolean.false'
- 'comment': [
- {
- match: "^//",
- scopes: 'comment.line'
- },
- 'comment.block'
- ]
- 'hash_bang_line': 'comment.block'
- '
- jsx_expression > "{",
- jsx_expression > "}",
- template_substitution > "${",
- template_substitution > "}"
- ': 'punctuation.section.embedded'
- 'template_substitution': 'embedded.source'
- '"("': 'punctuation.definition.parameters.begin.bracket.round'
- '")"': 'punctuation.definition.parameters.end.bracket.round'
- '"{"': 'punctuation.definition.function.body.begin.bracket.curly'
- '"}"': 'punctuation.definition.function.body.end.bracket.curly'
- '";"': 'punctuation.terminator.statement.semicolon'
- '"["': 'punctuation.definition.array.begin.bracket.square'
- '"]"': 'punctuation.definition.array.end.bracket.square'
- '"var"': 'storage.type'
- '"let"': 'storage.type'
- '"class"': 'storage.type'
- '"extends"': 'storage.modifier'
- '"const"': 'storage.modifier'
- '"static"': 'storage.modifier'
- '"function"': 'storage.type.function'
- '"=>"': 'storage.type.function.arrow'
- '"="': 'keyword.operator.js'
- '"+="': 'keyword.operator.js'
- '"-="': 'keyword.operator.js'
- '"*="': 'keyword.operator.js'
- '"/="': 'keyword.operator.js'
- '"%="': 'keyword.operator.js'
- '"**="': 'keyword.operator.js'
- '"<<="': 'keyword.operator.js'
- '">>="': 'keyword.operator.js'
- '">>>="': 'keyword.operator.js'
- '"&&="': 'keyword.operator.js'
- '"||="': 'keyword.operator.js'
- '"??="': 'keyword.operator.js'
- '"&="': 'keyword.operator.js'
- '"^="': 'keyword.operator.js'
- '"|="': 'keyword.operator.js'
- '"!"': 'keyword.operator.js'
- '"+"': 'keyword.operator.js'
- '"-"': 'keyword.operator.js'
- '"*"': 'keyword.operator.js'
- '"/"': 'keyword.operator.js'
- '"%"': 'keyword.operator.js'
- '"**"': 'keyword.operator.js'
- '"=="': 'keyword.operator.js'
- '"==="': 'keyword.operator.js'
- '"!="': 'keyword.operator.js'
- '"!=="': 'keyword.operator.js'
- '">="': 'keyword.operator.js'
- '"<="': 'keyword.operator.js'
- '">"': 'keyword.operator.js'
- '"<"': 'keyword.operator.js'
- '"&&"': 'keyword.operator.js'
- '"||"': 'keyword.operator.js'
- '"??"': 'keyword.operator.js'
- '"&"': 'keyword.operator.js'
- '"^"': 'keyword.operator.js'
- '"|"': 'keyword.operator.js'
- '"~"': 'keyword.operator.js'
- '">>"': 'keyword.operator.js'
- '">>>"': 'keyword.operator.js'
- '"<<"': 'keyword.operator.js'
- '"++"': 'keyword.operator.js'
- '"--"': 'keyword.operator.js'
- '"..."': 'keyword.operator.spread.js'
- '"?"': 'keyword.operator.js'
- '":"': 'keyword.operator.js'
- '"in"': 'keyword.operator.in'
- '"instanceof"': 'keyword.operator.instanceof'
- '"of"': 'keyword.operator.of'
- '"new"': 'keyword.operator.new'
- '"delete"': 'keyword.operator.delete'
- '"void"': 'keyword.operator.void'
- '"typeof"': 'keyword.operator.typeof'
- '"get"': 'keyword.operator.setter'
- '"set"': 'keyword.operator.setter'
- '"."': 'meta.delimiter.period'
- '","': 'meta.delimiter.comma'
- '"as"': 'keyword.control'
- '"if"': 'keyword.control'
- '"do"': 'keyword.control'
- '"else"': 'keyword.control'
- '"while"': 'keyword.control'
- '"for"': 'keyword.control'
- '"return"': 'keyword.control'
- '"break"': 'keyword.control'
- '"continue"': 'keyword.control'
- '"throw"': 'keyword.control'
- '"try"': 'keyword.control'
- '"catch"': 'keyword.control'
- '"finally"': 'keyword.control'
- '"switch"': 'keyword.control'
- '"case"': 'keyword.control'
- '"default"': 'keyword.control'
- '"export"': 'keyword.control'
- '"import"': 'keyword.control'
- '"from"': 'keyword.control'
- '"yield"': 'keyword.control'
- '"async"': 'keyword.control'
- '"await"': 'keyword.control'
- '"debugger"': 'keyword.control'
- 'jsx_attribute > property_identifier': 'entity.other.attribute-name'
- 'jsx_opening_element > identifier': 'entity.name.tag'
- 'jsx_closing_element > identifier': 'entity.name.tag'
- 'jsx_self_closing_element > identifier': 'entity.name.tag'
|