Skip to content

Commit

Permalink
Change main scope to source.astro
Browse files Browse the repository at this point in the history
Astro language server relies on `source.astro` to return diagnostics
and completions. Latest versions kept quiet due to wrong `text.html.astro`
scope.
  • Loading branch information
deathaxe committed Mar 12, 2024
1 parent f3a61a9 commit cb3a079
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 153 deletions.
2 changes: 1 addition & 1 deletion Syntaxes/HTML (Astro).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/withastro/language-tools/tree/main/packages/vscode/syntaxes
# http://www.sublimetext.com/docs/syntax.html
name: HTML (Astro)
scope: text.html.astro
scope: source.astro
version: 2

extends: Packages/HTML/HTML.sublime-syntax
Expand Down
8 changes: 4 additions & 4 deletions Syntaxes/Markdown (Astro).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ variables:
contexts:
prototype:
- meta_prepend: true
- include: scope:text.html.astro#astro-interpolations
- include: scope:source.astro#astro-interpolations

main:
- meta_include_prototype: false
Expand Down Expand Up @@ -1045,8 +1045,8 @@ contexts:
0: meta.code-fence.definition.begin.markdown-gfm
2: punctuation.definition.raw.code-fence.begin.markdown
5: constant.other.language-name.markdown
embed: scope:text.html.astro
embed_scope: markup.raw.code-fence.markdown-gfm text.html.astro
embed: scope:source.astro
embed_scope: markup.raw.code-fence.markdown-gfm source.astro
escape: '{{fenced_code_block_escape}}'
escape_captures:
0: meta.code-fence.definition.end.markdown-gfm
Expand Down Expand Up @@ -1904,7 +1904,7 @@ contexts:
- include: html-content

html-content:
- include: scope:text.html.astro#html
- include: scope:source.astro#html

html-entities:
# https://spec.commonmark.org/0.30/#entity-and-numeric-character-references
Expand Down
2 changes: 0 additions & 2 deletions preview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ const expressions = 'Lorem ipsum';
})}
</Markdown>
</Layout>


10 changes: 5 additions & 5 deletions tests/syntax_test_astro.astro
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@
// ^ entity.name.tag
// ^^^^^ entity.other.attribute-name
// ^ punctuation.separator.key-value
// ^ punctuation.section.interpolation.begin.astro - source
// ^ punctuation.section.interpolation.begin.astro - source.tsx
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro meta.string.js
// ^^^^^^^^^ meta.interpolation.js
// ^^ punctuation.section.interpolation.begin.js
// ^ punctuation.section.interpolation.end.js
// ^^^^^^^^^ meta.interpolation.js
// ^^ punctuation.section.interpolation.begin.js
// ^ punctuation.section.interpolation.end.js
// ^ punctuation.section.interpolation.end.astro - source
// ^ punctuation.section.interpolation.end.astro - source.tsx
// ^^^^ entity.other.attribute-name
// ^ punctuation.separator.key-value
// ^^^^^^ meta.path.url.html meta.string.html meta.interpolation.astro

<ul>{posts.map(post => <li>{post.frontmatter.title}</li>)}</ul>
//^^^^ meta.tag.block
// ^ meta.interpolation.astro punctuation.section.interpolation.begin.astro - source
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.astro source.tsx.embedded.astro meta.function-call.method.js
// ^ meta.interpolation.astro punctuation.section.interpolation.end.astro - source
// ^ meta.interpolation.astro punctuation.section.interpolation.begin.astro - source.tsx
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.astro source.tsx.embedded.astro
// ^ meta.interpolation.astro punctuation.section.interpolation.end.astro - source.tsx
// ^^^^^ meta.tag.block

<raw.Component attr:value is:raw attr:value=Value> <p>Text</p> </raw.Component>
Expand Down
12 changes: 6 additions & 6 deletions tests/syntax_test_astro.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ The {frontmatter.author} is {frontmatter.age} and lives in Toronto, Canada.

```astro
---
| <- markup.raw.code-fence.markdown-gfm text.html.astro meta.frontmatter.astro punctuation.section.frontmatter.begin.astro
|^^^ markup.raw.code-fence.markdown-gfm text.html.astro meta.frontmatter.astro
| <- markup.raw.code-fence.markdown-gfm source.astro meta.frontmatter.astro punctuation.section.frontmatter.begin.astro
|^^^ markup.raw.code-fence.markdown-gfm source.astro meta.frontmatter.astro
|^^ punctuation.section.frontmatter.begin.astro
| <- markup.raw.code-fence.markdown-gfm text.html.astro meta.frontmatter.astro source.ts.embedded.astro
| <- markup.raw.code-fence.markdown-gfm source.astro meta.frontmatter.astro source.ts.embedded.astro
---
| <- markup.raw.code-fence.markdown-gfm text.html.astro meta.frontmatter.astro punctuation.section.frontmatter.end.astro
|^^^ markup.raw.code-fence.markdown-gfm text.html.astro meta.frontmatter.astro
| <- markup.raw.code-fence.markdown-gfm source.astro meta.frontmatter.astro punctuation.section.frontmatter.end.astro
|^^^ markup.raw.code-fence.markdown-gfm source.astro meta.frontmatter.astro
|^^ punctuation.section.frontmatter.end.astro
<ul>
{posts.map(post => <li>{post.frontmatter.title}</li>)}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.raw.code-fence.markdown-gfm text.html.astro meta.interpolation.astro
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.raw.code-fence.markdown-gfm source.astro meta.interpolation.astro
| ^ punctuation.section.interpolation.begin.astro
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro
| ^ punctuation.section.interpolation.end.astro
Expand Down
116 changes: 58 additions & 58 deletions tests/syntax_test_script.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,81 @@
// ^^^^^^^^^ meta.tag.script.end.html

<script> var i = 0; </script>
// ^^^^^^^^ meta.tag - source
// ^^^^^^^^ meta.tag - source.ts
// ^^^^^^^^^^^^ source.ts.embedded.html - meta.tag
// ^^^^^^^^^ meta.tag - source
// ^^^^^^^^^ meta.tag - source.ts

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

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

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


<script>

// <- source.ts.embedded.html
var i = 0;
// ^^^^^^^^^^^^ source.ts.embedded.html - source source
// ^^^^^^^^^^^^ source.ts.embedded.html - source.ts source.ts
</script>
// <- source.ts.embedded.html - source source
// ^ source.ts.embedded.html - source source
// ^^^^^^^^^ meta.tag - source
// <- source.ts.embedded.html - source.ts source.ts
// ^ source.ts.embedded.html - source.ts source.ts
// ^^^^^^^^^ meta.tag - source.ts


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


<script> <!--
// ^^^^^^^^^^^^^ - source
// ^^^^^^^^^^^^^ - source.ts
// ^^^^^^^^ meta.tag
// ^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag
// ^ punctuation.definition.tag.end.html
// ^ - meta.tag - comment
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.ts.embedded.html - source source
// ^ source.ts.embedded.html - source.ts source.ts

var foo = 100;
// <- source.ts.embedded.html - source source
// <- source.ts.embedded.html - source.ts source.ts

(a --> b);
// ^^^ source.ts.embedded.html keyword.operator - comment

--> </script>
// ^ source.ts.embedded.html - source source
// ^^^^^^^^^^^^^^ - source
// ^ source.ts.embedded.html - source.ts source.ts
// ^^^^^^^^^^^^^^ - source.ts
// ^ - meta.tag - comment
// ^^^^^^^^^ meta.tag
// ^ - meta.tag
Expand All @@ -89,10 +89,10 @@


<script type="text/javascript"> <!--
// ^^^^^^^^ meta.tag - meta.attribute-with-value - source
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value - source
// ^ meta.tag - meta.attribute-with-value - source
// ^^^^^ - meta.tag - source
// ^^^^^^^^ meta.tag - meta.attribute-with-value - source.ts
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value - source.ts
// ^ meta.tag - meta.attribute-with-value - source.ts
// ^^^^^ - meta.tag - source.ts
// ^^^^^^ entity.name.tag
// ^^^^ entity.other.attribute-name.html
// ^ punctuation.separator.key-value.html
Expand All @@ -101,14 +101,14 @@
// ^ source.js.embedded.html

var foo = 100;
// <- source.js.embedded.html - source source
// <- source.js.embedded.html - source.ts source.ts

(a --> b);
// ^^^ source.js.embedded.html keyword.operator - comment

--> </script>
// ^ source.js.embedded.html - source source
// ^^^^^^^^^^^^^^ - source
// ^ source.js.embedded.html - source.ts source.ts
// ^^^^^^^^^^^^^^ - source.ts
// ^ - meta.tag - comment
// ^^^^^^^^^ meta.tag
// ^ - meta.tag
Expand All @@ -125,12 +125,12 @@
application/jAvAsCrIpT>
// ^^^^^^^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value
var foo = 100;
// <- source.ts.embedded.html - source source
// ^^^^^^^^^^^^^^^^ source.ts.embedded.html - source source
// <- source.ts.embedded.html - source.ts source.ts
// ^^^^^^^^^^^^^^^^ source.ts.embedded.html - source.ts source.ts
</script>
// <- source.ts.embedded.html - source source
// ^ source.ts.embedded.html - source source
// ^^^^^^^^^ meta.tag - source
// <- source.ts.embedded.html - source.ts source.ts
// ^ source.ts.embedded.html - source.ts source.ts
// ^^^^^^^^^ meta.tag - source.ts
// ^^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag.script.html
// ^ punctuation.definition.tag.end.html
Expand All @@ -147,39 +147,39 @@
// ^ punctuation.definition.tag.end.html
// ^ - meta.tag

// <- source.ts.embedded.html - source source
// <- source.ts.embedded.html - source.ts source.ts
</script>
// <- source.ts.embedded.html - source source
//^^ source.ts.embedded.html - source source
// ^^^^^^^^^ meta.tag - source
// <- source.ts.embedded.html - source.ts source.ts
//^^ source.ts.embedded.html - source.ts source.ts
// ^^^^^^^^^ meta.tag - source.ts
// ^^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag.script.html
// ^ punctuation.definition.tag.end.html


<script lang="ts">
<!--
// ^^^^^^^^^ - source
// ^^^^^^^^^ - source.ts
// ^^^^ comment.block.html punctuation.definition.comment.begin.html
// ^ source.ts.embedded.html - source source
// ^ source.ts.embedded.html - source.ts source.ts
-->
// ^^^^^ source.ts.embedded.html - source source
// ^^^ comment.block.html punctuation.definition.comment.end.html - source
// ^ - source - comment - meta.tag
// ^^^^^ source.ts.embedded.html - source.ts source.ts
// ^^^ comment.block.html punctuation.definition.comment.end.html - source.ts
// ^ - source.ts - comment - meta.tag
</script>
// <- - source - comment - meta.tag
//^^ - source - comment - meta.tag
// ^^^^^^^^^ meta.tag - source
// <- - source.ts - comment - meta.tag
//^^ - source.ts - comment - meta.tag
// ^^^^^^^^^ meta.tag - source.ts
// ^^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag.script.html
// ^ punctuation.definition.tag.end.html


<script lang="other"> </script>
// ^^^^^^^^^^^^^^^^^^^^^ meta.tag - meta.tag meta.tag - source
// ^^^^^^^^^^^^^^^^^^^^^ meta.tag - meta.tag meta.tag - source.ts
// ^^^^^^^^^^^^ meta.attribute-with-value.html - meta.attribute-with-value meta.attribute-with-value
// ^^ - meta.tag - source
// ^^^^^^^^^ meta.tag - source
// ^^ - meta.tag - source.ts
// ^^^^^^^^^ meta.tag - source.ts


<script src={Astro.resolve('../scripts/main.js')} hoist></script>
Expand All @@ -190,9 +190,9 @@
// ^^^ entity.other.attribute-name.href.html
// ^ punctuation.separator.key-value.html
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.url.html meta.string.html meta.interpolation.astro
// ^ punctuation.section.interpolation.begin.astro - source
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro meta.function-call.method.js
// ^ punctuation.section.interpolation.end.astro - source
// ^ punctuation.section.interpolation.begin.astro - source.ts
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.tsx.embedded.astro meta.function-call
// ^ punctuation.section.interpolation.end.astro - source.ts
// ^^^^^ meta.attribute-with-value.html entity.other.attribute-name.html
// ^ punctuation.definition.tag.end.html

Expand All @@ -215,7 +215,7 @@
// ^^^^^^^^^^^^^^^^^^^ source.ts.embedded.html
// ^^^^^ variable.function.js
</script>
// ^^^^^^^^^ meta.tag - source
// ^^^^^^^^^ meta.tag - source.ts
// ^^ punctuation.definition.tag.begin.html
// ^^^^^^ entity.name.tag.script.html
// ^ punctuation.definition.tag.end.html
Loading

0 comments on commit cb3a079

Please sign in to comment.