From c7a87c12a879b6b2ab0778567ba06f26fe4115bc Mon Sep 17 00:00:00 2001 From: Benjamin Streit Date: Tue, 13 Sep 2022 01:53:55 -0500 Subject: [PATCH] feat: Syntax highlighting for Astro files (#3829) --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++++++++++++ runtime/queries/astro/highlights.scm | 3 +++ runtime/queries/astro/injections.scm | 9 +++++++++ 4 files changed, 25 insertions(+) create mode 100644 runtime/queries/astro/highlights.scm create mode 100644 runtime/queries/astro/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 37ceec16aa7f..78362384897c 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -1,5 +1,6 @@ | Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP | | --- | --- | --- | --- | --- | +| astro | ✓ | | | | | awk | ✓ | ✓ | | `awk-language-server` | | bash | ✓ | | | `bash-language-server` | | beancount | ✓ | | | | diff --git a/languages.toml b/languages.toml index 83e4affd5e35..5e563178a189 100644 --- a/languages.toml +++ b/languages.toml @@ -1754,3 +1754,15 @@ language-server = { command = "jsonnet-language-server", args= ["-t", "--lint"] [[grammar]] name = "jsonnet" source = { git = "https://github.com/sourcegraph/tree-sitter-jsonnet", rev = "0475a5017ad7dc84845d1d33187f2321abcb261d" } + +[[language]] +name = "astro" +scope = "source.astro" +injection-regex = "astro" +file-types = ["astro"] +roots = [] +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "astro" +source = { git = "https://github.com/virchau13/tree-sitter-astro", rev = "5f5c3e73c45967df9aa42f861fad2d77cd4e0900" } diff --git a/runtime/queries/astro/highlights.scm b/runtime/queries/astro/highlights.scm new file mode 100644 index 000000000000..3d0792b84399 --- /dev/null +++ b/runtime/queries/astro/highlights.scm @@ -0,0 +1,3 @@ +; inherits: html + +["---"] @punctuation.delimiter diff --git a/runtime/queries/astro/injections.scm b/runtime/queries/astro/injections.scm new file mode 100644 index 000000000000..e3cff1789acd --- /dev/null +++ b/runtime/queries/astro/injections.scm @@ -0,0 +1,9 @@ +; inherits: html + +((frontmatter + (raw_text) @injection.content) + (#set! injection.language "typescript")) + +((interpolation + (raw_text) @injection.content) + (#set! injection.language "tsx"))