diff --git a/README.md b/README.md index efde56a..8f9e0f7 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Vue Syntax Highlight -**Note**: the `st4` branch hosts the new syntax that only works in Sublime build > 4107. +Sublime Text Syntax highlighting for single-file [Vue.js](http://vuejs.org) components. -* For Sublime Text 2 support (`.tmlanguage` files), see `master` branch. -* For Sublime Text 3 support, see `new` branch. +The `main` branch targets Sublime Text 4. +For the Sublime Text 2 and 3 support (`.tmlanguage` files), see `st2` branch. -Sublime Text Syntax highlighting for single-file [Vue.js](http://vuejs.org) components (enabled by [vue-loader](https://github.com/vuejs/vue-loader) or [vueify](https://github.com/vuejs/vueify)). +This repository is a fork of [vuejs/vue-syntax-highlight](https://github.com/vuejs/vue-syntax-highlight) +with a focus on providing syntax highlighting only for Sublime Text.
@@ -18,20 +19,6 @@ Sublime Text Syntax highlighting for single-file [Vue.js](http://vuejs.org) comp
**NOTE:** You still need to install corresponding packages for pre-processors (e.g. Pug, SASS, CoffeeScript) to get proper syntax highlighting for them.
-### Enabling JSX Highlighting
-
-The ` tag
- (?: (\s*) (-->) \s* )? (?=(?i:script){{tag_name_break_char}})
- # or standalone html comment end punctuation in a line
- | ^ (\s*) (-->) \s* $
- )
- style_content_begin: '{{script_content_begin}}'
- style_content_end: |-
- (?x:
- # optional html comment end punctuation followed by tag
- (?: (\s*) (-->) \s* )? (?=(?i:style){{tag_name_break_char}})
- # 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 tag
- (?: (\s*) (-->) \s* )? (?=(?i:template){{tag_name_break_char}})
- # or standalone html comment end punctuation in a line
- | ^ (\s*) (-->) \s* $
- )
-
-contexts:
-
-###[ HTML TAGS ]##############################################################
-
- prototype:
- - meta_prepend: true
- - include: mustache-templates
-
- tag-html:
- - meta_prepend: true
- - include: script-tag
- - include: style-tag
- - include: template-tag
-
-###[ SCRIPT TAG ]#############################################################
-
- script-tag:
- # for compatibility with ST builds before 4114
- - match: (<)((?i:script)){{tag_name_break}}
- captures:
- 1: punctuation.definition.tag.begin.html
- 2: entity.name.tag.script.html
- push: script-javascript
- - match: ()((?i:script){{tag_name_break}})
- captures:
- 1: punctuation.definition.tag.begin.html
- 2: entity.name.tag.script.html
- push: script-close-tag-content
-
- script-close-tag-content:
- - meta_scope: meta.tag.script.end.html
- - include: tag-end
-
- script-common:
- - meta_prepend: true
- - include: script-lang-attribute
-
- script-javascript:
- # for compatibility with ST builds before 4114
- - meta_scope: meta.tag.script.begin.html
- - match: '>'
- scope: punctuation.definition.tag.end.html
- set: script-javascript-content
- - include: script-common
-
- script-javascript-content:
- # for compatibility with ST builds before 4114
- - meta_include_prototype: false
- - match: '{{script_content_begin}}'
- captures:
- 1: comment.block.html punctuation.definition.comment.begin.html
- pop: 1 # make sure to match only once
- embed: scope:source.js
- embed_scope: source.js.embedded.html
- escape: '{{script_content_end}}'
- escape_captures:
- 1: source.js.embedded.html
- 2: comment.block.html punctuation.definition.comment.end.html
- 3: source.js.embedded.html
- 4: comment.block.html punctuation.definition.comment.end.html
-
- script-lang-attribute:
- - match: (?i:lang){{attribute_name_break}}
- scope: meta.attribute-with-value.html entity.other.attribute-name.html
- set: script-lang-attribute-assignment
-
- script-lang-attribute-assignment:
- - meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.html
- - match: =
- scope: punctuation.separator.key-value.html
- set: script-lang-attribute-value
- - match: (?=\S)
- set: script-javascript
-
- script-lang-attribute-value:
- - meta_include_prototype: false
- - meta_scope: meta.tag.script.begin.html meta.attribute-with-value.html
- - include: script-lang-decider
-
- script-lang-decider:
- - !script_language [ coffee, source.coffee ]
- - !script_language [ livescript, source.livescript ]
- - !script_language [ ts, source.ts ]
- - match: (?=\S)
- set:
- - script-javascript
- - tag-generic-attribute-meta
- - tag-generic-attribute-value
-
-###[ STYLE TAG ]##############################################################
-
- style-tag:
- # for compatibility with ST builds before 4114
- - match: (<)((?i:style)){{tag_name_break}}
- captures:
- 1: punctuation.definition.tag.begin.html
- 2: entity.name.tag.style.html
- push: style-css
- - match: ()((?i:style){{tag_name_break}})
- captures:
- 1: punctuation.definition.tag.begin.html
- 2: entity.name.tag.style.html
- push: style-close-tag-content
-
- style-close-tag-content:
- - meta_scope: meta.tag.style.end.html
- - include: tag-end
-
- style-common:
- - meta_prepend: true
- - include: style-lang-attribute
-
- style-css:
- # for compatibility with ST builds before 4114
- - meta_scope: meta.tag.style.begin.html
- - match: '>'
- scope: punctuation.definition.tag.end.html
- set: style-css-content
- - include: style-common
-
- style-css-content:
- # for compatibility with ST builds before 4114
- - meta_include_prototype: false
- - match: '{{style_content_begin}}'
- captures:
- 1: comment.block.html punctuation.definition.comment.begin.html
- pop: 1 # make sure to match only once
- embed: scope:source.css
- embed_scope: source.css.embedded.html
- escape: '{{style_content_end}}'
- escape_captures:
- 1: source.css.embedded.html
- 2: comment.block.html punctuation.definition.comment.end.html
- 3: source.css.embedded.html
- 4: comment.block.html punctuation.definition.comment.end.html
-
- style-lang-attribute:
- - match: (?i:lang){{attribute_name_break}}
- scope: meta.attribute-with-value.html entity.other.attribute-name.html
- set: style-lang-attribute-assignment
-
- style-lang-attribute-assignment:
- - meta_content_scope: meta.tag.style.begin.html meta.attribute-with-value.html
- - match: =
- scope: punctuation.separator.key-value.html
- set: style-lang-attribute-value
- - match: (?=\S)
- set: style-css
-
- style-lang-attribute-value:
- - meta_include_prototype: false
- - meta_scope: meta.tag.style.begin.html meta.attribute-with-value.html
- - include: style-lang-decider
-
- style-lang-decider:
- - !style_language [ sass, source.sass ]
- - !style_language [ scss, source.scss ]
- - !style_language [ stylus, source.stylus ]
- - !style_language [ postcss\?parser=sugarss, source.sss ]
- - !style_language [ postcss, source.postcss ]
- - !style_language [ less, source.less ]
- - match: (?=\S)
- set:
- - style-css
- - tag-generic-attribute-meta
- - tag-generic-attribute-value
-
-###[ TEMPLATE TAG ]###########################################################
-
- template-tag:
- - match: (<)((?i:template)){{tag_name_break}}
- captures:
- 1: punctuation.definition.tag.begin.html
- 2: entity.name.tag.template.html
- push: template-mustache
- - match: ()((?i:template))
- captures:
- 1: punctuation.definition.tag.begin.html
- 2: entity.name.tag.template.html
- 3: punctuation.definition.tag.end.html
- push: template-tag-content
-
- template-tag-content:
- - meta_scope: meta.tag.template.end.html
- - include: tag-end
-
- template-common:
- - include: template-lang-attribute
- - include: tag-attributes
- - include: tag-end-self-closing
-
- template-mustache:
- - meta_scope: meta.tag.template.begin.html
- - include: tag-end
- - include: template-common
-
- template-lang-attribute:
- - match: (?i:lang){{attribute_name_break}}
- scope: meta.attribute-with-value.html entity.other.attribute-name.html
- set: template-lang-attribute-assignment
-
- template-lang-attribute-assignment:
- - meta_content_scope: meta.tag.template.begin.html meta.attribute-with-value.html
- - match: =
- scope: punctuation.separator.key-value.html
- set: template-lang-attribute-value
- - match: (?=\S)
- set: template-mustache
-
- template-lang-attribute-value:
- - meta_include_prototype: false
- - meta_scope: meta.tag.template.begin.html meta.attribute-with-value.html
- - include: template-lang-decider
-
- template-lang-decider:
- - !template_language [ jade, text.jade ]
- - !template_language [ pug, text.pug ]
- - !template_language [ slm, text.slm ]
- - match: (?=\S)
- set:
- - template-mustache
- - tag-generic-attribute-meta
- - tag-generic-attribute-value
-
-###[ TAG ATTRIBUTES ]#########################################################
-
- tag-attributes:
- - meta_prepend: true
- - include: vue-directive
-
- tag-class-attribute-value:
- # for compatibility with ST builds before 4114
- - meta_prepend: true
- - meta_include_prototype: false
-
- tag-generic-attribute-value:
- # for compatibility with ST builds before 4114
- - meta_prepend: true
- - meta_include_prototype: false
-
- tag-href-attribute-value:
- # for compatibility with ST builds before 4114
- - meta_prepend: true
- - meta_include_prototype: false
-
- tag-id-attribute-value:
- # for compatibility with ST builds before 4114
- - meta_prepend: true
- - meta_include_prototype: false
-
- tag-attribute-value-content:
- - meta_prepend: true
- - include: mustache-interpolations
-
- strings-common-content:
- - meta_prepend: true
- - include: mustache-interpolations
-
-###[ MUSTAGE TEMPLATES ]######################################################
-
- mustache-interpolations:
- - match: (?={{)
- push: mustache-interpolation-content
-
- mustache-interpolation-content:
- - clear_scopes: 1
- - include: mustache-templates
- - include: immediately-pop
-
- mustache-templates:
- - match: '{{'
- scope: meta.interpolation.vue punctuation.section.interpolation.begin.html
- embed: scope:source.js
- embed_scope: meta.interpolation.vue source.js.embedded.vue
- escape: '}}'
- escape_captures:
- 0: meta.interpolation.vue punctuation.section.interpolation.end.html
-
-###[ VUE DIRECTIVES ]#########################################################
-
- vue-directive:
- - match: (?=v-)
- push:
- - vue-directive-meta
- - vue-directive-assignment
- - tag-generic-attribute-name
- - match: (?::|@|#)
- scope: punctuation.definition.attribute.html
- push:
- - vue-directive-meta
- - vue-directive-assignment
- - tag-generic-attribute-name
-
- vue-directive-meta:
- - meta_include_prototype: false
- - meta_scope: meta.attribute-with-value.directive.html
- - include: immediately-pop
-
- vue-directive-assignment:
- - match: =
- scope: punctuation.separator.key-value.html
- set: vue-directive-value
- - include: else-pop
-
- vue-directive-value:
- - match: \"
- scope:
- meta.string.html string.quoted.double.html
- punctuation.definition.string.begin.html
- embed: scope:source.js#expression-statement
- embed_scope:
- meta.string.html meta.interpolation.vue
- source.js.embedded.vue
- escape: \"
- escape_captures:
- 0:
- meta.attribute-with-value.directive.html
- meta.string.html string.quoted.double.html
- punctuation.definition.string.end.html
- - match: \'
- scope:
- meta.string.html string.quoted.single.html
- punctuation.definition.string.begin.html
- embed: scope:source.js#expression-statement
- embed_scope:
- meta.string.html meta.interpolation.vue
- source.js.embedded.vue
- escape: \'
- escape_captures:
- 0:
- meta.attribute-with-value.directive.html
- meta.string.html string.quoted.single.html
- punctuation.definition.string.end.html
- - include: else-pop
-
- tag-generic-attribute-name:
- - meta_prepend: true
- # https://vuejs.org/guide/essentials/template-syntax.html#dynamic-arguments
- - match: (?=\[)
- push: vue-dynamic-attribute-name
-
- vue-dynamic-attribute-name:
- - clear_scopes: 1 # clear `entity.other.attribute-name`
- - match: \[
- scope: meta.interpolation.vue punctuation.section.interpolation.begin.vue
- embed: scope:source.js#expression-statement
- embed_scope: meta.interpolation.vue source.js.embedded.vue
- escape: \]
- escape_captures:
- 0: meta.interpolation.vue punctuation.section.interpolation.end.vue
- - include: immediately-pop
diff --git a/src/macros.py b/src/macros.py
deleted file mode 100644
index 9884d5a..0000000
--- a/src/macros.py
+++ /dev/null
@@ -1,45 +0,0 @@
-from YAMLMacros.lib.syntax import rule as _rule
-
-def script_language(match, embed):
- return embed_language_in_tag('script', match, embed)
-
-def style_language(match, embed):
- return embed_language_in_tag('style', match, embed)
-
-def template_language(match, embed):
- return embed_language_in_tag('template', match, embed)
-
-def embed_language_in_tag(tag, match, embed):
- return _rule(
- match=r'(?i)(?={0}{{{{unquoted_attribute_break}}}}|\'{0}\'|"{0}")'.format(match),
- set=[
- [
- _rule(meta_scope='meta.tag.%s.begin.html' % tag),
- _rule(
- match='>',
- scope='punctuation.definition.tag.end.html',
- set=[
- _rule(
- match=r'{{%s_content_begin}}' % tag,
- captures={
- 1: 'comment.block.html punctuation.definition.comment.begin.html',
- },
- pop=1,
- embed=('scope:%s' % embed),
- embed_scope=('%s.embedded.html' % embed),
- escape='{{%s_content_end}}' % tag,
- escape_captures={
- 1: ('%s.embedded.html' % embed),
- 2: 'comment.block.html punctuation.definition.comment.end.html',
- 3: ('%s.embedded.html' % embed),
- 4: 'comment.block.html punctuation.definition.comment.end.html',
- },
- )
- ]
- ),
- _rule(include='%s-common' % tag),
- ],
- 'tag-generic-attribute-meta',
- 'tag-generic-attribute-value',
- ]
- )