From 2d345aead183d986013ef880f74377638e7463bb Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 2 Nov 2024 12:12:59 +0100 Subject: [PATCH] Unique type attribute scope This commit scopes `type` attributes special to enable static type value completions and adjusts some tests to maintain compatibility with older ST builds. Related with https://github.com/sublimehq/Packages/pull/4061 --- Syntaxes/HTML (Astro).sublime-syntax | 22 +++++++++++++++-- tests/syntax_test_script.astro | 37 ++++++++++++++++++++++++---- tests/syntax_test_style.astro | 6 ++--- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/Syntaxes/HTML (Astro).sublime-syntax b/Syntaxes/HTML (Astro).sublime-syntax index d5e4749..b99dc53 100644 --- a/Syntaxes/HTML (Astro).sublime-syntax +++ b/Syntaxes/HTML (Astro).sublime-syntax @@ -151,23 +151,41 @@ contexts: - meta_scope: meta.attribute-with-value.lang.html - include: immediately-pop + script-type-attribute: + # required until https://github.com/sublimehq/Packages/pull/4061 + - match: (?i:type){{attribute_name_break}} + scope: meta.attribute-with-value.type.html entity.other.attribute-name.html + set: script-type-attribute-assignment + script-type-attribute-assignment: - meta_include_prototype: false - - meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.html + - meta_content_scope: meta.tag.script.begin.html meta.attribute-with-value.type.html - match: = scope: punctuation.separator.key-value.html set: script-type-attribute-value - match: (?=\S) set: script-typescript + script-type-attribute-value: + # required until https://github.com/sublimehq/Packages/pull/4061 + - meta_include_prototype: false + - meta_scope: meta.tag.script.begin.html meta.attribute-with-value.type.html + - include: script-type-decider + script-type-decider: - meta_prepend: true - match: (?=>|''|"") set: - script-javascript - - tag-generic-attribute-meta + - tag-type-attribute-meta - tag-generic-attribute-value + tag-type-attribute-meta: + # required until https://github.com/sublimehq/Packages/pull/4061 + - meta_include_prototype: false + - meta_scope: meta.attribute-with-value.type.html + - include: immediately-pop + script-typescript: - meta_scope: meta.tag.script.begin.html - match: '>' diff --git a/tests/syntax_test_script.astro b/tests/syntax_test_script.astro index c950db6..5a41bd2 100644 --- a/tests/syntax_test_script.astro +++ b/tests/syntax_test_script.astro @@ -89,8 +89,35 @@ +// ^^^^^^^^^^^^^^ - source.js +// ^ - meta.tag - comment +// ^^^^^^^^^ meta.tag +// ^ - meta.tag +// ^^^ comment.block.html punctuation.definition.comment.end.html +// ^^ punctuation.definition.tag.begin.html +// ^^^^^^ entity.name.tag.script.html +// ^ punctuation.definition.tag.end.html + + // ^ source.js.embedded.html - source.ts source.ts @@ -120,10 +147,10 @@