diff --git a/grammars/ts.cson b/grammars/ts.cson
new file mode 100644
index 000000000..bc9d3bb2e
--- /dev/null
+++ b/grammars/ts.cson
@@ -0,0 +1,974 @@
+name: "TypeScript"
+scopeName: "source.ts"
+fileTypes: [
+ "ts"
+]
+uuid: "ef98eb90-bf9b-11e4-bb52-0800200c9a66"
+patterns: [
+ {
+ include: "#expression"
+ }
+]
+repository:
+ "var-expr":
+ name: "meta.var.expr.ts"
+ begin: "(?]|var|type|function|class|interface)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "enum-declaration":
+ name: "meta.enum.declaration.ts"
+ match: "(?:\\b(const)\\s+)?\\b(enum)\\s+([a-zA-Z_$][\\w$]*)"
+ captures:
+ "1":
+ name: "storage.modifier.ts"
+ "2":
+ name: "storage.type.ts"
+ "3":
+ name: "entity.name.class.ts"
+ "object-declaration":
+ name: "meta.declaration.object.ts"
+ begin: "\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(?])|(?<=[\\}>\\]\\)]|[a-zA-Z_$])\\s*(?=\\{)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ type:
+ name: "meta.type.ts"
+ patterns: [
+ {
+ include: "#type-primitive"
+ }
+ {
+ include: "#type-parameters"
+ }
+ {
+ include: "#type-tuple"
+ }
+ {
+ include: "#type-object"
+ }
+ {
+ include: "#type-operator"
+ }
+ {
+ include: "#type-paren-or-function-type-parameters"
+ }
+ {
+ include: "#type-function-return-type"
+ }
+ {
+ include: "#type-name"
+ }
+ ]
+ "function-type-parameters":
+ name: "meta.function.type.parameter.ts"
+ begin: "\\("
+ beginCaptures:
+ "0":
+ name: "meta.brace.round.ts"
+ end: "\\)"
+ endCaptures:
+ "0":
+ name: "meta.brace.round.ts"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#parameter-name"
+ }
+ {
+ include: "#type-annotation"
+ }
+ {
+ include: "#variable-initializer"
+ }
+ ]
+ "type-primitive":
+ name: "meta.type.primitive.ts"
+ match: "\\b(string|number|boolean|symbol|any|void)\\b"
+ captures:
+ "1":
+ name: "storage.type.ts"
+ "type-paren-or-function-type-parameters":
+ name: "meta.type.paren.cover.ts"
+ begin: "(?:\\b(new)\\b)?\\s*\\("
+ beginCaptures:
+ "1":
+ name: "keyword.control.ts"
+ end: "\\)"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ {
+ include: "#function-type-parameters"
+ }
+ ]
+ "await-modifier":
+ name: "storage.modifier.ts"
+ match: "await"
+ "type-operator":
+ name: "keyword.operator.type.ts"
+ match: "[.|]"
+ "type-function-return-type":
+ name: "meta.type.function.return.ts"
+ begin: "=>"
+ beginCaptures:
+ "0":
+ name: "keyword.operator.ts"
+ end: "(?=\\s*[,\\)\\{=;>]|//|$)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "type-tuple":
+ name: "meta.type.tuple.ts"
+ begin: "\\["
+ beginCaptures:
+ "0":
+ name: "meta.brace.square.ts"
+ end: "\\]"
+ endCaptures:
+ "0":
+ name: "meta.brace.square.ts"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ "type-name":
+ name: "meta.type.name.ts"
+ match: "[a-zA-Z_$][.\\w$]*"
+ captures:
+ "1":
+ name: "entity.name.type.ts"
+ "type-parameters":
+ name: "meta.type.parameters.ts"
+ begin: "([a-zA-Z_$][\\w$]*)?(<)"
+ beginCaptures:
+ "1":
+ name: "entity.name.type.ts"
+ "2":
+ name: "meta.brace.angle.ts"
+ end: "(?=$)|(>)"
+ endCaptures:
+ "2":
+ name: "meta.brace.angle.ts"
+ patterns: [
+ {
+ name: "keyword.other.ts"
+ match: "\\b(extends)\\b"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ ]
+ "variable-initializer":
+ begin: "(=)"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.ts"
+ end: "(?=$|[,);=])"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ expression:
+ name: "meta.expression.ts"
+ patterns: [
+ {
+ comment: "Match ES6 \"import from\" syntax"
+ match: "(import).*(from)\\s+((['\"`]).*\\4)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "keyword.other.ts"
+ "3":
+ name: "es6import.path.string"
+ }
+ {
+ comment: "Match import = require"
+ match: "(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\s*=\\s*(require)\\s*\\((.*)\\)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "variable.type.ts"
+ "3":
+ name: "keyword.other.ts"
+ "4":
+ name: "require.path.string"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match full triple slash reference comments"
+ match: "(\\/\\/\\/\\s*)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "reference.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match debugger statement"
+ match: "\\b(debugger)\\b"
+ captures:
+ "1":
+ name: "keyword.debugger.ts"
+ }
+ {
+ include: "#for-in-simple"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#regex"
+ }
+ {
+ include: "#template"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#literal"
+ }
+ {
+ include: "#paren-expression"
+ }
+ {
+ include: "#var-expr"
+ }
+ {
+ include: "#declaration"
+ }
+ {
+ include: "#cast"
+ }
+ {
+ include: "#new-expr"
+ }
+ {
+ include: "#block"
+ }
+ {
+ include: "#expression-operator"
+ }
+ {
+ include: "#relational-operator"
+ }
+ {
+ include: "#arithmetic-operator"
+ }
+ {
+ include: "#logic-operator"
+ }
+ {
+ include: "#assignment-operator"
+ }
+ {
+ include: "#storage-keyword"
+ }
+ {
+ include: "#function-call"
+ }
+ {
+ include: "#switch-case"
+ }
+ {
+ include: "#control-statement"
+ }
+ ]
+ "for-in-simple":
+ name: "forin.expr.ts"
+ match: "(?<=\\()\\s*\\b(var|let|const)\\s+([a-zA-Z_$][\\w$]*)\\s+(in|of)\\b"
+ captures:
+ "1":
+ name: "storage.type.ts"
+ "3":
+ name: "keyword.operator.ts"
+ "function-call":
+ name: "functioncall.expr.ts"
+ patterns: [
+ {
+ include: "#await-modifier"
+ }
+ {
+ include: "#type-parameters"
+ }
+ {
+ include: "#paren-expression"
+ }
+ ]
+ cast:
+ name: "cast.expr.ts"
+ begin: "(?:(?<=return|throw|yield|await|[=(,:>]))\\s*(<)(?!\\=)"
+ beginCaptures:
+ "1":
+ name: "meta.brace.angle.ts"
+ end: ">"
+ endCaptures:
+ "0":
+ name: "meta.brace.angle.ts"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "new-expr":
+ name: "new.expr.ts"
+ begin: "\\b(new)\\b"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.ts"
+ end: "(?=[(;]|$)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ "object-member":
+ name: "meta.object.member.ts"
+ begin: "[a-zA-Z_$][\\w$]*\\s*:"
+ end: "(?=,|\\})"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ "expression-operator":
+ name: "keyword.operator.ts"
+ match: "=>|\\b(delete|export|import|in|instanceof|module|namespace|new|typeof|void)\\b"
+ "arithmetic-operator":
+ name: "keyword.operator.arithmetic.ts"
+ match: "\\*|/|\\-\\-|\\-|\\+\\+|\\+|%"
+ "relational-operator":
+ name: "keyword.operator.comparison.ts"
+ match: "===|==|=|!=|!==|<=|>=|<>|<|>"
+ "assignment-operator":
+ name: "keyword.operator.assignment.ts"
+ match: "<<=|>>=|>>>=|\\*=|(?]|var|type|function|class|interface)"
- patterns: [
- {
- include: "#type"
- }
- ]
- "enum-declaration":
- name: "meta.enum.declaration.tsx"
- match: "(?:\\b(const)\\s+)?\\b(enum)\\s+([a-zA-Z_$][\\w$]*)"
- captures:
- "1":
- name: "storage.modifier.tsx"
- "2":
- name: "storage.type.tsx"
- "3":
- name: "entity.name.class.tsx"
- "object-declaration":
- name: "meta.declaration.object.tsx"
- begin: "\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(?])|(?<=[\\}>\\]\\)]|[a-zA-Z_$])\\s*(?=\\{)"
- patterns: [
- {
- include: "#type"
- }
- {
- include: "#string"
- }
- {
- include: "#comment"
- }
- ]
- type:
- name: "meta.type.tsx"
- patterns: [
- {
- include: "#type-primitive"
- }
- {
- include: "#type-parameters"
- }
- {
- include: "#type-tuple"
- }
- {
- include: "#type-object"
- }
- {
- include: "#type-operator"
- }
- {
- include: "#type-paren-or-function-type-parameters"
- }
- {
- include: "#type-function-return-type"
- }
- {
- include: "#type-name"
- }
- ]
- "function-type-parameters":
- name: "meta.function.type.parameter.tsx"
- begin: "\\("
- beginCaptures:
- "0":
- name: "meta.brace.round.tsx"
- end: "\\)"
- endCaptures:
- "0":
- name: "meta.brace.round.tsx"
- patterns: [
- {
- include: "#comment"
- }
- {
- include: "#parameter-name"
- }
- {
- include: "#type-annotation"
- }
- {
- include: "#variable-initializer"
- }
- ]
- "type-primitive":
- name: "meta.type.primitive.tsx"
- match: "\\b(string|number|boolean|symbol|any|void)\\b"
- captures:
- "1":
- name: "storage.type.tsx"
- "type-paren-or-function-type-parameters":
- name: "meta.type.paren.cover.tsx"
- begin: "(?:\\b(new)\\b)?\\s*\\("
- beginCaptures:
- "1":
- name: "keyword.control.tsx"
- end: "\\)"
- patterns: [
- {
- include: "#comment"
- }
- {
- include: "#type"
- }
- {
- include: "#function-type-parameters"
- }
- ]
- "type-operator":
- name: "keyword.operator.type.tsx"
- match: "[.|]"
- "type-function-return-type":
- name: "meta.type.function.return.tsx"
- begin: "=>"
- beginCaptures:
- "0":
- name: "keyword.operator.tsx"
- end: "(?=\\s*[,\\)\\{=;>]|//|$)"
- patterns: [
- {
- include: "#type"
- }
- ]
- "type-tuple":
- name: "meta.type.tuple.tsx"
- begin: "\\["
- beginCaptures:
- "0":
- name: "meta.brace.square.tsx"
- end: "\\]"
- endCaptures:
- "0":
- name: "meta.brace.square.tsx"
- patterns: [
- {
- include: "#type"
- }
- {
- include: "#comment"
- }
- ]
- "type-name":
- name: "meta.type.name.tsx"
- match: "[a-zA-Z_$][.\\w$]*"
- captures:
- "1":
- name: "entity.name.type.tsx"
- "type-parameters":
- name: "meta.type.parameters.tsx"
- begin: "([a-zA-Z_$][\\w$]*)?(<)"
- beginCaptures:
- "1":
- name: "entity.name.type.tsx"
- "2":
- name: "meta.brace.angle.tsx"
- end: "(?=$)|(>)"
- endCaptures:
- "2":
- name: "meta.brace.angle.tsx"
- patterns: [
- {
- name: "keyword.other.tsx"
- match: "\\b(extends)\\b"
- }
- {
- include: "#comment"
- }
- {
- include: "#type"
- }
- ]
- "variable-initializer":
- begin: "(=)"
- beginCaptures:
- "1":
- name: "keyword.operator.tsx"
- end: "(?=$|[,);=])"
- patterns: [
- {
- include: "#expression"
- }
- ]
- expression:
- name: "meta.expression.tsx"
- patterns: [
- {
- include: "#jsx"
- }
- {
- include: "#for-in-simple"
- }
- {
- include: "#string"
- }
- {
- include: "#regex"
- }
- {
- include: "#template"
- }
- {
- include: "#comment"
- }
- {
- include: "#literal"
- }
- {
- include: "#paren-expression"
- }
- {
- include: "#var-expr"
- }
- {
- include: "#declaration"
- }
- {
- include: "#new-expr"
- }
- {
- include: "#block"
- }
- {
- include: "#expression-operator"
- }
- {
- include: "#relational-operator"
- }
- {
- include: "#arithmetic-operator"
- }
- {
- include: "#logic-operator"
- }
- {
- include: "#assignment-operator"
- }
- {
- include: "#storage-keyword"
- }
- {
- include: "#function-call"
- }
- {
- include: "#switch-case"
- }
- {
- include: "#control-statement"
- }
- ]
- "for-in-simple":
- name: "forin.expr.tsx"
- match: "(?<=\\()\\s*\\b(var|let|const)\\s+([a-zA-Z_$][\\w$]*)\\s+(in|of)\\b"
- captures:
- "1":
- name: "storage.type.tsx"
- "3":
- name: "keyword.operator.tsx"
- "function-call":
- name: "functioncall.expr.tsx"
- patterns: [
- {
- include: "#type-parameters"
- }
- {
- include: "#paren-expression"
- }
- ]
- "new-expr":
- name: "new.expr.tsx"
- begin: "\\b(new)\\b"
- beginCaptures:
- "1":
- name: "keyword.operator.tsx"
- end: "(?=[(;]|$)"
- patterns: [
- {
- include: "#type"
- }
- ]
- "object-member":
- name: "meta.object.member.tsx"
- begin: "[a-zA-Z_$][\\w$]*\\s*:"
- end: "(?=,|\\})"
- patterns: [
- {
- include: "#expression"
- }
- ]
- "expression-operator":
- name: "keyword.operator.tsx"
- match: "=>|\\b(delete|export|import|in|instanceof|module|namespace|new|typeof|void|as)\\b"
- "arithmetic-operator":
- name: "keyword.operator.arithmetic.tsx"
- match: "\\*|/|\\-\\-|\\-|\\+\\+|\\+|%"
- "relational-operator":
- name: "keyword.operator.comparison.tsx"
- match: "===|==|=|!=|!==|<=|>=|<>|<|>"
- "assignment-operator":
- name: "keyword.operator.assignment.tsx"
- match: "<<=|>>=|>>>=|\\*=|(?|/\\*|//)
- '''
- captures:
- "1":
- name: "entity.other.attribute-name.tsx"
- "jsx-tag-attribute-assignment":
- name: "keyword.operator.assignment.tsx"
- match: "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))"
- "jsx-string-double-quoted":
- name: "string.quoted.double.tsx"
- begin: "\""
- end: "\""
- beginCaptures:
- "0":
- name: "punctuation.definition.string.begin.tsx"
- endCaptures:
- "0":
- name: "punctuation.definition.string.end.tsx"
- patterns: [
- {
- include: "#jsx-entities"
- }
- ]
- "jsx-string-single-quoted":
- name: "string.quoted.single.tsx"
- begin: "'"
- end: "'"
- beginCaptures:
- "0":
- name: "punctuation.definition.string.begin.tsx"
- endCaptures:
- "0":
- name: "punctuation.definition.string.end.tsx"
- patterns: [
- {
- include: "#jsx-entities"
- }
- ]
- "jsx-entities":
- patterns: [
- {
- name: "constant.character.entity.tsx"
- match: "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)"
- captures:
- "1":
- name: "punctuation.definition.entity.tsx"
- "3":
- name: "punctuation.definition.entity.tsx"
- }
- {
- name: "invalid.illegal.bad-ampersand.tsx"
- match: "&"
- }
- ]
- "jsx-evaluated-code":
- name: "meta.brace.curly.tsx"
- begin: "{"
- end: "}"
- beginCaptures:
- "0":
- name: "punctuation.definition.brace.curly.start.tsx"
- endCaptures:
- "0":
- name: "punctuation.definition.brace.curly.end.tsx"
- patterns: [
- {
- include: "#expression"
- }
- ]
- "jsx-tag-attributes-illegal":
- name: "invalid.illegal.attribute.tsx"
- match: "\\S+"
- "jsx-tag-without-attributes":
- name: "tag.without-attributes.tsx"
- begin: "(<)([_$a-zA-Z][-$\\w.]*(?)"
- end: "()([_$a-zA-Z][-$\\w.]*(?)"
- beginCaptures:
- "1":
- name: "punctuation.definition.tag.begin.tsx"
- "2":
- name: "entity.name.tag.tsx"
- "3":
- name: "punctuation.definition.tag.end.tsx"
- endCaptures:
- "1":
- name: "punctuation.definition.tag.begin.tsx"
- "2":
- name: "entity.name.tag.tsx"
- "3":
- name: "punctuation.definition.tag.end.tsx"
- patterns: [
- {
- include: "#jsx-children"
- }
- ]
- "jsx-tag-open":
- name: "tag.open.tsx"
- begin: '''
- (?x)
- (<)
- ([_$a-zA-Z][-$\\w.]*(?)
- '''
- end: "(/?>)"
- beginCaptures:
- "1":
- name: "punctuation.definition.tag.begin.tsx"
- "2":
- name: "entity.name.tag.tsx"
- endCaptures:
- "1":
- name: "punctuation.definition.tag.end.tsx"
- patterns: [
- {
- include: "#comment"
- }
- {
- include: "#jsx-tag-attributes"
- }
- {
- include: "#jsx-tag-attributes-illegal"
- }
- ]
- "jsx-tag-close":
- name: "tag.close.tsx"
- begin: "()([_$a-zA-Z][-$\\w.]*(?)"
- beginCaptures:
- "1":
- name: "punctuation.definition.tag.begin.tsx"
- "2":
- name: "entity.name.tag.tsx"
- endCaptures:
- "1":
- name: "punctuation.definition.tag.end.tsx"
- patterns: [
- {
- include: "#comment"
- }
- ]
- "jsx-tag-invalid":
- name: "invalid.illegal.tag.incomplete.tsx"
- match: "<\\s*>"
- "jsx-children":
- patterns: [
- {
- include: "#jsx-tag-without-attributes"
- }
- {
- include: "#jsx-tag-open"
- }
- {
- include: "#jsx-tag-close"
- }
- {
- include: "#jsx-tag-invalid"
- }
- {
- include: "#jsx-evaluated-code"
- }
- {
- include: "#jsx-entities"
- }
- ]
- jsx:
- name: "meta.jsx.tsx"
- patterns: [
- ####
- # Rules that no one should change
- # These are used by code to provide fancy completions
- ####
-
- {
- 'comment': 'Match debugger statement'
- 'match': '\\s*(debugger)[\\s;]+'
- 'captures':
- '1':
- 'name':'keyword.debugger.ts'
- }
- {
- 'comment': 'Match full triple slash reference comments'
- 'match': '(\\/\\/\\/\\s*)'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'reference.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match )'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'amd.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match )'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'amd.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match import = require'
- 'match': '(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)?\\s*=\\s*(require)\\s*\\((.*)\\)'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'variable.type.ts'
- '3':
- 'name':'keyword.other.ts'
- '4':
- 'name':'require.path.string'
- }
- {
- 'comment': 'Match ES6 "import from" syntax'
- 'match': '(import).*(from)\\s*(.*[\'"])'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'keyword.other.ts'
- '3':
- 'name':'es6import.path.string'
- }
-
- ####
- # Other rules
- ####
-
- {
- include: "#jsx-tag-without-attributes"
- }
- {
- include: "#jsx-tag-open"
- }
- {
- include: "#jsx-tag-close"
- }
- {
- include: "#jsx-tag-invalid"
- }
- {
- name: "meta.jsx.children.tsx"
- begin: "(?<=(?:'|\"|})>)"
- end: "(?=)"
- patterns: [
- {
- include: "#jsx-children"
- }
- ]
- }
- ]
+ "var-expr":
+ name: "meta.var.expr.tsx"
+ begin: "(?]|var|type|function|class|interface)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "enum-declaration":
+ name: "meta.enum.declaration.tsx"
+ match: "(?:\\b(const)\\s+)?\\b(enum)\\s+([a-zA-Z_$][\\w$]*)"
+ captures:
+ "1":
+ name: "storage.modifier.tsx"
+ "2":
+ name: "storage.type.tsx"
+ "3":
+ name: "entity.name.class.tsx"
+ "object-declaration":
+ name: "meta.declaration.object.tsx"
+ begin: "\\b(?:(export)\\s+)?\\b(?:(abstract)\\s+)?\\b(?])|(?<=[\\}>\\]\\)]|[a-zA-Z_$])\\s*(?=\\{)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ type:
+ name: "meta.type.tsx"
+ patterns: [
+ {
+ include: "#type-primitive"
+ }
+ {
+ include: "#type-parameters"
+ }
+ {
+ include: "#type-tuple"
+ }
+ {
+ include: "#type-object"
+ }
+ {
+ include: "#type-operator"
+ }
+ {
+ include: "#type-paren-or-function-type-parameters"
+ }
+ {
+ include: "#type-function-return-type"
+ }
+ {
+ include: "#type-name"
+ }
+ ]
+ "function-type-parameters":
+ name: "meta.function.type.parameter.tsx"
+ begin: "\\("
+ beginCaptures:
+ "0":
+ name: "meta.brace.round.tsx"
+ end: "\\)"
+ endCaptures:
+ "0":
+ name: "meta.brace.round.tsx"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#parameter-name"
+ }
+ {
+ include: "#type-annotation"
+ }
+ {
+ include: "#variable-initializer"
+ }
+ ]
+ "type-primitive":
+ name: "meta.type.primitive.tsx"
+ match: "\\b(string|number|boolean|symbol|any|void)\\b"
+ captures:
+ "1":
+ name: "storage.type.tsx"
+ "type-paren-or-function-type-parameters":
+ name: "meta.type.paren.cover.tsx"
+ begin: "(?:\\b(new)\\b)?\\s*\\("
+ beginCaptures:
+ "1":
+ name: "keyword.control.tsx"
+ end: "\\)"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ {
+ include: "#function-type-parameters"
+ }
+ ]
+ "type-operator":
+ name: "keyword.operator.type.tsx"
+ match: "[.|]"
+ "type-function-return-type":
+ name: "meta.type.function.return.tsx"
+ begin: "=>"
+ beginCaptures:
+ "0":
+ name: "keyword.operator.tsx"
+ end: "(?=\\s*[,\\)\\{=;>]|//|$)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "type-tuple":
+ name: "meta.type.tuple.tsx"
+ begin: "\\["
+ beginCaptures:
+ "0":
+ name: "meta.brace.square.tsx"
+ end: "\\]"
+ endCaptures:
+ "0":
+ name: "meta.brace.square.tsx"
+ patterns: [
+ {
+ include: "#type"
+ }
+ {
+ include: "#comment"
+ }
+ ]
+ "type-name":
+ name: "meta.type.name.tsx"
+ match: "[a-zA-Z_$][.\\w$]*"
+ captures:
+ "1":
+ name: "entity.name.type.tsx"
+ "type-parameters":
+ name: "meta.type.parameters.tsx"
+ begin: "([a-zA-Z_$][\\w$]*)?(<)"
+ beginCaptures:
+ "1":
+ name: "entity.name.type.tsx"
+ "2":
+ name: "meta.brace.angle.tsx"
+ end: "(?=$)|(>)"
+ endCaptures:
+ "2":
+ name: "meta.brace.angle.tsx"
+ patterns: [
+ {
+ name: "keyword.other.tsx"
+ match: "\\b(extends)\\b"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#type"
+ }
+ ]
+ "variable-initializer":
+ begin: "(=)"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.tsx"
+ end: "(?=$|[,);=])"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ expression:
+ name: "meta.expression.tsx"
+ patterns: [
+ {
+ comment: "Match ES6 \"import from\" syntax"
+ match: "(import).*(from)\\s+((['\"`]).*\\4)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "keyword.other.ts"
+ "3":
+ name: "es6import.path.string"
+ }
+ {
+ comment: "Match import = require"
+ match: "(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\s*=\\s*(require)\\s*\\((.*)\\)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "variable.type.ts"
+ "3":
+ name: "keyword.other.ts"
+ "4":
+ name: "require.path.string"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match )"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "amd.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match full triple slash reference comments"
+ match: "(\\/\\/\\/\\s*)"
+ captures:
+ "1":
+ name: "keyword.other.ts"
+ "2":
+ name: "reference.path.string"
+ "3":
+ name: "keyword.other.ts"
+ }
+ {
+ comment: "Match debugger statement"
+ match: "\\b(debugger)\\b"
+ captures:
+ "1":
+ name: "keyword.debugger.ts"
+ }
+ {
+ include: "#jsx"
+ }
+ {
+ include: "#for-in-simple"
+ }
+ {
+ include: "#string"
+ }
+ {
+ include: "#regex"
+ }
+ {
+ include: "#template"
+ }
+ {
+ include: "#comment"
+ }
+ {
+ include: "#literal"
+ }
+ {
+ include: "#paren-expression"
+ }
+ {
+ include: "#var-expr"
+ }
+ {
+ include: "#declaration"
+ }
+ {
+ include: "#new-expr"
+ }
+ {
+ include: "#block"
+ }
+ {
+ include: "#expression-operator"
+ }
+ {
+ include: "#relational-operator"
+ }
+ {
+ include: "#arithmetic-operator"
+ }
+ {
+ include: "#logic-operator"
+ }
+ {
+ include: "#assignment-operator"
+ }
+ {
+ include: "#storage-keyword"
+ }
+ {
+ include: "#function-call"
+ }
+ {
+ include: "#switch-case"
+ }
+ {
+ include: "#control-statement"
+ }
+ ]
+ "for-in-simple":
+ name: "forin.expr.tsx"
+ match: "(?<=\\()\\s*\\b(var|let|const)\\s+([a-zA-Z_$][\\w$]*)\\s+(in|of)\\b"
+ captures:
+ "1":
+ name: "storage.type.tsx"
+ "3":
+ name: "keyword.operator.tsx"
+ "function-call":
+ name: "functioncall.expr.tsx"
+ patterns: [
+ {
+ include: "#type-parameters"
+ }
+ {
+ include: "#paren-expression"
+ }
+ ]
+ "new-expr":
+ name: "new.expr.tsx"
+ begin: "\\b(new)\\b"
+ beginCaptures:
+ "1":
+ name: "keyword.operator.tsx"
+ end: "(?=[(;]|$)"
+ patterns: [
+ {
+ include: "#type"
+ }
+ ]
+ "object-member":
+ name: "meta.object.member.tsx"
+ begin: "[a-zA-Z_$][\\w$]*\\s*:"
+ end: "(?=,|\\})"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ "expression-operator":
+ name: "keyword.operator.tsx"
+ match: "=>|\\b(delete|export|import|in|instanceof|module|namespace|new|typeof|void|as)\\b"
+ "arithmetic-operator":
+ name: "keyword.operator.arithmetic.tsx"
+ match: "\\*|/|\\-\\-|\\-|\\+\\+|\\+|%"
+ "relational-operator":
+ name: "keyword.operator.comparison.tsx"
+ match: "===|==|=|!=|!==|<=|>=|<>|<|>"
+ "assignment-operator":
+ name: "keyword.operator.assignment.tsx"
+ match: "<<=|>>=|>>>=|\\*=|(?|/\\*|//)
+ '''
+ captures:
+ "1":
+ name: "entity.other.attribute-name.tsx"
+ "jsx-tag-attribute-assignment":
+ name: "keyword.operator.assignment.tsx"
+ match: "=(?=\\s*(?:'|\"|{|/\\*|//|\\n))"
+ "jsx-string-double-quoted":
+ name: "string.quoted.double.tsx"
+ begin: "\""
+ end: "\""
+ beginCaptures:
+ "0":
+ name: "punctuation.definition.string.begin.tsx"
+ endCaptures:
+ "0":
+ name: "punctuation.definition.string.end.tsx"
+ patterns: [
+ {
+ include: "#jsx-entities"
+ }
+ ]
+ "jsx-string-single-quoted":
+ name: "string.quoted.single.tsx"
+ begin: "'"
+ end: "'"
+ beginCaptures:
+ "0":
+ name: "punctuation.definition.string.begin.tsx"
+ endCaptures:
+ "0":
+ name: "punctuation.definition.string.end.tsx"
+ patterns: [
+ {
+ include: "#jsx-entities"
+ }
+ ]
+ "jsx-entities":
+ patterns: [
+ {
+ name: "constant.character.entity.tsx"
+ match: "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)"
+ captures:
+ "1":
+ name: "punctuation.definition.entity.tsx"
+ "3":
+ name: "punctuation.definition.entity.tsx"
+ }
+ {
+ name: "invalid.illegal.bad-ampersand.tsx"
+ match: "&"
+ }
+ ]
+ "jsx-evaluated-code":
+ name: "meta.brace.curly.tsx"
+ begin: "{"
+ end: "}"
+ beginCaptures:
+ "0":
+ name: "punctuation.definition.brace.curly.start.tsx"
+ endCaptures:
+ "0":
+ name: "punctuation.definition.brace.curly.end.tsx"
+ patterns: [
+ {
+ include: "#expression"
+ }
+ ]
+ "jsx-tag-attributes-illegal":
+ name: "invalid.illegal.attribute.tsx"
+ match: "\\S+"
+ "jsx-tag-without-attributes":
+ name: "tag.without-attributes.tsx"
+ begin: "(<)([_$a-zA-Z][-$\\w.]*(?)"
+ end: "()([_$a-zA-Z][-$\\w.]*(?)"
+ beginCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ "3":
+ name: "punctuation.definition.tag.end.tsx"
+ endCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ "3":
+ name: "punctuation.definition.tag.end.tsx"
+ patterns: [
+ {
+ include: "#jsx-children"
+ }
+ ]
+ "jsx-tag-open":
+ name: "tag.open.tsx"
+ begin: '''
+ (?x)
+ (<)
+ ([_$a-zA-Z][-$\\w.]*(?)
+ '''
+ end: "(/?>)"
+ beginCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ endCaptures:
+ "1":
+ name: "punctuation.definition.tag.end.tsx"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ {
+ include: "#jsx-tag-attributes"
+ }
+ {
+ include: "#jsx-tag-attributes-illegal"
+ }
+ ]
+ "jsx-tag-close":
+ name: "tag.close.tsx"
+ begin: "()([_$a-zA-Z][-$\\w.]*(?)"
+ beginCaptures:
+ "1":
+ name: "punctuation.definition.tag.begin.tsx"
+ "2":
+ name: "entity.name.tag.tsx"
+ endCaptures:
+ "1":
+ name: "punctuation.definition.tag.end.tsx"
+ patterns: [
+ {
+ include: "#comment"
+ }
+ ]
+ "jsx-tag-invalid":
+ name: "invalid.illegal.tag.incomplete.tsx"
+ match: "<\\s*>"
+ "jsx-children":
+ patterns: [
+ {
+ include: "#jsx-tag-without-attributes"
+ }
+ {
+ include: "#jsx-tag-open"
+ }
+ {
+ include: "#jsx-tag-close"
+ }
+ {
+ include: "#jsx-tag-invalid"
+ }
+ {
+ include: "#jsx-evaluated-code"
+ }
+ {
+ include: "#jsx-entities"
+ }
+ ]
+ jsx:
+ name: "meta.jsx.tsx"
+ patterns: [
+ {
+ include: "#jsx-tag-without-attributes"
+ }
+ {
+ include: "#jsx-tag-open"
+ }
+ {
+ include: "#jsx-tag-close"
+ }
+ {
+ include: "#jsx-tag-invalid"
+ }
+ {
+ name: "meta.jsx.children.tsx"
+ begin: "(?<=(?:'|\"|})>)"
+ end: "(?=)"
+ patterns: [
+ {
+ include: "#jsx-children"
+ }
+ ]
+ }
+ ]
\ No newline at end of file
diff --git a/grammars/typescript.cson b/grammars/typescript.cson
deleted file mode 100644
index 9695e5078..000000000
--- a/grammars/typescript.cson
+++ /dev/null
@@ -1,1389 +0,0 @@
-'scopeName': 'source.ts'
-'comment': 'TypeScript Syntax: version 1.0'
-'fileTypes': [
- 'ts'
- 'str'
- 'tst'
-]
-'name': 'TypeScript'
-
-'patterns': [
- ####
- # Rules that no one should change
- # These are used by code to provide fancy completions
- ####
- {
- 'comment': 'Match debugger statement'
- 'match': '\\s*(debugger)[\\s;]+'
- 'captures':
- '1':
- 'name':'keyword.debugger.ts'
- }
- {
- 'comment': 'Match full triple slash reference comments'
- 'match': '(\\/\\/\\/\\s*)'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'reference.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match )'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'amd.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match )'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'amd.path.string'
- '3':
- 'name':'keyword.other.ts'
- }
- {
- 'comment': 'Match import = require'
- 'match': '(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)?\\s*=\\s*(require)\\s*\\((.*)\\)'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'variable.type.ts'
- '3':
- 'name':'keyword.other.ts'
- '4':
- 'name':'require.path.string'
- }
- {
- 'comment': 'Match ES6 "import from" syntax'
- 'match': '(import).*(from)\\s*(.*[\'"])'
- 'captures':
- '1':
- 'name':'keyword.other.ts'
- '2':
- 'name':'keyword.other.ts'
- '3':
- 'name':'es6import.path.string'
- }
-
- ####
- # Other rules
- ####
-
- {
- 'comment': 'Match stuff like: namespace name {...}'
- 'match': '(?:^|(;)|\\s)(module|namespace)\\s+([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*'
- 'captures':
- '1':
- 'name': 'meta.delimiter.semicolon.js'
- '2':
- 'name': 'keyword.other.ts'
- '3':
- 'patterns': [
- {
- 'match': '[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*'
- 'name': 'entity.name.type.namespace.ts'
- }
- ]
- }
- {
- 'comment': 'Match types in variable definitions.'
- 'begin': '(var|const|let)\\s+'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- 'end': '(;)|\\b(in|of)\\b|(?)?)?(?:\\s+(extends|implements)\\s)?'
- 'beginCaptures':
- '1':
- 'patterns': [
- {
- 'match': '[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*'
- 'name': 'meta.class.ts'
- }
- {
- 'match': ','
- 'name': 'meta.delimiter.object.comma.js'
- }
- ]
- '2':
- 'name': 'storage.modifier.ts'
- 'end': '(?(?=\\()'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'match': '((?:(?:private|public|protected|static)\\s+){0,2})(?:(get|set)\\s+)?([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(?=\\()'
- 'captures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'storage.modifier.ts'
- '3':
- 'name': 'entity.name.function.js'
- }
- {
- 'include': '#functionargumentstype'
- }
- {
- 'comment': 'Match function return type'
- 'begin': '(?<=\\))\\s*:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '((?:(?:private|public|protected|static)\\s+){0,2})([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(\\??)\\s*:\\s*'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'entity.name.variable.ts'
- '3':
- 'name': 'keyword.operator.js'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'match': '((?:(?:private|public|protected|static)\\s+){0,2})([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(\\??)'
- 'captures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'entity.name.variable.ts'
- '3':
- 'name': 'keyword.operator.js'
- }
- {
- 'begin': '\\s*(=)\\s*'
- 'beginCaptures':
- '1':
- 'name': 'keyword.operator.js'
- 'end': '(;)|$'
- 'endCaptures':
- '1':
- 'name': 'meta.delimiter.semicolon.js'
- 'patterns': [
- 'include': '$base'
- ]
- }
- {
- 'include': '#curlybracerecursion'
- }
- {
- 'include': '$base'
- }
- {
- 'match': ';'
- 'name': 'meta.delimiter.semicolon.js'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\.(prototype)\\.([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*(=)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '1':
- 'name': 'support.class.js'
- '2':
- 'name': 'support.constant.js'
- '3':
- 'name': 'entity.name.function.js'
- '4':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: Sound.prototype.play = function() { … }'
- 'end': '(?!\\G)'
- 'name': 'meta.function.prototype.js'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\.([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*(=)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '0':
- 'name': 'meta.function.js'
- '1':
- 'name': 'support.class.js'
- '2':
- 'name': 'entity.name.function.js'
- '3':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: Sound.play = function() { … }'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\s*(=)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '0':
- 'name': 'meta.function.js'
- '1':
- 'name': 'entity.name.function.js'
- '2':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: play = function() { … }'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\b([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)\\s*(:)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '1':
- 'name': 'entity.name.function.js'
- '2':
- 'name': 'keyword.operator.js'
- 'comment': 'match stuff like: foobar: function() { … }'
- 'end': '(?!\\G)'
- 'name': 'meta.function.json.js'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '(?:((\')(.*?)(\'))|((")(.*?)(")))\\s*(:)\\s*(?=(?:(?:async\\s+)?function)|(?:(?:<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>)?\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>))'
- 'beginCaptures':
- '1':
- 'name': 'string.quoted.single.js'
- '2':
- 'name': 'punctuation.definition.string.begin.js'
- '3':
- 'name': 'entity.name.function.js'
- '4':
- 'name': 'punctuation.definition.string.end.js'
- '5':
- 'name': 'string.quoted.double.js'
- '6':
- 'name': 'punctuation.definition.string.begin.js'
- '7':
- 'name': 'entity.name.function.js'
- '8':
- 'name': 'punctuation.definition.string.end.js'
- '9':
- 'name': 'keyword.operator.js'
- 'comment': 'Attempt to match "foo": function'
- 'end': '(?!\\G)'
- 'name': 'meta.function.json.js'
- 'patterns': [
- {
- 'include': '#functionnolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#decorator'
- }
- {
- 'include': '#function'
- }
- {
- 'match': '(new)\\s+([\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*(?:\\.[\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*)*)'
- 'captures':
- '1':
- 'name': 'keyword.operator.new.js'
- '2':
- 'patterns': [
- {
- 'name': 'entity.name.type.instance.js'
- 'match': '[\\p{L}\\p{Nl}$_.][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}.]*'
- }
- ]
- 'name': 'meta.class.instance.constructor'
- }
- {
- 'begin': '(?:(?<=[\\)\\]])|\\b([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*))(\\()'
- 'beginCaptures':
- '1':
- 'patterns': [
- {
- 'match': '\\b(shift|showModelessDialog|showModalDialog|showHelp|scroll|scrollX|scrollByPages|scrollByLines|scrollY|scrollTo|stop|strike|sin|sizeToContent|sidebar|signText|sort|sup|sub|substr|substring|splice|split|send|set(Milliseconds|Seconds|Minutes|Hours|Month|Year|FullYear|Date|UTC(Milliseconds|Seconds|Minutes|Hours|Month|FullYear|Date)|Time|Hotkeys|Cursor|Timeout|Interval|ZOptions|Active|Resizable|RequestHeader)|search|sqrt|slice|savePreferences|small|home|handleEvent|navigate|char|charCodeAt|charAt|cos|concat|contextual|confirm|compile|ceil|clear|clearTimeout|clearInterval|captureEvents|call|createStyleSheet|createPopup|createEventObject|to(GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)|test|tan|taint|taintEnabled|isNaN|isFinite|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift|untaint|unescape|unwatch|updateCommands|join|javaEnabled|pop|pow|push|plugins.refresh|paddings|parse|parseInt|parseFloat|print|prompt|preference|escape|enableExternalCapture|eval|elementFromPoint|exp|exec|execScript|execCommand|valueOf|UTC|queryCommandState|queryCommandIndeterm|queryCommandEnabled|queryCommandValue|find|file|fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor|forward|floor|fromCharCode|watch|link|load|log|lastIndexOf|asin|anchor|acos|attachEvent|atob|atan|atan2|apply|alert|abs|abort|round|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|releaseCapture|releaseEvents|random|go|get(Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear|Time|Date|TimezoneOffset|UTC(Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)|Attention|Selection|ResponseHeader|AllResponseHeaders)|min|moveBy|moveBelow|moveTo|moveToAbsolute|moveAbove|mergeAttributes|match|margins|max|btoa|big|bold|borderWidths|blink|back)\\b'
- 'name': 'support.function.js'
- }
- {
- 'match': '\\b(substringData|submit|splitText|setNamedItem|setAttribute|setAttributeNode|select|hasChildNodes|hasFeature|namedItem|click|close|cloneNode|createComment|createCDATASection|createCaption|createTHead|createTextNode|createTFoot|createDocumentFragment|createProcessingInstruction|createEntityReference|createElement|createAttribute|tabIndex|insertRow|insertBefore|insertCell|insertData|item|open|deleteRow|deleteCell|deleteCaption|deleteTHead|deleteTFoot|deleteData|focus|write|writeln|add|appendChild|appendData|reset|replaceChild|replaceData|move|moveNamedItem|moveChild|moveAttribute|moveAttributeNode|getNamedItem|getElementsByName|getElementsByTagName|getElementById|getAttribute|getAttributeNode|blur)\\b'
- 'name': 'support.function.dom.js'
- }
- {
- 'match': '\\bsuper\\b'
- 'name': 'keyword.other.ts'
- }
- ]
- '2':
- 'name': 'punctuation.definition.parameters.begin.js'
- 'end': '\\)'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.end.js'
- 'patterns': [
- {
- 'begin': '(?=)'
- 'end': '(,)\\s*|(?=\\))'
- 'endCaptures':
- '1':
- 'include': '#comma'
- 'patterns': [
- {
- 'include': '$base'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'comment': 'Prevent built-in types from being highlighted if accessed as property'
- 'match': '(\\.)(?:Anchor|Applet|Area|Array|Boolean|Button|Checkbox|Date|document|event|FileUpload|Form|Frame|Function|Hidden|History|Image|JavaArray|JavaClass|JavaObject|JavaPackage|java|Layer|Link|Location|Math|MimeType|Number|navigator|netscape|Object|Option|Packages|Password|Plugin|Radio|RegExp|Reset|Select|String|Style|Submit|screen|sun|Text|Textarea|window|XMLHttpRequest)'
- 'captures':
- '1':
- 'name': 'meta.delimiter.method.period.js'
- }
- {
- 'comment': 'Match export, declare and constructor'
- 'match': '\\b(?:export|declare|constructor)\\b'
- 'name': 'keyword.other.ts'
- }
- {
- 'comment': 'Match stuff like: as'
- 'match': '\\b(?:as|AS)\\b'
- 'name': 'keyword.operator.ts'
- }
- {
- 'comment': 'Match type SomeType = OtherType'
- 'begin': '(type)\\s+([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.ts'
- '2':
- 'name': 'meta.class.ts'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\s*(=)\\s*'
- 'beginCaptures':
- '1':
- 'name': 'keyword.operator.js'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'comment': 'Match types in template instantiation'
- 'begin': '(?<=[\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}])<(?=(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>\\()'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'comment': 'Match type assertions'
- 'begin': '(?])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>[\\p{L}\\p{Nl}$_\\(\\[\\d\\{])'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\?'
- 'beginCaptures':
- '0':
- 'name': 'keyword.operator.js'
- 'end': ':'
- 'endCaptures':
- '0':
- 'name': 'keyword.operator.js'
- 'patterns': [
- {
- 'include': '$base'
- }
- ]
- }
-
- {
- 'include': '#curlybracerecursion'
- }
- {
- 'comment': 'Match all [] pairs'
- 'begin': '\\['
- 'end': '\\]'
- 'captures':
- '0':
- 'name': 'meta.brace.square.js'
- 'patterns': [
- {
- 'include': '$base'
- }
- ]
- }
- {
- 'comment': 'Match all () pairs'
- 'begin': '\\('
- 'end': '\\)'
- 'captures':
- '0':
- 'name': 'meta.brace.round.js'
- 'patterns': [
- {
- 'include': '$base'
- }
- ]
- }
- {
- 'include': 'source.js'
- }
-
- # TRANSFORMS
- {
- 'comment': 'Embedded Syntaxes support'
- 'begin': '(transform):(null){'
- 'beginCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'end': '}(transform):(null)'
- 'endCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'patterns': [
- {
- 'include': 'source.ts'
- }
- ]
- }
- {
- 'comment': 'Embedded Syntax for JSX'
- 'begin': '(transform):(jsx){'
- 'beginCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'end': '}(transform):(jsx)'
- 'endCaptures':
- '1':
- 'name': 'keyword.other.ts'
- '2':
- 'name': 'meta.support.constant.ts'
- 'patterns': [
- {
- 'include': 'text.html.basic'
- }
- ]
- }
-]
-
-'repository':
- 'curlybracerecursion':
- 'comment': 'Match all {} pairs'
- 'begin': '{'
- 'end': '}'
- 'captures':
- '0':
- 'name': 'meta.brace.curly.js'
- 'patterns': [
- {
- 'include': '$base'
- }
- ]
-
- 'type':
- 'begin': '(?=[\\(\\{\\p{L}\\p{Nl}$_])'
- 'end': '(?))'
- 'end': '\\)(?:\\[\\])*'
- 'patterns': [
- {
- 'include': '#type'
- }
- ]
- }
- {
- 'include': '#keytype'
- }
- {
- 'include': '#typetemplate'
- }
- {
- 'include': '#typenontemplate'
- }
- {
- 'include': '#functiontype'
- }
- {
- 'include': '#tuple'
- }
- {
- 'include': '#objecttype'
- }
- {
- 'match': '\\s*(\\|)\\s*'
- 'captures':
- '1':
- 'name': 'keyword.operator.union.ts'
- }
- {
- 'include': '#comments'
- }
- {
- 'match': '\\.'
- 'captures':
- '0':
- 'name': 'meta.delimiter.period.type.ts'
- }
- ]
-
- 'typeinheritedfrom':
- 'begin': '(?=[\\(\\{\\p{L}\\p{Nl}$_])'
- 'end': '(?))'
- 'end': '\\)(?:\\[\\])*'
- 'patterns': [
- {
- 'include': '#typeinheritedfrom'
- }
- ]
- }
- {
- 'include': '#keytype'
- }
- {
- 'include': '#functiontype'
- }
- {
- 'include': '#objecttype'
- }
- {
- 'include': '#tuple'
- }
- {
- 'include': '#typetemplateinheritedfrom'
- }
- {
- 'include': '#typenontemplateinheritedfrom'
- }
- {
- 'match': '\\|'
- 'captures':
- '0':
- 'name': 'keyword.operator.union.ts'
- }
- {
- 'match': '\\.'
- 'captures':
- '0':
- 'name': 'meta.delimiter.period.type.ts'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typenontemplate':
- 'comment': 'Matches a simple type without template specification'
- 'match': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\b((?:\\[\\])*)(?!<)'
- 'captures':
- '1':
- 'name': 'support.class.ts'
-
- 'typetemplate':
- 'begin': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)<'
- 'beginCaptures':
- '1':
- 'name': 'support.class.template.ts'
- 'end': '>((?:\\[\\])*)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typenontemplateinheritedfrom':
- 'comment': 'Matches a simple type without template specification'
- 'match': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\b((?:\\[\\])*)(?!<)'
- 'captures':
- '1':
- 'name': 'entity.other.inherited-class.ts'
-
- 'typetemplateinheritedfrom':
- 'begin': '([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)<'
- 'beginCaptures':
- '1':
- 'name': 'entity.other.template.inherited-class.ts'
- 'end': '>((?:\\[\\])*)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'keytype':
- 'comment': 'Match key types.'
- 'match': '(number|string|boolean|any|void)(?:\\[\\])*'
- 'captures':
- '1':
- 'name': 'storage.type.variable.ts'
-
- 'functiontype':
- 'patterns': [
- {
- 'include': '#functionargumentreturntype'
- }
- {
- 'begin': '(?=<)'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#functionargumentreturntype'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- ]
-
- 'functionargumentreturntype':
- 'begin': '(?=\\()'
- 'end': '(?)\\s*'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.arrow.js'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'functionargumentstype':
- 'comment': 'Matches the types for functions.'
- 'begin': '\\('
- 'beginCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.begin.js'
- 'end': '\\)'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.end.js'
- 'patterns': [
- {
- 'include': '#args'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'objecttype':
- 'comment': 'Matches anonymous object types.'
- 'begin': '{'
- 'beginCaptures':
- '0':
- 'name': 'meta.brace.curly.js'
- 'end': '(})(\\[\\])?'
- 'endCaptures':
- '1':
- 'name': 'meta.brace.curly.js'
- 'patterns': [
- {
- 'include': '#typeindexable'
- }
- {
- 'include': '#typedvariable'
- }
- {
- 'match': ';'
- 'name': 'meta.delimiter.semicolon.js'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typeindexable':
- 'begin': '\\[[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*:\\s*(string|number)\\s*\\]:\\s*'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.variable.ts'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'tuple':
- 'begin': '\\['
- 'end': '\\]'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typedvariable':
- 'begin': '[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*\\??\\s*:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'decorator':
- 'begin': '(\\@[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)(\\()'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.annotation.js'
- '2':
- 'name': 'punctuation.definition.parameters.begin.js'
- 'end': '\\)'
- 'endCaptures':
- '0':
- 'name': 'punctuation.definition.parameters.end.js'
- 'patterns': [
- {
- 'include': '#angulartemplate'
- }
- ]
-
- 'args':
- 'comment': 'Match the arguments in a function'
- 'patterns': [
- {
- 'match': '(?:\\.\\.\\.)?[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*(?=\\??\\s*[,\\)])'
- 'name': 'variable.parameter.function.ts'
- }
- {
- 'begin': '((?:\\.\\.\\.)?[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\??\\s*:\\s*'
- 'beginCaptures':
- '1':
- 'name': 'variable.parameter.function.ts'
- 'end': '(?=\\s*[,\\)])'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'function':
- 'patterns': [
- {
- 'include': '#oldstylefunction'
- }
- {
- 'include': '#newstylefunction'
- }
- ]
-
- 'functionnolookahead':
- 'patterns': [
- {
- 'include': '#oldstylefunction'
- }
- {
- 'include': '#newstylefunctionnolookahead'
- }
- ]
-
- 'newstylefunction':
- 'patterns': [
- {
- 'include': '#newstylefunctionnontemplate'
- }
- {
- 'begin': '(?\\([^\\(].+=>)(?=<(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+>\\((?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>)'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#newstylefunctionnontemplatenolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- ]
-
- 'newstylefunctionnolookahead':
- 'patterns': [
- {
- 'begin': '(?=<)'
- 'end': '(?)(?!\\G)'
- 'patterns': [
- {
- 'begin': '\\G<'
- 'end': '>'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#newstylefunctionnontemplatenolookahead'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#newstylefunctionnontemplatenolookahead'
- }
- ]
-
- 'newstylefunctionnontemplate':
- 'begin': '(?)(?=(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))*\\)(?:\\:\\s*(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/|\\|(?:[^&|*/+\\-\\)]|\\)(?=[\\[\\)|>])|\\/\\*\\*?(?:[^*]*?\\*)*\\/))+)?\\s*=>)'
- 'end': '(?!\\:)\\s*(=>)'
- 'endCaptures':
- '1':
- 'name': 'storage.type.arrow.js'
- 'patterns': [
- {
- 'include': '#functionargumentstype'
- }
- {
- 'begin': '\\:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'newstylefunctionnontemplatenolookahead':
- 'begin': '(?=\\()'
- 'end': '(?!\\:)\\s*(=>)'
- 'endCaptures':
- '1':
- 'name': 'storage.type.arrow.js'
- 'patterns': [
- {
- 'include': '#functionargumentstype'
- }
- {
- 'begin': '\\:\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'oldstylefunction':
- 'begin': '(?=(?:(async)(?:\\s+))?(function))'
- 'end': '(?!\\G)(?!:)'
- 'name': 'meta.function.js'
- 'patterns': [
- {
- 'begin': '\\G(?:(async)(?:\\s+))?(function)(?:\\s+([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*))?(\\*?)\\s*(\\*?)(?=\\()'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'storage.type.function.js'
- '3':
- 'name': 'entity.name.function.js'
- '4':
- 'name': 'storage.type.function.js'
- '5':
- 'name': 'storage.type.function.js'
- 'end': '(?<=\\))'
- 'patterns': [
- {
- 'include': '#functionargumentstype'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '\\G(?:(async)(?:\\s+))?(function)(?:\\s+([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*))?(?=<)'
- 'beginCaptures':
- '1':
- 'name': 'storage.modifier.js'
- '2':
- 'name': 'storage.type.function.js'
- '3':
- 'name': 'entity.name.function.js'
- 'end': '(?<=\\))'
- 'patterns': [
- {
- 'begin': '(?<=\\G)<'
- 'end': '>(?:(\\*)\\s*|\\s*(\\*)|\\s*)(?=\\()'
- 'endCaptures':
- '1':
- 'name': 'storage.type.function.js'
- '2':
- 'name': 'storage.type.function.js'
- 'patterns': [
- {
- 'include': '#typeextend'
- }
- {
- 'include': '#type'
- }
- {
- 'include': '#comma'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#functionargumentstype'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'begin': '(?<=\\)):\\s*'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#type'
- }
- {
- 'include': '#comments'
- }
- ]
- }
- {
- 'include': '#comments'
- }
- ]
-
- 'typeextend':
- 'begin': '(extends)\\s+'
- 'beginCaptures':
- '1':
- 'name': 'storage.type.modifier.ts'
- 'end': '(?!\\G)'
- 'patterns': [
- {
- 'include': '#typeinheritedfrom'
- }
- ]
-
- # Taken from JS grammar (https://github.com/atom/language-javascript/blob/897e999910fb001780286778a20b7e5c02eb59dd/grammars/javascript.cson#L631-L661)
- 'docblock':
- 'patterns': [
- {
- 'match': '(?)',
+ captures: {
+ '1': {
+ name: 'keyword.other.ts'
+ },
+ '2': {
+ name: 'reference.path.string'
+ },
+ '3': {
+ name: 'keyword.other.ts'
+ }
+ }
+ },
+ {
+ comment: 'Match )',
+ captures: {
+ '1': {
+ name: 'keyword.other.ts'
+ },
+ '2': {
+ name: 'amd.path.string'
+ },
+ '3': {
+ name: 'keyword.other.ts'
+ }
+ }
+ },
+ {
+ comment: 'Match )',
+ captures: {
+ '1': {
+ name: 'keyword.other.ts'
+ },
+ '2': {
+ name: 'amd.path.string'
+ },
+ '3': {
+ name: 'keyword.other.ts'
+ }
+ }
+ },
+ {
+ comment: 'Match import = require',
+ match: '(import)\\s*([\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}$\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}\\x{200C}\\x{200D}]*)\\s*=\\s*(require)\\s*\\((.*)\\)',
+ captures: {
+ '1': {
+ name: 'keyword.other.ts'
+ },
+ '2': {
+ name: 'variable.type.ts'
+ },
+ '3': {
+ name: 'keyword.other.ts'
+ },
+ '4': {
+ name: 'require.path.string'
+ }
+ }
+ },
+ {
+ comment: 'Match ES6 "import from" syntax',
+ match: '(import).*(from)\\s+(([\'"`]).*\\4)',
+ captures: {
+ '1': {
+ name: 'keyword.other.ts'
+ },
+ '2': {
+ name: 'keyword.other.ts'
+ },
+ '3': {
+ name: 'es6import.path.string'
+ }
+ }
+ }
+]
+
+Promise.all([
+ request('https://raw.githubusercontent.com/Microsoft/TypeScript-TmLanguage/master/TypeScript.YAML-tmLanguage'),
+ request('https://raw.githubusercontent.com/Microsoft/TypeScript-TmLanguage/master/TypeScriptReact.YAML-tmLanguage')
+])
+ .then(function (result) {
+ var ts = yaml.safeLoad(result[0].body)
+ var tsx = yaml.safeLoad(result[1].body)
+
+ atomPatterns.forEach(function (pattern) {
+ ts.repository.expression.patterns.unshift(pattern)
+ tsx.repository.expression.patterns.unshift(pattern)
+ })
+
+ return Promise.all([
+ fs.writeFile(join(__dirname, '../grammars/ts.cson'), cson.stringify(ts, null, ' ')),
+ fs.writeFile(join(__dirname, '../grammars/tsx.cson'), cson.stringify(tsx, null, ' '))
+ ])
+ })
+ .catch(function (err) {
+ console.error(err.stack)
+ process.exit(1)
+ })