Skip to content

Commit 7f69a0e

Browse files
Add Astro language support
Register Astro files with the bundled tree-sitter parser, language detection, LSP, and Prettier plugin formatter metadata. Fixes #720
1 parent a76e74e commit 7f69a0e

11 files changed

Lines changed: 76 additions & 0 deletions

File tree

bun.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"$schema": "https://athas.dev/schemas/extension.json",
3+
"id": "athas.astro",
4+
"name": "Astro",
5+
"displayName": "Astro",
6+
"version": "1.0.0",
7+
"description": "Astro language support with LSP and formatting",
8+
"publisher": "Athas",
9+
"categories": ["Language"],
10+
"languages": [
11+
{
12+
"id": "astro",
13+
"extensions": [".astro"],
14+
"aliases": ["Astro"]
15+
}
16+
],
17+
"capabilities": {
18+
"lsp": {
19+
"name": "astro-ls",
20+
"runtime": "bun",
21+
"package": "@astrojs/language-server",
22+
"args": ["--stdio"]
23+
},
24+
"formatter": {
25+
"name": "prettier",
26+
"runtime": "bun",
27+
"package": "prettier",
28+
"packages": ["prettier-plugin-astro"],
29+
"args": ["--plugin", "prettier-plugin-astro", "--stdin-filepath", "${file}"]
30+
}
31+
}
32+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(tag_name) @tag
2+
(erroneous_end_tag_name) @tag.error
3+
(doctype) @constant
4+
(attribute_name) @attribute
5+
(attribute_value) @string
6+
(comment) @comment
7+
8+
[
9+
"<"
10+
">"
11+
"</"
12+
] @punctuation.bracket

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"concurrently": "^10.0.3",
132132
"simple-git-hooks": "^2.13.1",
133133
"tailwindcss": "^4.3.1",
134+
"tree-sitter-astro": "github:virchau13/tree-sitter-astro",
134135
"tree-sitter-bash": "^0.25.1",
135136
"tree-sitter-c": "^0.24.1",
136137
"tree-sitter-c-sharp": "^0.23.5",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(tag_name) @tag
2+
(erroneous_end_tag_name) @tag.error
3+
(doctype) @constant
4+
(attribute_name) @attribute
5+
(attribute_value) @string
6+
(comment) @comment
7+
8+
[
9+
"<"
10+
">"
11+
"</"
12+
] @punctuation.bracket
29.2 KB
Binary file not shown.

scripts/postinstall.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ interface ParserSource {
5757

5858
// All bundled parsers — built from source using tree-sitter-cli.
5959
const BUNDLED_PARSERS: Record<string, ParserSource> = {
60+
astro: { package: "tree-sitter-astro" },
6061
bash: { package: "tree-sitter-bash" },
6162
c: { package: "tree-sitter-c" },
6263
c_sharp: { package: "tree-sitter-c-sharp" },

src/features/editor/tests/extension-assets.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ describe("extension-assets", () => {
8080
wasmPath: "/tree-sitter/parsers/elisp/parser.wasm",
8181
highlightQueryUrl: "/tree-sitter/parsers/elisp/highlights.scm",
8282
});
83+
expect(getLanguageAssetConfig("astro")).toMatchObject({
84+
parserLanguageId: "astro",
85+
queryLanguageId: "astro",
86+
wasmPath: "/tree-sitter/parsers/astro/parser.wasm",
87+
highlightQueryUrl: "/tree-sitter/parsers/astro/highlights.scm",
88+
});
8389
});
8490

8591
it("prefers registered manifest asset URLs", () => {

src/features/editor/tests/language-id.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe("getLanguageIdFromPath", () => {
6868
expect(getLanguageIdFromPath("/tmp/message.proto")).toBe("protobuf");
6969
expect(getLanguageIdFromPath("/tmp/query.ql")).toBe("ql");
7070
expect(getLanguageIdFromPath("/tmp/main.tf")).toBe("terraform");
71+
expect(getLanguageIdFromPath("/tmp/page.astro")).toBe("astro");
7172
expect(getLanguageIdFromPath("/tmp/icon.svg")).toBe("xml");
7273
expect(getLanguageIdFromPath("/tmp/project.csproj")).toBe("xml");
7374
expect(getLanguageDisplayName("diff")).toBe("Diff");
@@ -78,6 +79,7 @@ describe("getLanguageIdFromPath", () => {
7879
expect(getLanguageDisplayName("r")).toBe("R");
7980
expect(getLanguageDisplayName("rmarkdown")).toBe("R Markdown");
8081
expect(getLanguageDisplayName("jupyter-notebook")).toBe("Jupyter Notebook");
82+
expect(getLanguageDisplayName("astro")).toBe("Astro");
8183
});
8284

8385
it("maps Monaco-highlighted extensions to registered Monaco language ids", () => {

src/features/editor/utils/language-detection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export function detectLanguageFromPath(filePath: string): string {
6868
lua: "lua",
6969
vim: "vim",
7070
elm: "elm",
71+
astro: "astro",
7172
};
7273

7374
return languageMap[extension] || "text";

0 commit comments

Comments
 (0)