From 17139a34b31a163374a083143418df077074b1e6 Mon Sep 17 00:00:00 2001 From: Anirudh Sanjeev Date: Fri, 15 Dec 2017 08:07:32 +0530 Subject: [PATCH 01/62] Rewrite syntax for Sublime > 3153 (#109) * Initial work on native sublime syntax support * Use older style of embedding scope in syntax highlight * Revert "Use older style of embedding scope in syntax highlight" This reverts commit 3beb4ba2720c6dde33bcc12120b03578b8d6182c. * Fixed syntax issues reported by @z3nz * delete old tmLanguage * add support for other languages * Fixing issues: - changed underscores in names to hyphens - added support for single quote in attribute strings * Rewrite using yaml macros * Fixed issues in regexps * Use different yaml file for html syntax * delete old language yaml file --- HTML.yaml | 480 +++++++ Vue Component.sublime-syntax | 857 +++++++++++++ Vue Component.sublime-syntax.yaml-macros | 398 ++++++ vue.YAML-tmLanguage | 470 ------- vue.tmLanguage | 1470 ---------------------- 5 files changed, 1735 insertions(+), 1940 deletions(-) create mode 100644 HTML.yaml create mode 100644 Vue Component.sublime-syntax create mode 100644 Vue Component.sublime-syntax.yaml-macros delete mode 100644 vue.YAML-tmLanguage delete mode 100644 vue.tmLanguage diff --git a/HTML.yaml b/HTML.yaml new file mode 100644 index 0000000..4121557 --- /dev/null +++ b/HTML.yaml @@ -0,0 +1,480 @@ +%YAML 1.2 +--- +name: HTML +file_extensions: + - html + - htm + - shtml + - xhtml + - inc + - tmpl + - tpl +first_line_match: (?i)<(!DOCTYPE\s*)?html +scope: text.html.basic + +variables: + unquoted_attribute_value: (?:[^\s<>/''"]|/(?!>))+ + not_equals_lookahead: (?=\s*[^\s=]) + +contexts: + immediately-pop: + - match: '' + pop: true + + else-pop: + - match: (?=\S) + pop: true + + main: + - match: (<\?)(xml) + captures: + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.xml.html + push: + - meta_scope: meta.tag.preprocessor.xml.html + - match: '\?>' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-generic-attribute + - include: string-double-quoted + - include: string-single-quoted + - match: )?\s*() + captures: + 0: meta.tag.script.end.html + 1: comment.block.html punctuation.definition.comment.html + 2: punctuation.definition.tag.begin.html + 3: entity.name.tag.script.html + 4: punctuation.definition.tag.end.html + pop: true + - match: '(>)\s*()?\s*)' + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - include: entities + - match: <> + scope: invalid.illegal.incomplete.html + entities-common: + - match: (&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;) + scope: constant.character.entity.html + captures: + 1: punctuation.definition.entity.html + 3: punctuation.definition.entity.html + attribute-entities: + - include: entities-common + entities: + - include: entities-common + - match: '&' + scope: invalid.illegal.bad-ampersand.html + string-double-quoted: + - match: '"' + scope: punctuation.definition.string.begin.html + push: + - meta_scope: string.quoted.double.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: entities + string-single-quoted: + - match: "'" + scope: punctuation.definition.string.begin.html + push: + - meta_scope: string.quoted.single.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: entities + + tag-generic-attribute: + - match: '[a-zA-Z0-9:\-_.]+' + scope: entity.other.attribute-name.html + push: + - tag-generic-attribute-meta + - tag-generic-attribute-equals + + - match: '[a-zA-Z0-9:\-_.]+' + scope: entity.other.attribute-name.html + + tag-generic-attribute-meta: + - meta_scope: meta.attribute-with-value.html + - include: immediately-pop + + tag-generic-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-generic-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-generic-attribute-value: + - match: '"' + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.double.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: "'" + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.single.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: '{{unquoted_attribute_value}}' + scope: string.unquoted.html + - include: else-pop + + tag-class-attribute: + - match: '\bclass\b' + scope: entity.other.attribute-name.class.html + push: + - tag-class-attribute-meta + - tag-class-attribute-equals + + tag-class-attribute-meta: + - meta_scope: meta.attribute-with-value.class.html + - include: immediately-pop + + tag-class-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-class-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-class-attribute-value: + - match: '"' + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.double.html + - meta_content_scope: meta.class-name.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: "'" + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.single.html + - meta_content_scope: meta.class-name.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: '{{unquoted_attribute_value}}' + scope: string.unquoted.html meta.class-name.html + - include: else-pop + + tag-id-attribute: + - match: '\bid\b' + scope: entity.other.attribute-name.id.html + push: + - tag-id-attribute-meta + - tag-id-attribute-equals + + tag-id-attribute-meta: + - meta_scope: meta.attribute-with-value.id.html + - include: immediately-pop + + tag-id-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-id-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-id-attribute-value: + - match: '"' + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.double.html + - meta_content_scope: meta.toc-list.id.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: "'" + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.single.html + - meta_content_scope: meta.toc-list.id.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: '{{unquoted_attribute_value}}' + scope: string.unquoted.html meta.toc-list.id.html + - include: else-pop + + tag-style-attribute: + - match: '\bstyle\b' + scope: entity.other.attribute-name.style.html + push: + - tag-style-attribute-meta + - tag-style-attribute-equals + + tag-style-attribute-meta: + - meta_scope: meta.attribute-with-value.style.html + - include: immediately-pop + + tag-style-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-style-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-style-attribute-value: + - match: '"' + scope: string.quoted.double punctuation.definition.string.begin.html + embed: scope:source.css#rule-list-body + embed_scope: source.css + escape: '"' + escape_captures: + 0: string.quoted.double punctuation.definition.string.end.html + - match: "'" + scope: string.quoted.single punctuation.definition.string.begin.html + embed: scope:source.css#rule-list-body + embed_scope: source.css + escape: "'" + escape_captures: + 0: string.quoted.single punctuation.definition.string.end.html + - include: else-pop + + tag-event-attribute: + - match: |- + (?x)\bon( + abort|autocomplete|autocompleteerror|blur|cancel|canplay + |canplaythrough|change|click|close|contextmenu|cuechange|dblclick|drag + |dragend|dragenter|dragexit|dragleave|dragover|dragstart|drop + |durationchange|emptied|ended|error|focus|input|invalid|keydown + |keypress|keyup|load|loadeddata|loadedmetadata|loadstart|mousedown + |mouseenter|mouseleave|mousemove|mouseout|mouseover|mouseup|mousewheel + |pause|play|playing|progress|ratechange|reset|resize|scroll|seeked + |seeking|select|show|sort|stalled|submit|suspend|timeupdate|toggle + |volumechange|waiting + )\b + scope: entity.other.attribute-name.event.html + push: + - tag-event-attribute-meta + - tag-event-attribute-equals + + tag-event-attribute-meta: + - meta_scope: meta.attribute-with-value.event.html + - include: immediately-pop + + tag-event-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-event-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-event-attribute-value: + - match: '"' + scope: string.quoted.double punctuation.definition.string.begin.html + embed: scope:source.js + embed_scope: meta.attribute-with-value.event.html + escape: '"' + escape_captures: + 0: string.quoted.double punctuation.definition.string.end.html + - match: "'" + scope: string.quoted.single punctuation.definition.string.begin.html meta.attribute-with-value.event.html + embed: scope:source.js + embed_scope: meta.attribute-with-value.event.html + escape: "'" + escape_captures: + 0: string.quoted.single punctuation.definition.string.end.html + - include: else-pop + + tag-attributes: + - include: tag-id-attribute + - include: tag-class-attribute + - include: tag-style-attribute + - include: tag-event-attribute + - include: tag-generic-attribute \ No newline at end of file diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax new file mode 100644 index 0000000..c2309c0 --- /dev/null +++ b/Vue Component.sublime-syntax @@ -0,0 +1,857 @@ +%YAML 1.2 +--- +name: Vue Component +file_extensions: [vue] +first_line_match: (?i)<(!DOCTYPE\s*)?html +scope: text.html.vue +variables: + unquoted_attribute_value: (?:[^\s<>/''"]|/(?!>))+ + not_equals_lookahead: (?=\s*[^\s=]) + +contexts: + immediately-pop: + - match: '' + pop: true + + else-pop: + - match: (?=\S) + pop: true + + main: + - include: langs + - include: template-tag + + - match: (<\?)(xml) + captures: + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.xml.html + push: + - meta_scope: meta.tag.preprocessor.xml.html + - match: \?> + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-generic-attribute + - include: string-double-quoted + - include: string-single-quoted + - match: )?\s*() + captures: + 0: meta.tag.script.end.html + 1: comment.block.html punctuation.definition.comment.html + 2: punctuation.definition.tag.begin.html + 3: entity.name.tag.script.html + 4: punctuation.definition.tag.end.html + pop: true + - match: (>)\s*()?\s*) + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - match: (' + scope: punctuation.definition.tag.end.html + pop: true + - include: tag-attributes + - include: entities + - match: <> + scope: invalid.illegal.incomplete.html + entities-common: + - match: (&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;) + scope: constant.character.entity.html + captures: + 1: punctuation.definition.entity.html + 3: punctuation.definition.entity.html + attribute-entities: + - include: entities-common + entities: + - include: entities-common + - match: '&' + scope: invalid.illegal.bad-ampersand.html + string-double-quoted: + - match: '"' + scope: punctuation.definition.string.begin.html + push: + - meta_scope: string.quoted.double.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: entities + string-single-quoted: + - match: "'" + scope: punctuation.definition.string.begin.html + push: + - meta_scope: string.quoted.single.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: entities + + tag-generic-attribute: + - match: '[a-zA-Z0-9:\-_.]+' + scope: entity.other.attribute-name.html + push: + - tag-generic-attribute-meta + - tag-generic-attribute-equals + + - match: '[a-zA-Z0-9:\-_.]+' + scope: entity.other.attribute-name.html + + tag-generic-attribute-meta: + - meta_scope: meta.attribute-with-value.html + - include: immediately-pop + + tag-generic-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-generic-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-generic-attribute-value: + - match: '"' + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.double.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: "'" + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.single.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: '{{unquoted_attribute_value}}' + scope: string.unquoted.html + - include: else-pop + + tag-class-attribute: + - match: \bclass\b + scope: entity.other.attribute-name.class.html + push: + - tag-class-attribute-meta + - tag-class-attribute-equals + + tag-class-attribute-meta: + - meta_scope: meta.attribute-with-value.class.html + - include: immediately-pop + + tag-class-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-class-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-class-attribute-value: + - match: '"' + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.double.html + - meta_content_scope: meta.class-name.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: "'" + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.single.html + - meta_content_scope: meta.class-name.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: '{{unquoted_attribute_value}}' + scope: string.unquoted.html meta.class-name.html + - include: else-pop + + tag-id-attribute: + - match: \bid\b + scope: entity.other.attribute-name.id.html + push: + - tag-id-attribute-meta + - tag-id-attribute-equals + + tag-id-attribute-meta: + - meta_scope: meta.attribute-with-value.id.html + - include: immediately-pop + + tag-id-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-id-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-id-attribute-value: + - match: '"' + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.double.html + - meta_content_scope: meta.toc-list.id.html + - match: '"' + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: "'" + scope: punctuation.definition.string.begin.html + set: + - meta_scope: string.quoted.single.html + - meta_content_scope: meta.toc-list.id.html + - match: "'" + scope: punctuation.definition.string.end.html + pop: true + - include: attribute-entities + - match: '{{unquoted_attribute_value}}' + scope: string.unquoted.html meta.toc-list.id.html + - include: else-pop + + tag-style-attribute: + - match: \bstyle\b + scope: entity.other.attribute-name.style.html + push: + - tag-style-attribute-meta + - tag-style-attribute-equals + + tag-style-attribute-meta: + - meta_scope: meta.attribute-with-value.style.html + - include: immediately-pop + + tag-style-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-style-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-style-attribute-value: + - match: '"' + scope: string.quoted.double punctuation.definition.string.begin.html + embed: scope:source.css#rule-list-body + embed_scope: source.css + escape: '"' + escape_captures: + 0: string.quoted.double punctuation.definition.string.end.html + - match: "'" + scope: string.quoted.single punctuation.definition.string.begin.html + embed: scope:source.css#rule-list-body + embed_scope: source.css + escape: "'" + escape_captures: + 0: string.quoted.single punctuation.definition.string.end.html + - include: else-pop + + tag-event-attribute: + - match: |- + (?x)\bon( + abort|autocomplete|autocompleteerror|blur|cancel|canplay + |canplaythrough|change|click|close|contextmenu|cuechange|dblclick|drag + |dragend|dragenter|dragexit|dragleave|dragover|dragstart|drop + |durationchange|emptied|ended|error|focus|input|invalid|keydown + |keypress|keyup|load|loadeddata|loadedmetadata|loadstart|mousedown + |mouseenter|mouseleave|mousemove|mouseout|mouseover|mouseup|mousewheel + |pause|play|playing|progress|ratechange|reset|resize|scroll|seeked + |seeking|select|show|sort|stalled|submit|suspend|timeupdate|toggle + |volumechange|waiting + )\b + scope: entity.other.attribute-name.event.html + push: + - tag-event-attribute-meta + - tag-event-attribute-equals + + tag-event-attribute-meta: + - meta_scope: meta.attribute-with-value.event.html + - include: immediately-pop + + tag-event-attribute-equals: + - match: '=' + scope: punctuation.separator.key-value.html + set: tag-event-attribute-value + - match: '{{not_equals_lookahead}}' + pop: true + + tag-event-attribute-value: + - match: '"' + scope: string.quoted.double punctuation.definition.string.begin.html + embed: scope:source.js + embed_scope: meta.attribute-with-value.event.html + escape: '"' + escape_captures: + 0: string.quoted.double punctuation.definition.string.end.html + - match: "'" + scope: string.quoted.single punctuation.definition.string.begin.html meta.attribute-with-value.event.html + embed: scope:source.js + embed_scope: meta.attribute-with-value.event.html + escape: "'" + escape_captures: + 0: string.quoted.single punctuation.definition.string.end.html + - include: else-pop + + tag-attributes: + - include: vue-directive + + - include: tag-id-attribute + - include: tag-class-attribute + - include: tag-style-attribute + - include: tag-event-attribute + - include: tag-generic-attribute + template-tag: + - match: (?i)(<)(template)\b + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '>' + scope: meta.tag.template.begin.html punctuation.definition.tag.end.html + push: mustache-template + - match: '' + push: + - meta_scope: meta.tag.template.begin.html + - match: (?=>) + pop: true + - include: tag-attributes + + mustache-template: + - match: (?=]*lang=(['"])coffee?) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.coffee + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:script))\b(?=[^>]*lang=(['"])livescript?) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.livescript + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:script))\b(?=[^>]*lang=(['"])ts?) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.ts + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:script))\b(?=[^>]*) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.js + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])sass?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.sass + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])scss?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.scss + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])stylus?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.stylus + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])postcss?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.postcss + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])less?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.less + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.css + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:template))\b(?=[^>]*lang=(['"])jade?) + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.template.begin.html punctuation.definition.tag.end.html + embed: scope:text.jade + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:template))\b(?=[^>]*lang=(['"])pug?) + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.template.begin.html punctuation.definition.tag.end.html + embed: scope:text.pug + escape: (?i)(?=) + pop: true + - include: tag-attributes + - match: (?i)(<)((?:template))\b(?=[^>]*lang=(['"])slm?) + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: (>) + captures: + 1: meta.tag.template.begin.html punctuation.definition.tag.end.html + embed: scope:text.slm + escape: (?i)(?=) + pop: true + - include: tag-attributes +hidden: false diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros new file mode 100644 index 0000000..1dfb9cc --- /dev/null +++ b/Vue Component.sublime-syntax.yaml-macros @@ -0,0 +1,398 @@ +%YAML 1.2 +%TAG ! tag:yaml-macros:YAMLMacros.lib.extend: +--- +!extend +_base: HTML.yaml +name: Vue Component +scope: text.html.vue +hidden: false +file_extensions: [vue] + +contexts: !merge + main: !prepend + - include: langs + - include: template-tag + + tag-attributes: !prepend + - include: vue-directive + + template-tag: + - match: '(?i)(<)(template)\b' + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '>' + scope: meta.tag.template.begin.html punctuation.definition.tag.end.html + push: mustache-template + - match: '' + push: + - meta_scope: meta.tag.template.begin.html + - match: '(?=>)' + pop: true + - include: tag-attributes + + mustache-template: + - match: (?=]*lang=(['"])coffee?) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.coffee + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:script))\b(?=[^>]*lang=(['"])livescript?) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.livescript + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:script))\b(?=[^>]*lang=(['"])ts?) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.ts + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:script))\b(?=[^>]*) + captures: + 0: meta.tag.script.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + push: + - match: (?i)() + captures: + 0: meta.tag.script.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.script.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.script.begin.html punctuation.definition.tag.end.html + embed: scope:source.js + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])sass?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.sass + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])scss?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.scss + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])stylus?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.stylus + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])postcss?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.postcss + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*lang=(['"])less?) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.less + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:style))\b(?=[^>]*) + captures: + 0: meta.tag.style.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + push: + - match: (?i)() + captures: + 0: meta.tag.style.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.style.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.style.begin.html punctuation.definition.tag.end.html + embed: scope:source.css + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:template))\b(?=[^>]*lang=(['"])jade?) + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.template.begin.html punctuation.definition.tag.end.html + embed: scope:text.jade + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:template))\b(?=[^>]*lang=(['"])pug?) + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.template.begin.html punctuation.definition.tag.end.html + embed: scope:text.pug + escape: (?i)(?=)' + pop: true + - include: tag-attributes + - match: (?i)(<)((?:template))\b(?=[^>]*lang=(['"])slm?) + captures: + 0: meta.tag.template.begin.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + push: + - match: (?i)() + captures: + 0: meta.tag.template.end.html + 1: punctuation.definition.tag.begin.html + 2: entity.name.tag.template.html + 3: punctuation.definition.tag.end.html + pop: true + - match: '(>)' + captures: + 1: meta.tag.template.begin.html punctuation.definition.tag.end.html + embed: scope:text.slm + escape: (?i)(?=)' + pop: true + - include: tag-attributes + \ No newline at end of file diff --git a/vue.YAML-tmLanguage b/vue.YAML-tmLanguage deleted file mode 100644 index 7582aef..0000000 --- a/vue.YAML-tmLanguage +++ /dev/null @@ -1,470 +0,0 @@ -# [PackageDev] target_format: plist, ext: tmLanguage ---- -name: Vue Component -scopeName: text.html.vue -fileTypes: [vue] -uuid: 5512c10d-4cc5-434c-b8fc-53b912f55ab3 - -patterns: -- include: '#vue-interpolations' - -- name: meta.tag.any.html - begin: (<)([a-zA-Z0-9:-]++)(?=[^>]*>) - beginCaptures: - '1': {name: punctuation.definition.tag.begin.html} - '2': {name: entity.name.tag.html} - end: (>)(<)(/)(\2)(>) - endCaptures: - '1': {name: punctuation.definition.tag.end.html} - '2': {name: punctuation.definition.tag.begin.html meta.scope.between-tag-pair.html} - '3': {name: punctuation.definition.tag.begin.html} - '4': {name: entity.name.tag.html} - '5': {name: punctuation.definition.tag.end.html} - patterns: - - include: '#tag-stuff' - -- name: meta.tag.preprocessor.xml.html - begin: (<\?)(xml) - end: (\?>) - captures: - '1': {name: punctuation.definition.tag.html} - '2': {name: entity.name.tag.xml.html} - patterns: - - include: '#tag-generic-attribute' - - include: '#string-double-quoted' - - include: '#string-single-quoted' - -- name: comment.block.html - begin: )$ - |<\?(?:php)?.*\b(if|for(each)?|while)\b.+: - |\{\{?(if|foreach|capture|literal|foreach|php|section|strip) - |\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/))) - ) - -foldingStopMarker: |- - (?x) - ( - |^(?!.*?$ - |<\?(?:php)?.*\bend(if|for(each)?|while)\b - |\{\{?/(if|foreach|capture|literal|foreach|php|section|strip) - |^[^{]*\} - ) - -keyEquivalent: ^~H diff --git a/vue.tmLanguage b/vue.tmLanguage deleted file mode 100644 index b8f67f4..0000000 --- a/vue.tmLanguage +++ /dev/null @@ -1,1470 +0,0 @@ - - - - - fileTypes - - vue - - foldingStartMarker - (?x) -(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|li|form|dl)\b.*?> -|<!--(?!.*--\s*>) -|^<!--\ \#tminclude\ (?>.*?-->)$ -|<\?(?:php)?.*\b(if|for(each)?|while)\b.+: -|\{\{?(if|foreach|capture|literal|foreach|php|section|strip) -|\{\s*($|\?>\s*$|//|/\*(.*\*/\s*$|(?!.*?\*/))) -) - foldingStopMarker - (?x) -(</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|li|form|dl)> -|^(?!.*?<!--).*?--\s*> -|^<!--\ end\ tminclude\ -->$ -|<\?(?:php)?.*\bend(if|for(each)?|while)\b -|\{\{?/(if|foreach|capture|literal|foreach|php|section|strip) -|^[^{]*\} -) - keyEquivalent - ^~H - name - Vue Component - patterns - - - include - #vue-interpolations - - - begin - (<)([a-zA-Z0-9:-]++)(?=[^>]*></\2>) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.html - - - end - (>)(<)(/)(\2)(>) - endCaptures - - 1 - - name - punctuation.definition.tag.end.html - - 2 - - name - punctuation.definition.tag.begin.html meta.scope.between-tag-pair.html - - 3 - - name - punctuation.definition.tag.begin.html - - 4 - - name - entity.name.tag.html - - 5 - - name - punctuation.definition.tag.end.html - - - name - meta.tag.any.html - patterns - - - include - #tag-stuff - - - - - begin - (<\?)(xml) - captures - - 1 - - name - punctuation.definition.tag.html - - 2 - - name - entity.name.tag.xml.html - - - end - (\?>) - name - meta.tag.preprocessor.xml.html - patterns - - - include - #tag-generic-attribute - - - include - #string-double-quoted - - - include - #string-single-quoted - - - - - begin - <!-- - captures - - 0 - - name - punctuation.definition.comment.html - - - end - --\s*> - name - comment.block.html - patterns - - - match - -- - name - invalid.illegal.bad-comments-or-CDATA.html - - - - - begin - <! - captures - - 0 - - name - punctuation.definition.tag.html - - - end - > - name - meta.tag.sgml.html - patterns - - - begin - (?i:DOCTYPE) - captures - - 1 - - name - entity.name.tag.doctype.html - - - end - (?=>) - name - meta.tag.sgml.doctype.html - patterns - - - match - "[^">]*" - name - string.quoted.double.doctype.identifiers-and-DTDs.html - - - - - begin - \[CDATA\[ - end - ]](?=>) - name - constant.other.inline-data.html - - - match - (\s*)(?!--|>)\S(\s*) - name - invalid.illegal.bad-comments-or-CDATA.html - - - - - begin - (?:^\s+)?(<)((?i:template))\b(?=[^>]*lang=(['"])slm\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:template))(>)(?:\s*\n)? - name - text.slm.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:template)) - patterns - - - include - text.slm - - - - - - - begin - (?:^\s+)?(<)((?i:template))\b(?=[^>]*lang=(['"])jade\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:template))(>)(?:\s*\n)? - name - text.jade.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:template)) - patterns - - - include - text.jade - - - - - - - begin - (?:^\s+)?(<)((?i:template))\b(?=[^>]*lang=(['"])pug\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:template))(>)(?:\s*\n)? - name - text.pug.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:template)) - patterns - - - include - text.pug - - - - - - - begin - (?:^\s+)?(<)((?i:style))\b(?=[^>]*lang=(['"])stylus\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:style))(>)(?:\s*\n)? - name - source.stylus.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:style)) - patterns - - - include - source.stylus - - - - - - - begin - (?:^\s+)?(<)((?i:style))\b(?=[^>]*lang=(['"])postcss\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:style))(>)(?:\s*\n)? - name - source.postcss.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:style)) - patterns - - - include - source.postcss - - - - - - - begin - (?:^\s+)?(<)((?i:style))\b(?=[^>]*lang=(['"])sass\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:style))(>)(?:\s*\n)? - name - source.sass.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:style)) - patterns - - - include - source.sass - - - include - source.scss - - - - - - - begin - (?:^\s+)?(<)((?i:style))\b(?=[^>]*lang=(['"])scss\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:style))(>)(?:\s*\n)? - name - source.scss.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:style)) - patterns - - - include - source.sass - - - include - source.scss - - - - - - - begin - (?:^\s+)?(<)((?i:style))\b(?=[^>]*lang=(['"])less\1?) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:style))(>)(?:\s*\n)? - name - source.less.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:style)) - patterns - - - include - source.less - - - - - - - begin - (?:^\s+)?(<)((?i:style))\b(?![^>]*/>) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.style.html - - 3 - - name - punctuation.definition.tag.html - - - end - (</)((?i:style))(>)(?:\s*\n)? - name - source.css.embedded.html - patterns - - - include - #tag-stuff - - - begin - (>) - beginCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - end - (?=</(?i:style)) - patterns - - - include - source.css - - - - - - - begin - (?:^\s+)?(<)((?i:script))\b(?=[^>]*lang=(['"])coffee\1?) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.script.html - - - end - (?<=</(script|SCRIPT))(>)(?:\s*\n)? - endCaptures - - 2 - - name - punctuation.definition.tag.html - - - name - source.coffee.embedded.html - patterns - - - include - #tag-stuff - - - begin - (?<!</(?:script|SCRIPT))(>) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.script.html - - - end - (</)((?i:script)) - patterns - - - include - source.coffee - - - - - - - begin - (?:^\s+)?(<)((?i:script))\b(?=[^>]*lang=(['"])livescript\1?) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.script.html - - - end - (?<=</(script|SCRIPT))(>)(?:\s*\n)? - endCaptures - - 2 - - name - punctuation.definition.tag.html - - - name - source.livescript.embedded.html - patterns - - - include - #tag-stuff - - - begin - (?<!</(?:script|SCRIPT))(>) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.script.html - - - end - (</)((?i:script)) - patterns - - - include - source.livescript - - - - - - - begin - (<)((?i:script))\b(?![^>]*/>)(?![^>]*(?i:type.?=.?text/((?!javascript|babel|ecmascript).*))) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.script.html - - - end - (?<=</(script|SCRIPT))(>)(?:\s*\n)? - endCaptures - - 2 - - name - punctuation.definition.tag.html - - - name - source.js.embedded.html - patterns - - - include - #tag-stuff - - - begin - (?<!</(?:script|SCRIPT))(>) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.script.html - - - end - (</)((?i:script)) - patterns - - - captures - - 1 - - name - punctuation.definition.comment.js - - - match - (//).*?((?=</script)|$\n?) - name - comment.line.double-slash.js - - - begin - /\* - captures - - 0 - - name - punctuation.definition.comment.js - - - end - \*/|(?=</script) - name - comment.block.js - - - include - source.js - - - - - - - begin - (</?)((?i:body|head|html)\b) - captures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.structure.any.html - - - end - (>) - endCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - name - meta.tag.structure.any.html - patterns - - - include - #tag-stuff - - - - - begin - (</?)((?i:address|blockquote|dd|div|dl|dt|fieldset|form|frame|frameset|h1|h2|h3|h4|h5|h6|iframe|noframes|object|ol|p|ul|applet|center|dir|hr|menu|pre)\b) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.block.any.html - - - end - (>) - endCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - name - meta.tag.block.any.html - patterns - - - include - #tag-stuff - - - - - begin - (</?)((?i:a|abbr|acronym|area|b|base|basefont|bdo|big|br|button|caption|cite|code|col|colgroup|del|dfn|em|font|head|html|i|img|input|ins|isindex|kbd|label|legend|li|link|map|meta|noscript|optgroup|option|param|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|var)\b) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.inline.any.html - - - end - ((?: ?/)?>) - endCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - name - meta.tag.inline.any.html - patterns - - - include - #tag-stuff - - - - - begin - (</?)([a-zA-Z0-9:-]+) - beginCaptures - - 1 - - name - punctuation.definition.tag.begin.html - - 2 - - name - entity.name.tag.other.html - - - end - (>) - endCaptures - - 1 - - name - punctuation.definition.tag.end.html - - - name - meta.tag.other.html - patterns - - - include - #tag-stuff - - - - - include - #entities - - - match - <> - name - invalid.illegal.incomplete.html - - - match - < - name - invalid.illegal.bad-angle-bracket.html - - - repository - - entities - - patterns - - - captures - - 1 - - name - punctuation.definition.entity.html - - 3 - - name - punctuation.definition.entity.html - - - match - (&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;) - name - constant.character.entity.html - - - match - & - name - invalid.illegal.bad-ampersand.html - - - - string-double-quoted - - begin - " - beginCaptures - - 0 - - name - punctuation.definition.string.begin.html - - - end - " - endCaptures - - 0 - - name - punctuation.definition.string.end.html - - - name - string.quoted.double.html - patterns - - - include - #vue-interpolations - - - include - #entities - - - - string-single-quoted - - begin - ' - beginCaptures - - 0 - - name - punctuation.definition.string.begin.html - - - end - ' - endCaptures - - 0 - - name - punctuation.definition.string.end.html - - - name - string.quoted.single.html - patterns - - - include - #vue-interpolations - - - include - #entities - - - - tag-generic-attribute - - match - \b([a-zA-Z\-:]+) - name - entity.other.attribute-name.html - - tag-id-attribute - - begin - \b(id)\b\s*(=) - captures - - 1 - - name - entity.other.attribute-name.id.html - - 2 - - name - punctuation.separator.key-value.html - - - end - (?<='|") - name - meta.attribute-with-value.id.html - patterns - - - begin - " - beginCaptures - - 0 - - name - punctuation.definition.string.begin.html - - - contentName - meta.toc-list.id.html - end - " - endCaptures - - 0 - - name - punctuation.definition.string.end.html - - - name - string.quoted.double.html - patterns - - - include - #vue-interpolations - - - include - #entities - - - - - begin - ' - beginCaptures - - 0 - - name - punctuation.definition.string.begin.html - - - contentName - meta.toc-list.id.html - end - ' - endCaptures - - 0 - - name - punctuation.definition.string.end.html - - - name - string.quoted.single.html - patterns - - - include - #vue-interpolations - - - include - #entities - - - - - - tag-stuff - - patterns - - - include - #vue-directives - - - include - #tag-id-attribute - - - include - #tag-generic-attribute - - - include - #string-double-quoted - - - include - #string-single-quoted - - - - vue-directives - - begin - (?:\b(v-)|(:|@))([a-zA-Z\-]+)(?:\:([a-zA-Z\-]+))?(?:\.([a-zA-Z\-]+))*\s*(=) - captures - - 1 - - name - entity.other.attribute-name.html - - 2 - - name - punctuation.separator.key-value.html - - 3 - - name - entity.other.attribute-name.html - - 4 - - name - entity.other.attribute-name.html - - 5 - - name - entity.other.attribute-name.html - - 6 - - name - punctuation.separator.key-value.html - - - end - (?<='|") - name - meta.directive.vue - patterns - - - begin - " - beginCaptures - - 0 - - name - punctuation.definition.string.begin.html - - - end - " - endCaptures - - 0 - - name - punctuation.definition.string.end.html - - - name - source.directive.vue - patterns - - - include - source.js - - - - - begin - ' - beginCaptures - - 0 - - name - punctuation.definition.string.begin.html - - - end - ' - endCaptures - - 0 - - name - punctuation.definition.string.end.html - - - name - source.directive.vue - patterns - - - include - source.js - - - - - - vue-interpolations - - patterns - - - begin - \{\{\{? - beginCaptures - - 0 - - name - punctuation.definition.generic.begin.html - - - end - \}\}\}? - endCaptures - - 0 - - name - punctuation.definition.generic.end.html - - - name - expression.embbeded.vue - patterns - - - include - source.js - - - - - - - scopeName - text.html.vue - uuid - 5512c10d-4cc5-434c-b8fc-53b912f55ab3 - - From 5090eb647f50538efc9016cfd3d9ef4238209aef Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 15 Dec 2017 10:38:43 -0500 Subject: [PATCH 02/62] fix: embed lang="scss" as source.sass as well --- Vue Component.sublime-syntax | 3 ++- Vue Component.sublime-syntax.yaml-macros | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index c2309c0..f18e13a 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -678,7 +678,7 @@ contexts: - match: (>) captures: 1: meta.tag.style.begin.html punctuation.definition.tag.end.html - embed: scope:source.scss + embed: scope:source.sass escape: (?i)(?=) pop: true - include: tag-attributes + hidden: false diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index 1dfb9cc..c8c6a09 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -219,7 +219,7 @@ contexts: !merge - match: '(>)' captures: 1: meta.tag.style.begin.html punctuation.definition.tag.end.html - embed: scope:source.scss + embed: scope:source.sass escape: (?i)(?=)' pop: true - include: tag-attributes - \ No newline at end of file + From e9799bfc32f794c6efa65464e496b726e8e93387 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 15 Dec 2017 10:39:06 -0500 Subject: [PATCH 03/62] edit samples --- samples/arrow.vue | 3 +-- samples/jsx.vue | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 samples/jsx.vue diff --git a/samples/arrow.vue b/samples/arrow.vue index 29d0a6b..4ff74cb 100644 --- a/samples/arrow.vue +++ b/samples/arrow.vue @@ -1,6 +1,5 @@ tag + (?: (\s*) (-->) \s* )? (?=) \s* $ + ) + contexts: main: - meta_prepend: true @@ -73,13 +115,48 @@ contexts: escape: "'" escape_captures: 0: meta.string.html string.quoted.single.html punctuation.definition.string.end.html - - include: else-pop + style-close-tag: + # for compatibility with ST builds before 4114 + - match: (' + scope: punctuation.definition.tag.end.html + set: + - style-close-tag + - style-css-content + + 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 @@ -101,11 +178,19 @@ contexts: - match: '>' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - embed_scope: source.sass.embedded.html - match: '' - embed: scope:source.sass - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - embed_scope: source.scss.embedded.html - match: '' - embed: scope:source.scss - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - embed_scope: source.stylus.embedded.html - match: '' - embed: scope:source.stylus - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - embed_scope: source.sss.embedded.html - match: '' - embed: scope:source.sss - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - embed_scope: source.postcss.embedded.html - match: '' - embed: scope:source.postcss - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - embed_scope: source.less.embedded.html - match: '' - embed: scope:source.less - escape: (?i)(?=(?:-->\s*)?' + scope: punctuation.definition.tag.end.html + set: + - script-close-tag + - script-javascript-content + script-javascript-content: - - match: (?=\S) + # 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_close_lookahead}}' + 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}} @@ -215,11 +370,19 @@ contexts: - match: '>' scope: punctuation.definition.tag.end.html set: - - include: script-close-tag - - embed_scope: source.coffee.embedded.html - match: '' - embed: scope:source.coffee - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: script-close-tag - - embed_scope: source.livescript.embedded.html - match: '' - embed: scope:source.livescript - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: script-close-tag - - embed_scope: source.ts.embedded.html - match: '' - embed: scope:source.ts - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: template-close-tag - - embed_scope: text.jade.embedded.html - match: '' - embed: scope:text.jade - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: template-close-tag - - embed_scope: text.pug.embedded.html - match: '' - embed: scope:text.pug - escape: (?i)(?=(?:-->\s*)?' scope: punctuation.definition.tag.end.html set: - - include: template-close-tag - - embed_scope: text.slm.embedded.html - match: '' - embed: scope:text.slm - escape: (?i)(?=(?:-->\s*)? tag + (?: (\s*) (-->) \s* )? (?=) \s* $ + ) + style_content_begin: '{{script_content_begin}}' + style_content_end: |- + (?x: + # optional html comment end punctuation followed by tag + (?: (\s*) (-->) \s* )? (?=) \s* $ + ) + template_content_begin: '{{script_content_begin}}' + template_content_end: |- + (?x: + # optional html comment end punctuation followed by tag + (?: (\s*) (-->) \s* )? (?=) \s* $ + ) + contexts: main: - meta_prepend: true @@ -82,13 +124,48 @@ contexts: 0: meta.string.html string.quoted.single.html punctuation.definition.string.end.html - - include: else-pop + style-close-tag: + # for compatibility with ST builds before 4114 + - match: (' + scope: punctuation.definition.tag.end.html + set: + - style-close-tag + - style-css-content + + 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 @@ -115,15 +192,45 @@ contexts: - tag-generic-attribute-meta - tag-generic-attribute-value + script-close-tag: + # for compatibility with ST builds before 4114 + - match: (' + scope: punctuation.definition.tag.end.html + set: + - script-close-tag + - script-javascript-content + script-javascript-content: - - match: (?=\S) + # 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_close_lookahead}}' + 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}} diff --git a/src/macros.py b/src/macros.py index cac2f31..4674d24 100644 --- a/src/macros.py +++ b/src/macros.py @@ -20,13 +20,27 @@ def embed_language_in_tag(tag, match, embed): match='>', scope='punctuation.definition.tag.end.html', set=[ - _rule(include='%s-close-tag' % tag), - _rule( - match=r'', - embed=('scope:%s' % embed), - embed_scope=('%s.embedded.html' % embed), - escape=r'(?i)(?=(?:-->\s*)? Date: Wed, 8 Sep 2021 18:15:20 +0200 Subject: [PATCH 34/62] Add tests for script/style tags --- tests/syntax_test_script.vue | 200 +++++++++++++++++++++++++++++ tests/syntax_test_style.vue | 240 +++++++++++++++++++++++++++++++++++ 2 files changed, 440 insertions(+) create mode 100644 tests/syntax_test_script.vue create mode 100644 tests/syntax_test_style.vue diff --git a/tests/syntax_test_script.vue b/tests/syntax_test_script.vue new file mode 100644 index 0000000..be81601 --- /dev/null +++ b/tests/syntax_test_script.vue @@ -0,0 +1,200 @@ +// SYNTAX TEST "Packages/Vue/Vue Component.sublime-syntax" + + + +// ^^^^^^^^ meta.tag - source +// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag +// ^^^^^^^^^ meta.tag - source + + +// ^^^^^^^^ meta.tag - source +// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag +// ^^^^ - meta.tag - source +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^^^^^^^^ meta.tag - source + + +// ^^^^^^^^ meta.tag - source +// ^^^^^ - meta.tag - source +// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag +// ^^^^^^^^^ meta.tag - source +// ^^^^ punctuation.definition.comment.begin.html + + +// ^^^^^^^^ meta.tag - source +// ^^^^^ - meta.tag - source +// ^^^^ punctuation.definition.comment.begin.html +// ^^^^^^^^^^^^ source.js.embedded.html - meta.tag +// ^^^^ - meta.tag - source +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^^^^^^^^ meta.tag - source + + + +// <- source.js.embedded.html - source source +// ^ source.js.embedded.html - source source +// ^^^^^^^^^ meta.tag - source + + + +// ^^^^^^^^^ meta.tag - source + + + +// ^ source.js.embedded.html - source source +// ^^^^^^^^^^^^^^ - source +// ^ - meta.tag - comment +// ^^^^^^^^^ meta.tag +// ^ - meta.tag +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^ punctuation.definition.tag.begin.html +// ^^^^^^ entity.name.tag +// ^ punctuation.definition.tag.end.html + + + +// ^ source.js.embedded.html - source source +// ^^^^^^^^^^^^^^ - source +// ^ - meta.tag - comment +// ^^^^^^^^^ meta.tag +// ^ - meta.tag +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^ punctuation.definition.tag.begin.html +// ^^^^^^ entity.name.tag +// ^ punctuation.definition.tag.end.html + + + +// <- source.js.embedded.html - source source +// ^ source.js.embedded.html - source source +// ^^^^^^^^^ meta.tag - source + + + +// <- source.coffee.embedded.html - source source +//^^ source.coffee.embedded.html - source source +// ^^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^^ meta.tag - source + + + +// <- source.livescript.embedded.html - source source +//^^ source.livescript.embedded.html - source source +// ^^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^^ meta.tag - source + + + +// <- source.ts.embedded.html - source source +//^^ source.ts.embedded.html - source source +// ^^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^^ meta.tag - source diff --git a/tests/syntax_test_style.vue b/tests/syntax_test_style.vue new file mode 100644 index 0000000..b7f3d8f --- /dev/null +++ b/tests/syntax_test_style.vue @@ -0,0 +1,240 @@ +// SYNTAX TEST "Packages/Vue/Vue Component.sublime-syntax" + + + +// ^^^^^^^ meta.tag - source +// ^^^^^^^ source.css.embedded.html - meta.tag +// ^^^^^^^^ meta.tag - source + + +// ^^^^^^^ meta.tag - source +// ^^^^^^^ source.css.embedded.html - meta.tag +// ^^^^ - meta.tag - source +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^^^^^^^ meta.tag - source + + +// ^^^^^^^ meta.tag - source +// ^^^^^ - meta.tag - source +// ^^^^^^^ source.css.embedded.html - meta.tag +// ^^^^^^^^ meta.tag - source +// ^^^^ punctuation.definition.comment.begin.html + + +// ^^^^^^^ meta.tag - source +// ^^^^^ - meta.tag - source +// ^^^^ punctuation.definition.comment.begin.html +// ^^^^^^^ source.css.embedded.html - meta.tag +// ^^^^ - meta.tag - source +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^^^^^^^ meta.tag - source + + + +// <- source.css.embedded.html - source source +// ^ source.css.embedded.html - source source +// ^^^^^^^^ meta.tag - source + + + +// ^^^^^^^^ meta.tag - source + + + +// ^ source.css.embedded.html - source source +// ^^^^^^^^^^^^^ - source +// ^ - meta.tag - comment +// ^^^^^^^^ meta.tag +// ^ - meta.tag +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^ punctuation.definition.tag.begin.html +// ^^^^^ entity.name.tag +// ^ punctuation.definition.tag.end.html + + + +// ^ source.css.embedded.html - source source +// ^^^^^^^^^^^^^ - source +// ^ - meta.tag - comment +// ^^^^^^^^ meta.tag +// ^ - meta.tag +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^ punctuation.definition.tag.begin.html +// ^^^^^ entity.name.tag +// ^ punctuation.definition.tag.end.html + + + +// <- source.css.embedded.html - source source +// ^ source.css.embedded.html - source source +// ^^^^^^^^ meta.tag - source + + + +// <- source.less.embedded.html - source source +//^^ source.less.embedded.html - source source +// ^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^ meta.tag - source + + + +// <- source.postcss.embedded.html - source source +//^^ source.postcss.embedded.html - source source +// ^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^ meta.tag - source + + + +// <- source.sss.embedded.html - source source +//^^ source.sss.embedded.html - source source +// ^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^ meta.tag - source + + + +// <- source.sass.embedded.html - source source +//^^ source.sass.embedded.html - source source +// ^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^ meta.tag - source + + + +// <- source.scss.embedded.html - source source +//^^ source.scss.embedded.html - source source +// ^^^^^^^^ meta.tag - source + + +// <- - source - comment - meta.tag +//^^ - source - comment - meta.tag +// ^^^^^^^^ meta.tag - source From e61f3b3d0cd0aaffd7fe0c35d20428f7d7b6143a Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 8 Sep 2021 18:51:01 +0200 Subject: [PATCH 35/62] Add Github Actions for automated syntax tests --- .github/workflows/ci-syntax-tests.yml | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/ci-syntax-tests.yml diff --git a/.github/workflows/ci-syntax-tests.yml b/.github/workflows/ci-syntax-tests.yml new file mode 100644 index 0000000..bf8afc1 --- /dev/null +++ b/.github/workflows/ci-syntax-tests.yml @@ -0,0 +1,38 @@ +name: CI Syntax Tests + +on: + push: + branches: + - 'master' + paths: + - '.github/workflows/ci-syntax-tests.yml' + - '**.sublime-syntax' + - '**/syntax_test_*' + - '**.tmPreferences' + pull_request: + branches: + - '**' + paths: + - '.github/workflows/ci-syntax-tests.yml' + - '**.sublime-syntax' + - '**/syntax_test_*' + - '**.tmPreferences' + workflow_dispatch: + +jobs: + syntax_tests: + name: Sublime Text ${{ matrix.build }} + strategy: + matrix: + include: + - build: 4107 + packages: a147e3eb6210de480d0d9a6bd6bf54931a8ba7e9 + - build: latest + packages: master + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: SublimeText/syntax-test-action@v2 + with: + build: ${{ matrix.build }} + default_packages: ${{ matrix.packages }} From a97625d191dfaff60c95f3f62e8361e676c79f10 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 8 Sep 2021 19:41:59 +0200 Subject: [PATCH 36/62] Fix meta.tag and meta.attribute-with-value scope boundaries This commit adds another fix introduced with ST4114, which addresses the mentioned meta scopes not being applied correctly. They were missing at attribute assignment operators and closing `>` sign. --- Vue Component.sublime-syntax | 78 ++++++++++++------------ Vue Component.sublime-syntax.yaml-macros | 6 +- src/macros.py | 2 +- tests/syntax_test_script.vue | 6 ++ tests/syntax_test_style.vue | 7 +++ 5 files changed, 56 insertions(+), 43 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 89dc5e7..6c464ca 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -165,7 +165,7 @@ contexts: - match: = scope: punctuation.separator.key-value.html set: - - meta_content_scope: meta.tag.style.begin.html meta.attribute-with-value.html + - meta_scope: meta.tag.style.begin.html meta.attribute-with-value.html - include: style-lang-decider - match: (?=\S) set: style-css @@ -173,19 +173,19 @@ contexts: style-lang-decider: - match: (?i)(?=sass{{unquoted_attribute_break}}|\'sass\'|"sass") set: - - - meta_content_scope: meta.tag.style.begin.html + - - meta_scope: meta.tag.style.begin.html - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - - match: '{{style_content_begin}}' + - - embed_scope: source.sass.embedded.html escape_captures: 1: source.sass.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.sass.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.sass.embedded.html + match: '{{style_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -195,19 +195,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=scss{{unquoted_attribute_break}}|\'scss\'|"scss") set: - - - meta_content_scope: meta.tag.style.begin.html + - - meta_scope: meta.tag.style.begin.html - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - - match: '{{style_content_begin}}' + - - embed_scope: source.scss.embedded.html escape_captures: 1: source.scss.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.scss.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.scss.embedded.html + match: '{{style_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -217,19 +217,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=stylus{{unquoted_attribute_break}}|\'stylus\'|"stylus") set: - - - meta_content_scope: meta.tag.style.begin.html + - - meta_scope: meta.tag.style.begin.html - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - - match: '{{style_content_begin}}' + - - embed_scope: source.stylus.embedded.html escape_captures: 1: source.stylus.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.stylus.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.stylus.embedded.html + match: '{{style_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -239,19 +239,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=postcss\?parser=sugarss{{unquoted_attribute_break}}|\'postcss\?parser=sugarss\'|"postcss\?parser=sugarss") set: - - - meta_content_scope: meta.tag.style.begin.html + - - meta_scope: meta.tag.style.begin.html - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - - match: '{{style_content_begin}}' + - - embed_scope: source.sss.embedded.html escape_captures: 1: source.sss.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.sss.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.sss.embedded.html + match: '{{style_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -261,19 +261,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=postcss{{unquoted_attribute_break}}|\'postcss\'|"postcss") set: - - - meta_content_scope: meta.tag.style.begin.html + - - meta_scope: meta.tag.style.begin.html - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - - match: '{{style_content_begin}}' + - - embed_scope: source.postcss.embedded.html escape_captures: 1: source.postcss.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.postcss.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.postcss.embedded.html + match: '{{style_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -283,19 +283,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=less{{unquoted_attribute_break}}|\'less\'|"less") set: - - - meta_content_scope: meta.tag.style.begin.html + - - meta_scope: meta.tag.style.begin.html - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: style-close-tag - - - match: '{{style_content_begin}}' + - - embed_scope: source.less.embedded.html escape_captures: 1: source.less.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.less.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.less.embedded.html + match: '{{style_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -357,7 +357,7 @@ contexts: - match: = scope: punctuation.separator.key-value.html set: - - meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.html + - meta_scope: meta.tag.script.begin.html meta.attribute-with-value.html - include: script-lang-decider - match: (?=\S) set: script-javascript @@ -365,19 +365,19 @@ contexts: script-lang-decider: - match: (?i)(?=coffee{{unquoted_attribute_break}}|\'coffee\'|"coffee") set: - - - meta_content_scope: meta.tag.script.begin.html + - - meta_scope: meta.tag.script.begin.html - include: script-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: script-close-tag - - - match: '{{script_content_begin}}' + - - embed_scope: source.coffee.embedded.html escape_captures: 1: source.coffee.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.coffee.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.coffee.embedded.html + match: '{{script_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -387,19 +387,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=livescript{{unquoted_attribute_break}}|\'livescript\'|"livescript") set: - - - meta_content_scope: meta.tag.script.begin.html + - - meta_scope: meta.tag.script.begin.html - include: script-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: script-close-tag - - - match: '{{script_content_begin}}' + - - embed_scope: source.livescript.embedded.html escape_captures: 1: source.livescript.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.livescript.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.livescript.embedded.html + match: '{{script_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -409,19 +409,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=ts{{unquoted_attribute_break}}|\'ts\'|"ts") set: - - - meta_content_scope: meta.tag.script.begin.html + - - meta_scope: meta.tag.script.begin.html - include: script-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: script-close-tag - - - match: '{{script_content_begin}}' + - - embed_scope: source.ts.embedded.html escape_captures: 1: source.ts.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: source.ts.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: source.ts.embedded.html + match: '{{script_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -469,7 +469,7 @@ contexts: - match: = scope: punctuation.separator.key-value.html set: - - meta_content_scope: meta.tag.template.begin.html meta.attribute-with-value.html + - meta_scope: meta.tag.template.begin.html meta.attribute-with-value.html - include: template-lang-decider - match: (?=\S) set: template-mustache @@ -477,19 +477,19 @@ contexts: template-lang-decider: - match: (?i)(?=jade{{unquoted_attribute_break}}|\'jade\'|"jade") set: - - - meta_content_scope: meta.tag.template.begin.html + - - meta_scope: meta.tag.template.begin.html - include: template-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: template-close-tag - - - match: '{{template_content_begin}}' + - - embed_scope: text.jade.embedded.html 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 - embed_scope: text.jade.embedded.html + match: '{{template_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -499,19 +499,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=pug{{unquoted_attribute_break}}|\'pug\'|"pug") set: - - - meta_content_scope: meta.tag.template.begin.html + - - meta_scope: meta.tag.template.begin.html - include: template-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: template-close-tag - - - match: '{{template_content_begin}}' + - - embed_scope: text.pug.embedded.html 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 - embed_scope: text.pug.embedded.html + match: '{{template_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 @@ -521,19 +521,19 @@ contexts: - tag-generic-attribute-value - match: (?i)(?=slm{{unquoted_attribute_break}}|\'slm\'|"slm") set: - - - meta_content_scope: meta.tag.template.begin.html + - - meta_scope: meta.tag.template.begin.html - include: template-common - match: '>' scope: punctuation.definition.tag.end.html set: - - include: template-close-tag - - - match: '{{template_content_begin}}' + - - embed_scope: text.slm.embedded.html escape_captures: 1: text.slm.embedded.html 2: comment.block.html punctuation.definition.comment.end.html 3: text.slm.embedded.html 4: comment.block.html punctuation.definition.comment.end.html - embed_scope: text.slm.embedded.html + match: '{{template_content_begin}}' captures: 1: comment.block.html punctuation.definition.comment.begin.html pop: 1 diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index e9193ba..3eaa0fe 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -174,7 +174,7 @@ contexts: - match: = scope: punctuation.separator.key-value.html set: - - meta_content_scope: meta.tag.style.begin.html meta.attribute-with-value.html + - meta_scope: meta.tag.style.begin.html meta.attribute-with-value.html - include: style-lang-decider - match: (?=\S) set: style-css @@ -240,7 +240,7 @@ contexts: - match: = scope: punctuation.separator.key-value.html set: - - meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.html + - meta_scope: meta.tag.script.begin.html meta.attribute-with-value.html - include: script-lang-decider - match: (?=\S) set: script-javascript @@ -289,7 +289,7 @@ contexts: - match: = scope: punctuation.separator.key-value.html set: - - meta_content_scope: meta.tag.template.begin.html meta.attribute-with-value.html + - meta_scope: meta.tag.template.begin.html meta.attribute-with-value.html - include: template-lang-decider - match: (?=\S) set: template-mustache diff --git a/src/macros.py b/src/macros.py index 4674d24..3f727a6 100644 --- a/src/macros.py +++ b/src/macros.py @@ -14,7 +14,7 @@ def embed_language_in_tag(tag, match, embed): match=r'(?i)(?={0}{{{{unquoted_attribute_break}}}}|\'{0}\'|"{0}")'.format(match), set=[ [ - _rule(meta_content_scope='meta.tag.%s.begin.html' % tag), + _rule(meta_scope='meta.tag.%s.begin.html' % tag), _rule(include='%s-common' % tag), _rule( match='>', diff --git a/tests/syntax_test_script.vue b/tests/syntax_test_script.vue index be81601..ef50d4b 100644 --- a/tests/syntax_test_script.vue +++ b/tests/syntax_test_script.vue @@ -131,6 +131,12 @@ // ^^^^^^^^^ meta.tag - source + +// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag - meta.tag meta.tag - source +// ^^^^^^^^^^^^^ meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value +// ^^ source.coffee.embedded.html - meta.tag +// ^^^^^^^^^ meta.tag - source + +// ^^^^^^^^^ meta.tag.script.end.html // ^^^^^^^^ meta.tag - source diff --git a/tests/syntax_test_style.vue b/tests/syntax_test_style.vue index 8b88d44..55d19c0 100644 --- a/tests/syntax_test_style.vue +++ b/tests/syntax_test_style.vue @@ -1,5 +1,7 @@ // SYNTAX TEST "Vue Component.sublime-syntax" + +// ^^^^^^^^ meta.tag.style.end.html // ^^^^^^^ meta.tag - source diff --git a/tests/syntax_test_template.vue b/tests/syntax_test_template.vue index 2be75fe..0035c86 100644 --- a/tests/syntax_test_template.vue +++ b/tests/syntax_test_template.vue @@ -8,6 +8,9 @@ // <- text.html.vue - text text // ^^^^^^^^^^^ meta.tag.template.end.html + +// <- text.html.vue - text text +// ^^^^^^^^^^^ meta.tag.template.end.html // ^^^^^^^^^^^^^^^^^^^^^^ meta.tag - source From d1e13d957f0121f0665670a52c5ab1745591b5ee Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 9 Sep 2021 18:47:23 +0200 Subject: [PATCH 48/62] Reorganize context/section order This commit just moves sections/contexts around. It doesn't change behavior. The goal is to end up with the same order as HTML.sublime-syntax which uses a top-down-order. 1. managing contexts 2. tag contexts 3. attribute contexts 4. other reusable contexts 5. prototypes --- Vue Component.sublime-syntax | 406 +++++++++++------------ Vue Component.sublime-syntax.yaml-macros | 310 ++++++++--------- 2 files changed, 358 insertions(+), 358 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 01c3990..8deb773 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -63,87 +63,140 @@ contexts: - include: style-tag - include: template-tag -###[ TAG ATTRIBUTES ]######################################################### +###[ SCRIPT TAG ]############################################################# - tag-attributes: - - meta_prepend: true - - include: vue-directive + 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: (' + scope: punctuation.definition.tag.end.html + set: script-javascript-content - mustache-templates: - - match: '{{' - scope: meta.template.vue punctuation.definition.template.begin.html + 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: meta.template.vue source.js.embedded.vue - escape: '}}' + embed_scope: source.js.embedded.html + escape: '{{script_content_end}}' escape_captures: - 0: meta.template.vue punctuation.definition.template.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 + 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 - vue-directive-meta: - - meta_include_prototype: false - - meta_scope: meta.attribute-with-value.directive.html - - include: immediately-pop + 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 - vue-directive-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: vue-directive-value - - include: else-pop + set: script-lang-attribute-value + - match: (?=\S) + set: script-javascript - vue-directive-value: - - match: \" - scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html - pop: true - embed: scope:source.js - embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html - 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 - pop: true - embed: scope:source.js - embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html - 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 + 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: + - match: (?i)(?=coffee{{unquoted_attribute_break}}|\'coffee\'|"coffee") + set: + - - meta_scope: meta.tag.script.begin.html + - include: script-common + - match: '>' + scope: punctuation.definition.tag.end.html + set: + - embed_scope: source.coffee.embedded.html + match: '{{script_content_begin}}' + escape_captures: + 1: source.coffee.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.coffee.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 + embed: scope:source.coffee + escape: '{{script_content_end}}' + - tag-generic-attribute-meta + - tag-generic-attribute-value + - match: (?i)(?=livescript{{unquoted_attribute_break}}|\'livescript\'|"livescript") + set: + - - meta_scope: meta.tag.script.begin.html + - include: script-common + - match: '>' + scope: punctuation.definition.tag.end.html + set: + - embed_scope: source.livescript.embedded.html + match: '{{script_content_begin}}' + escape_captures: + 1: source.livescript.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.livescript.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 + embed: scope:source.livescript + escape: '{{script_content_end}}' + - tag-generic-attribute-meta + - tag-generic-attribute-value + - match: (?i)(?=ts{{unquoted_attribute_break}}|\'ts\'|"ts") + set: + - - meta_scope: meta.tag.script.begin.html + - include: script-common + - match: '>' + scope: punctuation.definition.tag.end.html + set: + - embed_scope: source.ts.embedded.html + match: '{{script_content_begin}}' + escape_captures: + 1: source.ts.embedded.html + 2: comment.block.html punctuation.definition.comment.end.html + 3: source.ts.embedded.html + 4: comment.block.html punctuation.definition.comment.end.html + captures: + 1: comment.block.html punctuation.definition.comment.begin.html + pop: 1 + embed: scope:source.ts + escape: '{{script_content_end}}' + - tag-generic-attribute-meta + - tag-generic-attribute-value + - match: (?=\S) + set: + - script-javascript + - tag-generic-attribute-meta + - tag-generic-attribute-value ###[ STYLE TAG ]############################################################## @@ -343,141 +396,6 @@ contexts: - tag-generic-attribute-meta - tag-generic-attribute-value -###[ 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: (' - scope: punctuation.definition.tag.end.html - set: script-javascript-content - - 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: - - match: (?i)(?=coffee{{unquoted_attribute_break}}|\'coffee\'|"coffee") - set: - - - meta_scope: meta.tag.script.begin.html - - include: script-common - - match: '>' - scope: punctuation.definition.tag.end.html - set: - - embed_scope: source.coffee.embedded.html - match: '{{script_content_begin}}' - escape_captures: - 1: source.coffee.embedded.html - 2: comment.block.html punctuation.definition.comment.end.html - 3: source.coffee.embedded.html - 4: comment.block.html punctuation.definition.comment.end.html - captures: - 1: comment.block.html punctuation.definition.comment.begin.html - pop: 1 - embed: scope:source.coffee - escape: '{{script_content_end}}' - - tag-generic-attribute-meta - - tag-generic-attribute-value - - match: (?i)(?=livescript{{unquoted_attribute_break}}|\'livescript\'|"livescript") - set: - - - meta_scope: meta.tag.script.begin.html - - include: script-common - - match: '>' - scope: punctuation.definition.tag.end.html - set: - - embed_scope: source.livescript.embedded.html - match: '{{script_content_begin}}' - escape_captures: - 1: source.livescript.embedded.html - 2: comment.block.html punctuation.definition.comment.end.html - 3: source.livescript.embedded.html - 4: comment.block.html punctuation.definition.comment.end.html - captures: - 1: comment.block.html punctuation.definition.comment.begin.html - pop: 1 - embed: scope:source.livescript - escape: '{{script_content_end}}' - - tag-generic-attribute-meta - - tag-generic-attribute-value - - match: (?i)(?=ts{{unquoted_attribute_break}}|\'ts\'|"ts") - set: - - - meta_scope: meta.tag.script.begin.html - - include: script-common - - match: '>' - scope: punctuation.definition.tag.end.html - set: - - embed_scope: source.ts.embedded.html - match: '{{script_content_begin}}' - escape_captures: - 1: source.ts.embedded.html - 2: comment.block.html punctuation.definition.comment.end.html - 3: source.ts.embedded.html - 4: comment.block.html punctuation.definition.comment.end.html - captures: - 1: comment.block.html punctuation.definition.comment.begin.html - pop: 1 - embed: scope:source.ts - escape: '{{script_content_end}}' - - tag-generic-attribute-meta - - tag-generic-attribute-value - - match: (?=\S) - set: - - script-javascript - - tag-generic-attribute-meta - - tag-generic-attribute-value - ###[ TEMPLATE TAG ]########################################################### template-tag: @@ -596,3 +514,85 @@ contexts: - template-mustache - tag-generic-attribute-meta - tag-generic-attribute-value + +###[ TAG ATTRIBUTES ]######################################################### + + tag-attributes: + - meta_prepend: true + - include: vue-directive + + 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 + - meta_scope: meta.interpolation.html + - include: mustache-templates + - include: immediately-pop + + mustache-templates: + - match: '{{' + scope: meta.template.vue punctuation.definition.template.begin.html + embed: scope:source.js + embed_scope: meta.template.vue source.js.embedded.vue + escape: '}}' + escape_captures: + 0: meta.template.vue punctuation.definition.template.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 + pop: true + embed: scope:source.js + embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html + 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 + pop: true + embed: scope:source.js + embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html + 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 diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index c810d08..1025365 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -64,99 +64,80 @@ contexts: - include: style-tag - include: template-tag -###[ TAG ATTRIBUTES ]######################################################### +###[ SCRIPT TAG ]############################################################# - tag-attributes: - - meta_prepend: true - - include: vue-directive + 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: (' + scope: punctuation.definition.tag.end.html + set: script-javascript-content - mustache-templates: - - match: '{{' - scope: meta.template.vue punctuation.definition.template.begin.html + 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: meta.template.vue source.js.embedded.vue - escape: '}}' + embed_scope: source.js.embedded.html + escape: '{{script_content_end}}' escape_captures: - 0: meta.template.vue punctuation.definition.template.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 + 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 - vue-directive-meta: - - meta_include_prototype: false - - meta_scope: meta.attribute-with-value.directive.html - - include: immediately-pop + 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 - vue-directive-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: vue-directive-value - - include: else-pop + set: script-lang-attribute-value + - match: (?=\S) + set: script-javascript - vue-directive-value: - - match: \" - scope: - meta.string.html string.quoted.double.html - punctuation.definition.string.begin.html - pop: true - embed: scope:source.js - embed_scope: - meta.string.html meta.interpolation.html - source.js.embedded.html - 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 - pop: true - embed: scope:source.js - embed_scope: - meta.string.html meta.interpolation.html - source.js.embedded.html - 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 + 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 ]############################################################## @@ -236,81 +217,6 @@ contexts: - tag-generic-attribute-meta - tag-generic-attribute-value -###[ 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: (' - scope: punctuation.definition.tag.end.html - set: script-javascript-content - - 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 - ###[ TEMPLATE TAG ]########################################################### template-tag: @@ -369,3 +275,97 @@ contexts: - template-mustache - tag-generic-attribute-meta - tag-generic-attribute-value + +###[ TAG ATTRIBUTES ]######################################################### + + tag-attributes: + - meta_prepend: true + - include: vue-directive + + 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 + - meta_scope: meta.interpolation.html + - include: mustache-templates + - include: immediately-pop + + mustache-templates: + - match: '{{' + scope: meta.template.vue punctuation.definition.template.begin.html + embed: scope:source.js + embed_scope: meta.template.vue source.js.embedded.vue + escape: '}}' + escape_captures: + 0: meta.template.vue punctuation.definition.template.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 + pop: true + embed: scope:source.js + embed_scope: + meta.string.html meta.interpolation.html + source.js.embedded.html + 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 + pop: true + embed: scope:source.js + embed_scope: + meta.string.html meta.interpolation.html + source.js.embedded.html + 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 From fc69ac1ebd2e78abfa8bbb701bfcfe9f1d4131a3 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 9 Sep 2021 19:01:38 +0200 Subject: [PATCH 49/62] Reorganize syntax header applies https://github.com/sublimehq/Packages/issues/2430 --- Vue Component.sublime-syntax | 6 ++++-- Vue Component.sublime-syntax.yaml-macros | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 8deb773..237a2fc 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -1,9 +1,11 @@ %YAML 1.2 --- -extends: Packages/HTML/HTML.sublime-syntax name: Vue Component -version: 2 scope: text.html.vue +version: 2 + +extends: Packages/HTML/HTML.sublime-syntax + file_extensions: - vue diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index 1025365..328a526 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -1,10 +1,12 @@ %YAML 1.2 %TAG ! tag:yaml-macros:src.macros: --- -extends: Packages/HTML/HTML.sublime-syntax name: Vue Component -version: 2 scope: text.html.vue +version: 2 + +extends: Packages/HTML/HTML.sublime-syntax + file_extensions: - vue From 634c637e5289c6a2bba2e30b93903897fc112d44 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 9 Sep 2021 19:03:16 +0200 Subject: [PATCH 50/62] Replace remaining pop: true by pop: 1 All sublime-syntax version 2 files should use explicit `pop: 1` instead of `pop: true`. It looks more consistent in case `pop: 2` are used. --- Vue Component.sublime-syntax | 4 ++-- Vue Component.sublime-syntax.yaml-macros | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 237a2fc..5b2e8de 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -581,7 +581,7 @@ contexts: vue-directive-value: - match: \" scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html - pop: true + pop: 1 embed: scope:source.js embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html escape: \" @@ -590,7 +590,7 @@ contexts: punctuation.definition.string.end.html - match: \' scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html - pop: true + pop: 1 embed: scope:source.js embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html escape: \' diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index 328a526..f2c5593 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -344,7 +344,7 @@ contexts: scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html - pop: true + pop: 1 embed: scope:source.js embed_scope: meta.string.html meta.interpolation.html @@ -359,7 +359,7 @@ contexts: scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html - pop: true + pop: 1 embed: scope:source.js embed_scope: meta.string.html meta.interpolation.html From 73cc77c7e564a55f60eec7cba47c14819914d966 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 9 Sep 2021 19:07:26 +0200 Subject: [PATCH 51/62] Reuse tag-end context No need to duplicate the match directive if it already exists. --- Vue Component.sublime-syntax | 4 +--- Vue Component.sublime-syntax.yaml-macros | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 5b2e8de..9ac8971 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -425,9 +425,7 @@ contexts: template-mustache: - meta_scope: meta.tag.template.begin.html - include: template-common - - match: '>' - scope: punctuation.definition.tag.end.html - pop: 1 + - include: tag-end template-lang-attribute: - match: (?i:lang){{attribute_name_break}} diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index f2c5593..7bede0e 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -246,9 +246,7 @@ contexts: template-mustache: - meta_scope: meta.tag.template.begin.html - include: template-common - - match: '>' - scope: punctuation.definition.tag.end.html - pop: 1 + - include: tag-end template-lang-attribute: - match: (?i:lang){{attribute_name_break}} From c39dc1b9793ae6bcc87cc0195b761272b1686a5e Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 9 Sep 2021 19:56:54 +0200 Subject: [PATCH 52/62] Exclude prototypes from attribute value starts This commit fixes https://github.com/sublimehq/Packages/pull/2910 for all ST builds before 4114. --- Vue Component.sublime-syntax | 4 ++++ Vue Component.sublime-syntax.yaml-macros | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 9ac8971..0d0414c 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -521,6 +521,10 @@ contexts: - meta_prepend: true - include: vue-directive + tag-generic-attribute-value: + - meta_prepend: true + - meta_include_prototype: false + tag-attribute-value-content: - meta_prepend: true - include: mustache-interpolations diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index 7bede0e..65467cb 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -282,6 +282,26 @@ contexts: - 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 From 69e78bf1dd14d20673dab1fae932c7d8833d6900 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 2 Feb 2022 19:11:35 +0100 Subject: [PATCH 53/62] Prepare for future changes of ST's HTML.sublime-syntax ST's HTML.sublime-syntax may change in the future so that the change of this commit is required to maintain compatibility. It is planned to highlight certain self-closing tags illegal, if they are known not to support it. This change is backward compatible with older builds of ST4. --- Vue Component.sublime-syntax | 88 +++++++++++++++++++++--------------- src/macros.py | 2 +- 2 files changed, 53 insertions(+), 37 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 0d0414c..4a75593 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -134,12 +134,11 @@ contexts: - match: (?i)(?=coffee{{unquoted_attribute_break}}|\'coffee\'|"coffee") set: - - meta_scope: meta.tag.script.begin.html - - include: script-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.coffee.embedded.html - match: '{{script_content_begin}}' + - match: '{{script_content_begin}}' + embed_scope: source.coffee.embedded.html escape_captures: 1: source.coffee.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -150,17 +149,17 @@ contexts: pop: 1 embed: scope:source.coffee escape: '{{script_content_end}}' + - include: script-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=livescript{{unquoted_attribute_break}}|\'livescript\'|"livescript") set: - - meta_scope: meta.tag.script.begin.html - - include: script-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.livescript.embedded.html - match: '{{script_content_begin}}' + - match: '{{script_content_begin}}' + embed_scope: source.livescript.embedded.html escape_captures: 1: source.livescript.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -171,17 +170,17 @@ contexts: pop: 1 embed: scope:source.livescript escape: '{{script_content_end}}' + - include: script-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=ts{{unquoted_attribute_break}}|\'ts\'|"ts") set: - - meta_scope: meta.tag.script.begin.html - - include: script-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.ts.embedded.html - match: '{{script_content_begin}}' + - match: '{{script_content_begin}}' + embed_scope: source.ts.embedded.html escape_captures: 1: source.ts.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -192,6 +191,7 @@ contexts: pop: 1 embed: scope:source.ts escape: '{{script_content_end}}' + - include: script-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?=\S) @@ -269,12 +269,11 @@ contexts: - match: (?i)(?=sass{{unquoted_attribute_break}}|\'sass\'|"sass") set: - - meta_scope: meta.tag.style.begin.html - - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.sass.embedded.html - match: '{{style_content_begin}}' + - match: '{{style_content_begin}}' + embed_scope: source.sass.embedded.html escape_captures: 1: source.sass.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -285,17 +284,17 @@ contexts: pop: 1 embed: scope:source.sass escape: '{{style_content_end}}' + - include: style-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=scss{{unquoted_attribute_break}}|\'scss\'|"scss") set: - - meta_scope: meta.tag.style.begin.html - - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.scss.embedded.html - match: '{{style_content_begin}}' + - match: '{{style_content_begin}}' + embed_scope: source.scss.embedded.html escape_captures: 1: source.scss.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -306,17 +305,17 @@ contexts: pop: 1 embed: scope:source.scss escape: '{{style_content_end}}' + - include: style-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=stylus{{unquoted_attribute_break}}|\'stylus\'|"stylus") set: - - meta_scope: meta.tag.style.begin.html - - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.stylus.embedded.html - match: '{{style_content_begin}}' + - match: '{{style_content_begin}}' + embed_scope: source.stylus.embedded.html escape_captures: 1: source.stylus.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -327,17 +326,17 @@ contexts: pop: 1 embed: scope:source.stylus escape: '{{style_content_end}}' + - include: style-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=postcss\?parser=sugarss{{unquoted_attribute_break}}|\'postcss\?parser=sugarss\'|"postcss\?parser=sugarss") set: - - meta_scope: meta.tag.style.begin.html - - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.sss.embedded.html - match: '{{style_content_begin}}' + - match: '{{style_content_begin}}' + embed_scope: source.sss.embedded.html escape_captures: 1: source.sss.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -348,17 +347,17 @@ contexts: pop: 1 embed: scope:source.sss escape: '{{style_content_end}}' + - include: style-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=postcss{{unquoted_attribute_break}}|\'postcss\'|"postcss") set: - - meta_scope: meta.tag.style.begin.html - - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.postcss.embedded.html - match: '{{style_content_begin}}' + - match: '{{style_content_begin}}' + embed_scope: source.postcss.embedded.html escape_captures: 1: source.postcss.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -369,17 +368,17 @@ contexts: pop: 1 embed: scope:source.postcss escape: '{{style_content_end}}' + - include: style-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=less{{unquoted_attribute_break}}|\'less\'|"less") set: - - meta_scope: meta.tag.style.begin.html - - include: style-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: source.less.embedded.html - match: '{{style_content_begin}}' + - match: '{{style_content_begin}}' + embed_scope: source.less.embedded.html escape_captures: 1: source.less.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -390,6 +389,7 @@ contexts: pop: 1 embed: scope:source.less escape: '{{style_content_end}}' + - include: style-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?=\S) @@ -449,12 +449,11 @@ contexts: - match: (?i)(?=jade{{unquoted_attribute_break}}|\'jade\'|"jade") set: - - meta_scope: meta.tag.template.begin.html - - include: template-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: text.jade.embedded.html - match: '{{template_content_begin}}' + - match: '{{template_content_begin}}' + embed_scope: text.jade.embedded.html escape_captures: 1: text.jade.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -465,17 +464,17 @@ contexts: pop: 1 embed: scope:text.jade escape: '{{template_content_end}}' + - include: template-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=pug{{unquoted_attribute_break}}|\'pug\'|"pug") set: - - meta_scope: meta.tag.template.begin.html - - include: template-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: text.pug.embedded.html - match: '{{template_content_begin}}' + - match: '{{template_content_begin}}' + embed_scope: text.pug.embedded.html escape_captures: 1: text.pug.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -486,17 +485,17 @@ contexts: pop: 1 embed: scope:text.pug escape: '{{template_content_end}}' + - include: template-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?i)(?=slm{{unquoted_attribute_break}}|\'slm\'|"slm") set: - - meta_scope: meta.tag.template.begin.html - - include: template-common - match: '>' scope: punctuation.definition.tag.end.html set: - - embed_scope: text.slm.embedded.html - match: '{{template_content_begin}}' + - match: '{{template_content_begin}}' + embed_scope: text.slm.embedded.html escape_captures: 1: text.slm.embedded.html 2: comment.block.html punctuation.definition.comment.end.html @@ -507,6 +506,7 @@ contexts: pop: 1 embed: scope:text.slm escape: '{{template_content_end}}' + - include: template-common - tag-generic-attribute-meta - tag-generic-attribute-value - match: (?=\S) @@ -521,7 +521,23 @@ contexts: - 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 diff --git a/src/macros.py b/src/macros.py index 85839af..9884d5a 100644 --- a/src/macros.py +++ b/src/macros.py @@ -15,7 +15,6 @@ def embed_language_in_tag(tag, match, embed): set=[ [ _rule(meta_scope='meta.tag.%s.begin.html' % tag), - _rule(include='%s-common' % tag), _rule( match='>', scope='punctuation.definition.tag.end.html', @@ -38,6 +37,7 @@ def embed_language_in_tag(tag, match, embed): ) ] ), + _rule(include='%s-common' % tag), ], 'tag-generic-attribute-meta', 'tag-generic-attribute-value', From b83ec255cf5df51a33ce5cd79993f2d399bd12b4 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 22 Feb 2022 20:48:31 +0100 Subject: [PATCH 54/62] Fix JS expression interpolation in directives Addresses https://github.com/vuejs/vue-syntax-highlight/pull/216#discussion_r812048219 This commit includes `JavaScript#expression-statement` context in attribute/directive values to highlight mappings correctly. The `pop: 1` is removed as the included context pops itself off stack. --- Vue Component.sublime-syntax | 6 ++--- Vue Component.sublime-syntax.yaml-macros | 6 ++--- tests/syntax_tests_mustage.vue | 29 ++++++++++++++++-------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Vue Component.sublime-syntax b/Vue Component.sublime-syntax index 4a75593..705de44 100644 --- a/Vue Component.sublime-syntax +++ b/Vue Component.sublime-syntax @@ -599,8 +599,7 @@ contexts: vue-directive-value: - match: \" scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html - pop: 1 - embed: scope:source.js + embed: scope:source.js#expression-statement embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html escape: \" escape_captures: @@ -608,8 +607,7 @@ contexts: punctuation.definition.string.end.html - match: \' scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html - pop: 1 - embed: scope:source.js + embed: scope:source.js#expression-statement embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html escape: \' escape_captures: diff --git a/Vue Component.sublime-syntax.yaml-macros b/Vue Component.sublime-syntax.yaml-macros index 65467cb..9db402a 100644 --- a/Vue Component.sublime-syntax.yaml-macros +++ b/Vue Component.sublime-syntax.yaml-macros @@ -362,8 +362,7 @@ contexts: scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html - pop: 1 - embed: scope:source.js + embed: scope:source.js#expression-statement embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html @@ -377,8 +376,7 @@ contexts: scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html - pop: 1 - embed: scope:source.js + embed: scope:source.js#expression-statement embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html diff --git a/tests/syntax_tests_mustage.vue b/tests/syntax_tests_mustage.vue index 57aa290..1b9c783 100644 --- a/tests/syntax_tests_mustage.vue +++ b/tests/syntax_tests_mustage.vue @@ -38,22 +38,31 @@ // ^^^^^^^^^^^ source.js.embedded.vue // ^^ punctuation.definition.template.end.html - source.js -

+

// ^^^ meta.tag - meta.attribute-with-value // ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html - meta.string // ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation -// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html -// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation -// ^ meta.tag - meta.attribute-with-value -// ^ - meta.tag +// ^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html meta.mapping +// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation +// ^ meta.tag - meta.attribute-with-value +// ^ - meta.tag -

+

// ^^^ meta.tag - meta.attribute-with-value // ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html - meta.string // ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation -// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html -// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation -// ^ meta.tag - meta.attribute-with-value -// ^ - meta.tag +// ^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html +// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation +// ^ meta.tag - meta.attribute-with-value +// ^ - meta.tag + +

+// ^^^ meta.tag - meta.attribute-with-value +// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html - meta.string +// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation +// ^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html +// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation +// ^ meta.tag - meta.attribute-with-value +// ^ - meta.tag \ No newline at end of file From 4c6622a63d47670cc3a15030777812b99df7265f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 22 Feb 2022 20:48:49 +0100 Subject: [PATCH 55/62] Opt-in to python 3.8 plugin host Run YAML macros in python 3.8 in order to maintain dictionary key sort order. --- .python-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..98fccd6 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.8 \ No newline at end of file From 865cc9d4778deeafe0e3e25abcf9000a94b54d32 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sat, 15 Oct 2022 12:03:08 +0200 Subject: [PATCH 56/62] Use `vue` suffix for embed_scope in attributes and mustache This allows easily targeting the embed scopes inside attributes as something that is contributed and supported by the vue syntax only as opposed to a a `