Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 12 additions & 32 deletions Vue Component.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ file_extensions:
- wpy

variables:
# CSS specific variables
# ======================

# Embedded script and style syntaxes may be wrapped into html comments for
# historical reasons. The following patterns match them, while maintaining
# correct boundaries of embedded source scopes. That's required to enable
Expand Down Expand Up @@ -44,14 +47,12 @@ variables:
# or standalone html comment end punctuation in a line
| ^ (\s*) (-->) \s* $
)
template_content_begin: '{{script_content_begin}}'
template_content_end: |-
(?x:
# optional html comment end punctuation followed by </template> tag
(?: (\s*) (-->) \s* )? (?=</(?i:template){{tag_name_break_char}})
# or standalone html comment end punctuation in a line
| ^ (\s*) (-->) \s* $
)

# Vue specific variables
# ======================

template_content_begin: ^|(?=[{{ascii_space}}]*\S)
template_content_end: (?=(?:^\s*)?</(?i:template){{tag_name_break}})

contexts:

Expand Down Expand Up @@ -608,17 +609,10 @@ contexts:

template-jade-content:
- match: '{{template_content_begin}}'
captures:
1: comment.block.html punctuation.definition.comment.begin.html
pop: 1
embed: scope:text.jade
embed_scope: text.jade.embedded.html
escape: '{{template_content_end}}'
escape_captures:
1: text.jade.embedded.html
2: comment.block.html punctuation.definition.comment.end.html
3: text.jade.embedded.html
4: comment.block.html punctuation.definition.comment.end.html
pop: 1

template-mustache:
- meta_scope: meta.tag.template.begin.html
Expand All @@ -634,17 +628,10 @@ contexts:

template-pug-content:
- match: '{{template_content_begin}}'
captures:
1: comment.block.html punctuation.definition.comment.begin.html
pop: 1
embed: scope:text.pug
embed_scope: text.pug.embedded.html
escape: '{{template_content_end}}'
escape_captures:
1: text.pug.embedded.html
2: comment.block.html punctuation.definition.comment.end.html
3: text.pug.embedded.html
4: comment.block.html punctuation.definition.comment.end.html
pop: 1

template-slim:
- meta_scope: meta.tag.template.begin.html
Expand All @@ -655,17 +642,10 @@ contexts:

template-slim-content:
- match: '{{template_content_begin}}'
captures:
1: comment.block.html punctuation.definition.comment.begin.html
pop: 1
embed: scope:text.slim
embed_scope: text.slim.embedded.html
escape: '{{template_content_end}}'
escape_captures:
1: text.slim.embedded.html
2: comment.block.html punctuation.definition.comment.end.html
3: text.slim.embedded.html
4: comment.block.html punctuation.definition.comment.end.html
pop: 1

###[ TAG ATTRIBUTES ]#########################################################

Expand Down
114 changes: 57 additions & 57 deletions tests/syntax_test_script.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,18 @@
var i = 0;
// ^^^^^^^^^^^^ source.js.embedded.html - source source
</script>
// <- source.js.embedded.html - source source
// ^ source.js.embedded.html - source source
// ^^^^^^^^^ meta.tag - source


<script>
<!--
//^^^^^^ - meta.tag - source
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.js.embedded.html - source source - meta.tag - comment
var i = 0;
// ^^^^^^^^^^^^ source.js.embedded.html - source source - meta.tag
-->
//^^ source.js.embedded.html - meta.tag - comment
// ^^^^ - source - meta.tag
// ^^^ comment.block.html punctuation.definition.comment.end.html
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - comment - source
var i = 0;
// ^^^^^^^^^^^^ - source
</script>
Expand All @@ -68,7 +64,6 @@
// ^ punctuation.definition.tag.end.html
// ^ - meta.tag - comment
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.js.embedded.html - source source

var foo = 100;
// <- source.js.embedded.html - source source
Expand All @@ -77,12 +72,9 @@
// ^^^ source.js.embedded.html keyword.operator - comment

--> </script>
// ^ source.js.embedded.html - source source
// ^^^^^^^^^^^^^^ - source
// ^ - meta.tag - comment
// ^^^^^^^^^ meta.tag
// ^ - meta.tag
// ^^^ comment.block.html punctuation.definition.comment.end.html
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - comment - meta.tag - source
// ^^^^^^^^^ meta.tag - comment - source
// ^^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag
// ^ punctuation.definition.tag.end.html
Expand All @@ -98,7 +90,6 @@
// ^ punctuation.separator.key-value.html
// ^^^^^^^^^^^^^^^^^ string.quoted.double.html
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.js.embedded.html

var foo = 100;
// <- source.js.embedded.html - source source
Expand All @@ -107,12 +98,9 @@
// ^^^ source.js.embedded.html keyword.operator - comment

--> </script>
// ^ source.js.embedded.html - source source
// ^^^^^^^^^^^^^^ - source
// ^ - meta.tag - comment
// ^^^^^^^^^ meta.tag
// ^ - meta.tag
// ^^^ comment.block.html punctuation.definition.comment.end.html
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - comment - meta.tag - source
// ^^^^^^^^^ meta.tag - comment - source
// ^^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag
// ^ punctuation.definition.tag.end.html
Expand All @@ -128,10 +116,13 @@
// <- source.js.embedded.html - source source
// ^^^^^^^^^^^^^^^^ source.js.embedded.html - source source
</script>
// <- source.js.embedded.html - source source
// ^ source.js.embedded.html - source source
// ^^^^^^^^^ meta.tag - source


<!--
-- CoffeeScript
-->

<script language="coffeescript"> </script>
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag - meta.tag meta.tag - source
// ^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.lang.html - meta.attribute-with-value meta.attribute-with-value
Expand All @@ -148,109 +139,118 @@

// <- source.coffee.embedded.html - source source
</script>
// <- source.coffee.embedded.html - source source
//^^ source.coffee.embedded.html - source source
// ^^^^^^^^^ meta.tag - source

<script lang="coffee">
<!--
// ^^^^^^^^^ - source
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.coffee.embedded.html - source source
-->
// ^^^^^ source.coffee.embedded.html - source source
// <- - comment
//^^^^^^ - comment
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - source - comment - meta.tag
// ^ - comment - source
var i = 0;
// ^^^^^^^^^^^^ - source
</script>
// <- - source - comment - meta.tag
//^^ - source - comment - meta.tag
// ^^^^^^^^^ meta.tag - source


<!--
-- JSX
-->

<script lang="jsx">

// <- source.jsx.embedded.html - source source
</script>
// <- source.jsx.embedded.html - source source
//^^ source.jsx.embedded.html - source source
// ^^^^^^^^^ meta.tag - source

<script lang="jsx">
<!--
// ^^^^^^^^^ - source
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.jsx.embedded.html - source source
-->
// ^^^^^ source.jsx.embedded.html - source source
// <- - comment
//^^^^^^ - comment
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - source - comment - meta.tag
// ^ - comment - source
var i = 0;
// ^^^^^^^^^^^^ - source
</script>
// <- - source - comment - meta.tag
//^^ - source - comment - meta.tag
// ^^^^^^^^^ meta.tag - source


<!--
-- LiveScript
-->

<script lang="livescript">

// <- source.livescript.embedded.html - source source
</script>
// <- source.livescript.embedded.html - source source
//^^ source.livescript.embedded.html - source source
// ^^^^^^^^^ meta.tag - source

<script lang="livescript">
<!--
// ^^^^^^^^^ - source
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.livescript.embedded.html - source source
-->
// ^^^^^ source.livescript.embedded.html - source source
// <- - comment
//^^^^^^ - comment
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - source - comment - meta.tag
// ^ - comment - source
var i = 0;
// ^^^^^^^^^^^^ - source
</script>
// <- - source - comment - meta.tag
//^^ - source - comment - meta.tag
// ^^^^^^^^^ meta.tag - source


<!--
-- TypeScript
-->

<script lang="ts">

// <- source.ts.embedded.html - source source
</script>
// <- source.ts.embedded.html - source source
//^^ source.ts.embedded.html - source source
// ^^^^^^^^^ meta.tag - source

<script lang="ts">
<!--
// ^^^^^^^^^ - source
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.ts.embedded.html - source source
-->
// ^^^^^ source.ts.embedded.html - source source
// <- - comment
//^^^^^^ - comment
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - source - comment - meta.tag
// ^ - comment - source
var i = 0;
// ^^^^^^^^^^^^ - source
</script>
// <- - source - comment - meta.tag
//^^ - source - comment - meta.tag
// ^^^^^^^^^ meta.tag - source


<!--
-- TSX
-->

<script lang="tsx">

// <- source.tsx.embedded.html - source source
</script>
// <- source.tsx.embedded.html - source source
//^^ source.tsx.embedded.html - source source
// ^^^^^^^^^ meta.tag - source

<script lang="tsx">
<!--
// ^^^^^^^^^ - source
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.tsx.embedded.html - source source
-->
// ^^^^^ source.tsx.embedded.html - source source
// <- - comment
//^^^^^^ - comment
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - source - comment - meta.tag
// ^ - comment - source
var i = 0;
// ^^^^^^^^^^^^ - source
</script>
// <- - source - comment - meta.tag
//^^ - source - comment - meta.tag
// ^^^^^^^^^ meta.tag - source
Loading