2016-08-12 01:38:31 +03:00
|
|
|
# [PackageDev] target_format: plist, ext: tmLanguage
|
2015-11-06 00:14:57 +03:00
|
|
|
# Similar to TypeScript.YAML-tmLanguage except:
|
2016-01-27 13:13:21 +03:00
|
|
|
# - Remove type assertion (cast.expr.tsx)
|
2015-11-06 00:14:57 +03:00
|
|
|
# - Add JSX expression (HTML-like expression).
|
|
|
|
---
|
|
|
|
name: TypeScriptReact
|
|
|
|
scopeName: source.tsx
|
|
|
|
fileTypes: [tsx]
|
|
|
|
uuid: 805375ec-d614-41f5-8993-5843fe63ea82
|
|
|
|
|
|
|
|
repository:
|
2016-09-20 22:25:38 +03:00
|
|
|
# Additions:
|
|
|
|
# statements and expression repository need to include jsx first followed by whaterver ts grammar says
|
2016-08-19 21:29:26 +03:00
|
|
|
statements:
|
|
|
|
patterns:
|
|
|
|
- include: '#jsx'
|
2016-04-27 19:36:09 +03:00
|
|
|
|
2016-08-19 21:29:26 +03:00
|
|
|
expression:
|
2016-04-27 19:36:09 +03:00
|
|
|
patterns:
|
2016-08-18 02:08:00 +03:00
|
|
|
- include: '#jsx'
|
2016-03-17 20:49:23 +03:00
|
|
|
|
2016-09-20 22:25:38 +03:00
|
|
|
# Overrides:
|
2016-08-19 21:29:26 +03:00
|
|
|
|
2016-09-20 22:25:38 +03:00
|
|
|
# We need to override this to make sure cast is not matched from typescript
|
|
|
|
# We can safely include jsx because thats the first rule matched anyways so it wont impact at all
|
|
|
|
cast:
|
2015-11-06 00:14:57 +03:00
|
|
|
patterns:
|
2016-09-20 22:25:38 +03:00
|
|
|
- include: '#jsx'
|
2015-11-06 00:14:57 +03:00
|
|
|
|
|
|
|
# jsx syntax is taken from https://github.com/babel/babel-sublime
|
|
|
|
jsx-tag-attributes:
|
|
|
|
patterns:
|
|
|
|
- include: '#jsx-tag-attribute-name'
|
|
|
|
- include: '#jsx-tag-attribute-assignment'
|
|
|
|
- include: '#jsx-string-double-quoted'
|
|
|
|
- include: '#jsx-string-single-quoted'
|
|
|
|
- include: '#jsx-evaluated-code'
|
|
|
|
|
|
|
|
jsx-tag-attribute-name:
|
|
|
|
name: meta.tag.attribute-name.tsx
|
|
|
|
match: >-
|
|
|
|
(?x)
|
|
|
|
\s*
|
|
|
|
([_$a-zA-Z][-$\w]*)
|
|
|
|
(?=\s|=|/?>|/\*|//)
|
|
|
|
captures:
|
|
|
|
'1': {name: entity.other.attribute-name.tsx}
|
|
|
|
|
|
|
|
jsx-tag-attribute-assignment:
|
|
|
|
name: keyword.operator.assignment.tsx
|
|
|
|
match: =(?=\s*(?:'|"|{|/\*|//|\n))
|
|
|
|
|
|
|
|
jsx-string-double-quoted:
|
2016-08-17 01:29:08 +03:00
|
|
|
name: string.jsxAttributeValue.quoted.double.tsx
|
2015-11-06 00:14:57 +03:00
|
|
|
begin: '"'
|
|
|
|
end: '"'
|
|
|
|
beginCaptures:
|
2016-08-17 01:29:08 +03:00
|
|
|
'0': {name: punctuation.definition.string.jsxAttributeValue.begin.tsx}
|
2015-11-06 00:14:57 +03:00
|
|
|
endCaptures:
|
2016-08-17 01:29:08 +03:00
|
|
|
'0': {name: punctuation.definition.string.jsxAttributeValue.end.tsx}
|
2015-11-06 00:14:57 +03:00
|
|
|
patterns:
|
2016-08-17 01:29:08 +03:00
|
|
|
- include: '#jsx-attributeValue-entities'
|
2015-11-06 00:14:57 +03:00
|
|
|
|
|
|
|
jsx-string-single-quoted:
|
2016-08-17 01:29:08 +03:00
|
|
|
name: string.jsxAttributeValue.quoted.single.tsx
|
2015-11-06 00:14:57 +03:00
|
|
|
begin: "'"
|
|
|
|
end: "'"
|
|
|
|
beginCaptures:
|
2016-08-17 01:29:08 +03:00
|
|
|
'0': {name: punctuation.definition.string.jsxAttributeValue.begin.tsx}
|
2015-11-06 00:14:57 +03:00
|
|
|
endCaptures:
|
2016-08-17 01:29:08 +03:00
|
|
|
'0': {name: punctuation.definition.string.jsxAttributeValue.end.tsx}
|
2015-11-06 00:14:57 +03:00
|
|
|
patterns:
|
2016-08-17 01:29:08 +03:00
|
|
|
- include: '#jsx-attributeValue-entities'
|
2015-11-06 00:14:57 +03:00
|
|
|
|
|
|
|
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: '&'
|
|
|
|
|
2016-08-17 01:29:08 +03:00
|
|
|
jsx-attributeValue-entities:
|
|
|
|
patterns:
|
|
|
|
- name: constant.character.entity.jsxAttributeValue.tsx
|
|
|
|
match: (&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)
|
|
|
|
captures:
|
|
|
|
'1': {name: punctuation.definition.entity.jsxAttributeValue.tsx}
|
|
|
|
'3': {name: punctuation.definition.entity.jsxAttributeValue.tsx}
|
|
|
|
- name: invalid.illegal.bad-ampersand.jsxAttributeValue.tsx
|
|
|
|
match: '&'
|
|
|
|
|
2015-11-06 00:14:57 +03:00
|
|
|
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:
|
2016-08-16 23:07:17 +03:00
|
|
|
name: meta.tag.without-attributes.tsx
|
2015-11-06 00:14:57 +03:00
|
|
|
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}
|
2016-08-31 22:23:59 +03:00
|
|
|
contentName: meta.jsx.children.tsx
|
2015-11-06 00:14:57 +03:00
|
|
|
patterns:
|
|
|
|
- include: '#jsx-children'
|
|
|
|
|
2016-08-31 22:11:14 +03:00
|
|
|
jsx-tag:
|
2016-08-31 22:20:03 +03:00
|
|
|
name: meta.tag.tsx
|
2015-11-06 00:14:57 +03:00
|
|
|
begin: >-
|
|
|
|
(?x)
|
|
|
|
(<)
|
|
|
|
([_$a-zA-Z][-$\w.]*(?<!\.|-))
|
|
|
|
(?=\s+(?!\?)|/?>)
|
|
|
|
beginCaptures:
|
2016-08-31 22:11:14 +03:00
|
|
|
'1': { name: punctuation.definition.tag.begin.tsx }
|
|
|
|
'2': { name: entity.name.tag.tsx }
|
|
|
|
end: (/>)|(?:(</)([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>))
|
2015-11-06 00:14:57 +03:00
|
|
|
endCaptures:
|
2016-08-31 22:11:14 +03:00
|
|
|
'1': { name: punctuation.definition.tag.end.tsx }
|
|
|
|
'2': { name: punctuation.definition.tag.begin.tsx }
|
|
|
|
'3': { name: entity.name.tag.tsx }
|
|
|
|
'4': { name: punctuation.definition.tag.end.tsx }
|
|
|
|
patterns:
|
2016-09-13 21:22:33 +03:00
|
|
|
- begin: \G(?![/]?>)
|
2016-08-31 22:11:14 +03:00
|
|
|
end: (?=[/]?>)
|
|
|
|
patterns:
|
|
|
|
- include: '#comment'
|
|
|
|
- include: '#jsx-tag-attributes'
|
|
|
|
- include: '#jsx-tag-attributes-illegal'
|
|
|
|
- begin: (>)
|
|
|
|
beginCaptures:
|
|
|
|
'1': { name: punctuation.definition.tag.end.tsx }
|
|
|
|
end: (?=</)
|
|
|
|
contentName: meta.jsx.children.tsx
|
|
|
|
patterns:
|
|
|
|
- include: '#jsx-children'
|
2015-11-06 00:14:57 +03:00
|
|
|
|
|
|
|
jsx-tag-invalid:
|
|
|
|
name: invalid.illegal.tag.incomplete.tsx
|
|
|
|
match: <\s*>
|
|
|
|
|
|
|
|
jsx-children:
|
|
|
|
patterns:
|
|
|
|
- include: '#jsx-tag-without-attributes'
|
2016-08-31 22:11:14 +03:00
|
|
|
- include: '#jsx-tag'
|
2015-11-06 00:14:57 +03:00
|
|
|
- include: '#jsx-tag-invalid'
|
|
|
|
- include: '#jsx-evaluated-code'
|
|
|
|
- include: '#jsx-entities'
|
|
|
|
|
|
|
|
jsx:
|
|
|
|
name: meta.jsx.tsx
|
|
|
|
patterns:
|
|
|
|
- include: '#jsx-tag-without-attributes'
|
2016-08-31 22:11:14 +03:00
|
|
|
- include: '#jsx-tag'
|
2015-11-06 00:14:57 +03:00
|
|
|
- include: '#jsx-tag-invalid'
|
|
|
|
|
2016-02-02 04:10:11 +03:00
|
|
|
...
|