Skip to content

Commit f237ba9

Browse files
Use @cursorless/tree-sitter-wasms dependency (#103)
* Use `@cursorless/tree-sitter-wasms` dependency
1 parent 428cc00 commit f237ba9

File tree

8 files changed

+32
-399
lines changed

8 files changed

+32
-399
lines changed

.vscodeignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ vsc-extension-quickstart.md
88
**/tslint.json
99
**/*.map
1010
**/*.ts
11-
examples/**
11+
examples/**
12+
.github/**
13+
copy-assets.sh
14+
.nvmrc

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to the "vscode-parse-tree" extension will be documented in this file.
44

5+
## 0.33.0 (22 Apr 2025)
6+
7+
### Enhancements
8+
9+
- Stop building wasm and instead use dependency `@cursorless/tree-sitter-wasms` [#103](https://github.com/cursorless-dev/vscode-parse-tree/pull/103) ([AndreasArvidsson](https://github.com/AndreasArvidsson))
10+
511
## 0.32.0 (25 Oct 2024)
612

713
### Enhancements

Makefile

-48
This file was deleted.

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ registerLanguage(languageId, wasmPath);
4343

4444
It's straightforward to add any [language with a tree-sitter grammar](https://tree-sitter.github.io/tree-sitter/).
4545

46-
1. Add a dependency on the npm package for that language: `yarn add -D tree-sitter-yourlang`.
46+
1. Add a dependency on the npm package for that language in [tree-sitter-wasms](https://github.com/cursorless-dev/tree-sitter-wasms)
4747
2. Add a language to the dictionary at the top of `./src/extension.ts`
4848
3. Add a reference to `onLanguage:yourlang` to the [activationEvents section of package.json](package.json). `yourlang` must be a [VSCode language identifier](https://code.visualstudio.com/docs/languages/identifiers).
49-
4. Add your language to the top of the [Makefile](Makefile)
50-
5. Run `yarn compile`, then hit `F5` in VSCode, with this project open, to test your changes.
51-
6. Submit a PR!
49+
4. Run `yarn compile`, then hit `F5` in VSCode, with this project open, to test your changes.
50+
5. Submit a PR!
5251

5352
### Developing on WSL2
5453

copy-assets.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cp -r node_modules/@cursorless/tree-sitter-wasms/out parsers

package.json

+5-44
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "parse-tree",
33
"displayName": "Parse tree",
44
"description": "Access document syntax using tree-sitter",
5-
"version": "0.34.0",
5+
"version": "0.35.0",
66
"publisher": "pokey",
77
"repository": {
88
"type": "git",
@@ -75,7 +75,8 @@
7575
"contributes": {},
7676
"scripts": {
7777
"vscode:prepublish": "npm run compile",
78-
"compile": "tsc -p ./ && make parsers",
78+
"compile": "tsc -p ./ && npm run copy-assets",
79+
"copy-assets": "sh copy-assets.sh",
7980
"watch": "tsc -watch -p ./",
8081
"test": "npm run compile && node ./out/test",
8182
"benchmark": "npm run compile && node ./out/benchmark",
@@ -85,59 +86,19 @@
8586
"publish": "vsce publish patch"
8687
},
8788
"devDependencies": {
89+
"@cursorless/tree-sitter-wasms": "0.2.5",
8890
"@electron/rebuild": "^3.3.0",
89-
"@elm-tooling/tree-sitter-elm": "github:elm-tooling/tree-sitter-elm#0aecfbf69f0c9bcdfada0f6f2c5398235c23949f",
9091
"@types/mocha": "^2.2.42",
9192
"@types/node": "^8.10.25",
9293
"@types/vscode": "~1.58.0",
9394
"@typescript-eslint/eslint-plugin": "^6.11.0",
9495
"@typescript-eslint/parser": "^6.11.0",
9596
"@vscode/test-electron": "^2.1.3",
96-
"eslint": "^8.53.0",
9797
"eslint-config-prettier": "^9.0.0",
98-
"tree-sitter-agda": "github:pokey/tree-sitter-agda#e5fba6cabe8c7fc7993ced2b86704f3841215284",
99-
"tree-sitter-bash": "github:tree-sitter/tree-sitter-bash#2fbd860f802802ca76a6661ce025b3a3bca2d3ed",
100-
"tree-sitter-c": "github:tree-sitter/tree-sitter-c#deca017a554045b4c203e7ddff39ae64ff05e071",
101-
"tree-sitter-c-sharp": "^0.19.0",
102-
"tree-sitter-cli": "^0.22.6",
103-
"tree-sitter-clojure": "github:sogaiu/tree-sitter-clojure#f4236d4da8aa92bc105d9c118746474c608e6af7",
104-
"tree-sitter-cpp": "github:tree-sitter/tree-sitter-cpp#9d412ba7e597fe158f209da33e60f31b1f0df967",
105-
"tree-sitter-css": "^0.19.0",
106-
"tree-sitter-dart": "github:UserNobody14/tree-sitter-dart#9ac03bb2154316624fb4c41fe0f372a5f1597b43",
107-
"tree-sitter-elixir": "github:elixir-lang/tree-sitter-elixir#b20eaa75565243c50be5e35e253d8beb58f45d56",
108-
"tree-sitter-gleam": "github:gleam-lang/tree-sitter-gleam#2012f294baacf30e7a62414754021284377366c6",
109-
"tree-sitter-go": "github:tree-sitter/tree-sitter-go#bbaa67a180cfe0c943e50c55130918be8efb20bd",
110-
"tree-sitter-haskell": "github:tree-sitter/tree-sitter-haskell#a50070d5bb5bd5c1281740a6102ecf1f4b0c4f19",
111-
"tree-sitter-hcl": "github:MichaHoffmann/tree-sitter-hcl#e135399cb31b95fac0760b094556d1d5ce84acf0",
112-
"tree-sitter-html": "github:tree-sitter/tree-sitter-html#e4d834eb4918df01dcad5c27d1b15d56e3bd94cd",
113-
"tree-sitter-java": "github:tree-sitter/tree-sitter-java#ac14b4b1884102839455d32543ab6d53ae089ab7",
114-
"tree-sitter-javascript": "github:tree-sitter/tree-sitter-javascript#391a8fcc48a11f63bf18ec9885f6f069e760949a",
115-
"tree-sitter-json": "github:tree-sitter/tree-sitter-json#94f5c527b2965465956c2000ed6134dd24daf2a7",
116-
"tree-sitter-julia": "github:tree-sitter/tree-sitter-julia#e2f449e2bcc95f1d07ceb62d67f986005f73a6be",
117-
"tree-sitter-kotlin": "github:fwcd/tree-sitter-kotlin#76f53c48d29e8588934fb55b0240d7bdfe00bfe5",
118-
"tree-sitter-latex": "github:latex-lsp/tree-sitter-latex#1666e9780de42a31b1376d32fbe8332e8dd5850f",
119-
"tree-sitter-lua": "github:MunifTanjim/tree-sitter-lua#9668709211b2e683f27f414454a8b51bf0a6bda1",
120-
"tree-sitter-markdown": "github:tree-sitter-grammars/tree-sitter-markdown#7fe453beacecf02c86f7736439f238f5bb8b5c9b",
121-
"tree-sitter-nix": "github:nix-community/tree-sitter-nix#66e3e9ce9180ae08fc57372061006ef83f0abde7",
122-
"tree-sitter-perl": "github:ganezdragon/tree-sitter-perl#3d3a95ee6645d7bcd993e77b252ffd33fd297c8e",
123-
"tree-sitter-php": "github:tree-sitter/tree-sitter-php#4f124bc6075e1c3333e80190c1c170933ed72c95",
124-
"tree-sitter-python": "github:tree-sitter/tree-sitter-python#71778c2a472ed00a64abf4219544edbf8e4b86d7",
125-
"tree-sitter-query": "github:nvim-treesitter/tree-sitter-query#5217c6805c09f8fc00ed13d17d5fcb791437aee6",
126-
"tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#dc2d7d6b50f9975bc3c35bbec0ba11b2617b736b",
127-
"tree-sitter-rust": "github:tree-sitter/tree-sitter-rust#36ae187ed6dd3803a8a89dbb54f3124c8ee74662",
128-
"tree-sitter-scala": "github:tree-sitter/tree-sitter-scala#master",
129-
"tree-sitter-scss": "github:serenadeai/tree-sitter-scss#c478c6868648eff49eb04a4df90d703dc45b312a",
130-
"tree-sitter-sparql": "^0.1.0",
131-
"tree-sitter-swift": "github:alex-pinkus/tree-sitter-swift#7e4ccc97a25315022a70b730085deccd5680a39b",
132-
"tree-sitter-talon": "github:pokey/tree-sitter-talon#f69923ea2490530babe105f0a36434e4a23e127e",
133-
"tree-sitter-typescript": "github:tree-sitter/tree-sitter-typescript#4ad3010c91d700026d036b5230e2d99ba94ae8a4",
134-
"tree-sitter-xml": "github:ObserverOfTime/tree-sitter-xml#648183d86f6f8ffb240ea11b4c6873f6f45d8b67",
135-
"tree-sitter-yaml": "github:tree-sitter-grammars/tree-sitter-yaml#7b03feefd36b5f155465ca736c6304aca983b267",
98+
"eslint": "^8.53.0",
13699
"typescript": "^4.5.5"
137100
},
138101
"dependencies": {
139-
"jsonc-parser": "^2.1.0",
140-
"tar": ">=4.4.2",
141102
"web-tree-sitter": "^0.24.6"
142103
}
143104
}

src/extension.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from "vscode";
22
import * as Parser from "web-tree-sitter";
33
import * as path from "path";
4+
import * as fs from "fs";
45
import { LanguageStillLoadingError, UnsupportedLanguageError } from "./errors";
56

67
interface Language {
@@ -16,7 +17,7 @@ const languages: {
1617
c: { module: "tree-sitter-c" },
1718
clojure: { module: "tree-sitter-clojure" },
1819
cpp: { module: "tree-sitter-cpp" },
19-
csharp: { module: "tree-sitter-c-sharp" },
20+
csharp: { module: "tree-sitter-c_sharp" },
2021
css: { module: "tree-sitter-css" },
2122
dart: { module: "tree-sitter-dart" },
2223
elm: { module: "tree-sitter-elm" },
@@ -91,6 +92,10 @@ export async function activate(context: vscode.ExtensionContext) {
9192
);
9293
}
9394

95+
if (!fs.existsSync(absolute)) {
96+
throw Error(`Parser for ${languageId} not found at ${absolute}`);
97+
}
98+
9499
const wasm = path.relative(process.cwd(), absolute);
95100
await initParser;
96101
const lang = await Parser.Language.load(wasm);

0 commit comments

Comments
 (0)