Skip to content

Commit 0466e90

Browse files
author
deathaxe
committed
Merge branch 'fix/jsx-support'
2 parents 7ec7638 + 4a86801 commit 0466e90

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

Vue Component.sublime-syntax

+4-14
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ contexts:
7474
- script-coffeescript
7575
- tag-lang-attribute-meta
7676
- tag-generic-attribute-value
77-
- match: (?i)(?=jsx{{unquoted_attribute_break}}|'jsx'|"jsx")
78-
set:
79-
- script-jsx
80-
- tag-lang-attribute-meta
81-
- tag-generic-attribute-value
8277
- match: (?i)(?=livescript{{unquoted_attribute_break}}|'livescript'|"livescript")
8378
set:
8479
- script-livescript
@@ -146,15 +141,10 @@ contexts:
146141
3: source.coffee.embedded.html
147142
4: comment.block.html punctuation.definition.comment.end.html
148143

149-
script-jsx:
150-
- meta_include_prototype: false
151-
- meta_scope: meta.tag.script.begin.html
152-
- match: '>'
153-
scope: punctuation.definition.tag.end.html
154-
set: script-jsx-content
155-
- include: script-common
156-
157-
script-jsx-content:
144+
script-javascript-content:
145+
# Note: Augment default JavaScript by JSX
146+
# as Vue supports writing components via JSX tags by default
147+
# and JSX highlights/scopes plain JavaScript without issues.
158148
- meta_include_prototype: false
159149
- match: '{{script_content_begin}}'
160150
captures:

tests/syntax_test_script.vue

+37-13
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,62 @@
55
66
<script> var i = 0; </script>
77
// ^^^^^^^^ meta.tag - source
8-
// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag
8+
// ^^^^^^^^^^^^ source.jsx.embedded.html - meta.tag
99
// ^^^^^^^^^ meta.tag - source
1010

1111
<script> var i = 0; --> </script>
1212
// ^^^^^^^^ meta.tag - source
13-
// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag
13+
// ^^^^^^^^^^^^ source.jsx.embedded.html - meta.tag
1414
// ^^^^ - meta.tag - source
1515
// ^^^ comment.block.html punctuation.definition.comment.end.html
1616
// ^^^^^^^^^ meta.tag - source
1717

1818
<script> <!-- var i = 0; </script>
1919
// ^^^^^^^^ meta.tag - source
2020
// ^^^^^ - meta.tag - source
21-
// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag
21+
// ^^^^^^^^^^^^ source.jsx.embedded.html - meta.tag
2222
// ^^^^^^^^^ meta.tag - source
2323
// ^^^^ punctuation.definition.comment.begin.html
2424

2525
<script> <!-- var i = 0; --> </script>
2626
// ^^^^^^^^ meta.tag - source
2727
// ^^^^^ - meta.tag - source
2828
// ^^^^ punctuation.definition.comment.begin.html
29-
// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag
29+
// ^^^^^^^^^^^^ source.jsx.embedded.html - meta.tag
3030
// ^^^^ - meta.tag - source
3131
// ^^^ comment.block.html punctuation.definition.comment.end.html
3232
// ^^^^^^^^^ meta.tag - source
3333

3434

3535
<script>
3636
37-
// <- source.js.embedded.html
37+
// <- source.jsx.embedded.html
3838
var i = 0;
39-
// ^^^^^^^^^^^^ source.js.embedded.html - source source
39+
// ^^^^^^^^^^^^ source.jsx.embedded.html - source source
40+
export default {
41+
render () {
42+
return <div>{ this.foo }</div>
43+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.jsx.embedded.html
44+
// ^^^^^^ keyword.control.flow.return.js
45+
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.jsx.js
46+
// ^^^^^ meta.tag
47+
// ^ punctuation.definition.tag.begin.js
48+
// ^^^ entity.name.tag
49+
// ^ punctuation.definition.tag.end.js
50+
// ^^^^^^^^^^^^ meta.interpolation.js
51+
// ^ punctuation.definition.interpolation.begin.js
52+
// ^^^^^^^^^^ source.js.embedded.jsx
53+
// ^ punctuation.definition.interpolation.end.js
54+
// ^^^^^^ meta.tag
55+
// ^^ punctuation.definition.tag.begin.js
56+
// ^^^ entity.name.tag
57+
// ^ punctuation.definition.tag.end.js
58+
}
59+
//^^^^^^ source.jsx.embedded.html
60+
// ^ punctuation.section
61+
}
62+
//^^^^ source.jsx.embedded.html
63+
// ^ punctuation.section
4064
</script>
4165
// ^^^^^^^^^ meta.tag - source
4266

@@ -46,7 +70,7 @@
4670
//^^^^^^ - meta.tag - source
4771
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
4872
var i = 0;
49-
// ^^^^^^^^^^^^ source.js.embedded.html - source source - meta.tag
73+
// ^^^^^^^^^^^^ source.jsx.embedded.html - source source - meta.tag
5074
-->
5175
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
5276
// ^ - comment - source
@@ -66,10 +90,10 @@
6690
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
6791
6892
var foo = 100;
69-
// <- source.js.embedded.html - source source
93+
// <- source.jsx.embedded.html - source source
7094
7195
(a --> b);
72-
// ^^^ source.js.embedded.html keyword.operator - comment
96+
// ^^^ source.jsx.embedded.html keyword.operator - comment
7397
7498
--> </script>
7599
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
@@ -92,10 +116,10 @@
92116
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
93117
94118
var foo = 100;
95-
// <- source.js.embedded.html - source source
119+
// <- source.jsx.embedded.html - source source
96120
97121
(a --> b);
98-
// ^^^ source.js.embedded.html keyword.operator - comment
122+
// ^^^ source.jsx.embedded.html keyword.operator - comment
99123
100124
--> </script>
101125
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
@@ -113,8 +137,8 @@
113137
application/jAvAsCrIpT>
114138
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value - meta.attribute-with-value meta.attribute-with-value
115139
var foo = 100;
116-
// <- source.js.embedded.html - source source
117-
// ^^^^^^^^^^^^^^^^ source.js.embedded.html - source source
140+
// <- source.jsx.embedded.html - source source
141+
// ^^^^^^^^^^^^^^^^ source.jsx.embedded.html - source source
118142
</script>
119143
// ^^^^^^^^^ meta.tag - source
120144

0 commit comments

Comments
 (0)