From 208eafff35f4cadc59d79d0b94cfdd76f1562019 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 2 Nov 2024 10:15:07 +0100 Subject: [PATCH 1/2] Fix HTML completions and snippets Addresses #10 Commit 172ec6621afd5a70395aff316a3d2ae9e711bf97 changed main scope from `text.html.astro` to `source.astro` as official language server expects the latter. This commit re-adds `text.html.astro` in order to re-enable basic HTML snippets. To also use ST's basic HTML auto completions however 1. https://github.com/sublimehq/Packages/pull/4085 is required, which adjusts HTML specific auto completion selector to enable them in `source.astro text.html` scope. 2. manual adjustment of html completion selector is required. - Open a HTML file - Call `Preferences: Settings - Syntax Specific` from command palette - copy selector setting from linked PR to the right view and save it. --- Syntaxes/HTML (Astro).sublime-syntax | 3 ++- tests/syntax_test_astro.astro | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Syntaxes/HTML (Astro).sublime-syntax b/Syntaxes/HTML (Astro).sublime-syntax index adf7376..9e0b440 100644 --- a/Syntaxes/HTML (Astro).sublime-syntax +++ b/Syntaxes/HTML (Astro).sublime-syntax @@ -28,8 +28,9 @@ contexts: main: - meta_include_prototype: false + - meta_scope: text.html.astro meta.template.astro - match: '' - set: [html, frontmatter] + push: [html, frontmatter] frontmatter: - meta_include_prototype: false diff --git a/tests/syntax_test_astro.astro b/tests/syntax_test_astro.astro index f8941f5..0de18f2 100644 --- a/tests/syntax_test_astro.astro +++ b/tests/syntax_test_astro.astro @@ -1,5 +1,7 @@ // SYNTAX TEST "HTML (Astro).sublime-syntax" +// <- source.astro text.html.astro meta.template.astro + //^^^^^^^^^ comment.block.astro //^^ punctuation.definition.comment.begin.astro From 097a5a7a1b0bd5058726f75f85de12b824604ff1 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 2 Nov 2024 11:17:09 +0100 Subject: [PATCH 2/2] Restrict snippets This commit disables snippet in ... - comments - literal or interpolated strings - embedded or interpolated code blocks (from template languages) - HTML tags - Markdown files (but not in fenced code blocks) Using `- source.astro ` in order to only exclude scopes belonging to possibly embedded Astro code block in question. --- Snippets/component.sublime-snippet | 12 +++++++++++- Snippets/page_html.sublime-snippet | 12 +++++++++++- Snippets/page_layout.sublime-snippet | 12 +++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Snippets/component.sublime-snippet b/Snippets/component.sublime-snippet index 3f58c1f..db870db 100644 --- a/Snippets/component.sublime-snippet +++ b/Snippets/component.sublime-snippet @@ -6,6 +6,16 @@ $1 $0 ]]> component - source.astro + + source.astro + - source.astro meta.tag + - source.astro meta.embedded + - source.astro meta.interpolation + - source.astro meta.string + - source.astro comment + - source.astro source + - source.astro string + - (text.html.markdown - markup.raw.code-fence source.astro) + Component diff --git a/Snippets/page_html.sublime-snippet b/Snippets/page_html.sublime-snippet index f8b334f..06421d7 100644 --- a/Snippets/page_html.sublime-snippet +++ b/Snippets/page_html.sublime-snippet @@ -16,6 +16,16 @@ $1 ]]> page_html - source.astro + + source.astro + - source.astro meta.tag + - source.astro meta.embedded + - source.astro meta.interpolation + - source.astro meta.string + - source.astro comment + - source.astro source + - source.astro string + - (text.html.markdown - markup.raw.code-fence source.astro) + Page with full HTML diff --git a/Snippets/page_layout.sublime-snippet b/Snippets/page_layout.sublime-snippet index dbae2f9..08510d2 100644 --- a/Snippets/page_layout.sublime-snippet +++ b/Snippets/page_layout.sublime-snippet @@ -8,6 +8,16 @@ import ${1:Layout} from "../layouts/$1.astro" ]]> page_layout - source.astro + + source.astro + - source.astro meta.tag + - source.astro meta.embedded + - source.astro meta.interpolation + - source.astro meta.string + - source.astro comment + - source.astro source + - source.astro string + - (text.html.markdown - markup.raw.code-fence source.astro) + Page from Layout