From 92af5cfd9a9413998a7157c497c8b2f2eb581856 Mon Sep 17 00:00:00 2001 From: bluedrink9 Date: Thu, 26 Dec 2024 22:24:30 +1300 Subject: [PATCH 1/3] Add r treesitter --- Makefile | 2 +- package.json | 2 ++ src/extension.ts | 1 + yarn.lock | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a7aa62a..8c246c4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # For generating .wasm files for parsers # See https://www.npmjs.com/package/web-tree-sitter -LANGUAGES = agda bash c c-sharp clojure cpp css dart elm elixir gleam go haskell hcl html java javascript json julia kotlin latex lua markdown nix perl php python query ruby rust scala scss sparql swift talon tsx typescript xml yaml +LANGUAGES = agda bash c c-sharp clojure cpp css dart elm elixir gleam go haskell hcl html java javascript json julia kotlin latex lua markdown nix perl php python query r ruby rust scala scss sparql swift talon tsx typescript xml yaml # Build web-tree-sitter parsers for $(LANGUAGES) diff --git a/package.json b/package.json index ff2aeed..6ab8213 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "onLanguage:perl", "onLanguage:php", "onLanguage:python", + "onLanguage:r", "onLanguage:ruby", "onLanguage:rust", "onLanguage:scala", @@ -123,6 +124,7 @@ "tree-sitter-php": "github:tree-sitter/tree-sitter-php#4f124bc6075e1c3333e80190c1c170933ed72c95", "tree-sitter-python": "github:tree-sitter/tree-sitter-python#71778c2a472ed00a64abf4219544edbf8e4b86d7", "tree-sitter-query": "github:nvim-treesitter/tree-sitter-query#5217c6805c09f8fc00ed13d17d5fcb791437aee6", + "tree-sitter-r": "^1.1.0", "tree-sitter-ruby": "github:tree-sitter/tree-sitter-ruby#dc2d7d6b50f9975bc3c35bbec0ba11b2617b736b", "tree-sitter-rust": "github:tree-sitter/tree-sitter-rust#36ae187ed6dd3803a8a89dbb54f3124c8ee74662", "tree-sitter-scala": "github:tree-sitter/tree-sitter-scala#master", diff --git a/src/extension.ts b/src/extension.ts index 7de21eb..16526f9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -40,6 +40,7 @@ const languages: { perl: { module: "tree-sitter-perl" }, php: { module: "tree-sitter-php" }, python: { module: "tree-sitter-python" }, + r: { module: "tree-sitter-r" }, ruby: { module: "tree-sitter-ruby" }, rust: { module: "tree-sitter-rust" }, scala: { module: "tree-sitter-scala" }, diff --git a/yarn.lock b/yarn.lock index 73536a8..67d2806 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2150,6 +2150,11 @@ tree-sitter-css@^0.19.0: dependencies: nan "^2.14.2" +tree-sitter-r@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/tree-sitter-r/-/tree-sitter-r-1.1.0.tgz#5fc0b854754b9a2aa5ebfe2feea577455d5d1f2f" + integrity sha512-dYYlIPiJjNlkldagvissXUiXQpEzyHUs1sAjsWmPM7KhVmrzS8M+O9LAa/o7CiZN6sP63ReH1nM6qmx+Wfbhbg== + "tree-sitter-ruby@github:tree-sitter/tree-sitter-ruby#dc2d7d6b50f9975bc3c35bbec0ba11b2617b736b": version "0.21.0" resolved "https://codeload.github.com/tree-sitter/tree-sitter-ruby/tar.gz/dc2d7d6b50f9975bc3c35bbec0ba11b2617b736b" From b7eeb7339cb1eb600caa53eb9f7ba40219bb13e6 Mon Sep 17 00:00:00 2001 From: bluedrink9 Date: Sun, 11 May 2025 17:00:37 +1200 Subject: [PATCH 2/3] Update read me with tree-sitter-wasms info --- README.md | 8 ++++---- package.json | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ef9e736..515e66f 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,12 @@ registerLanguage(languageId, wasmPath); It's straightforward to add any [language with a tree-sitter grammar](https://tree-sitter.github.io/tree-sitter/). -1. Add a dependency on the npm package for that language: `yarn add -D tree-sitter-yourlang`. +1. First you need to add the package for that language to the [WASMs repo](https://github.com/cursorless-dev/tree-sitter-wasms). Submit a pull request to that repository, with the npm package for your language's tree-sitter added using `pnpm add -D tree-sitter-yourlang`, and wait for a new version to be released. It should be very quick. 2. Add a language to the dictionary at the top of `./src/extension.ts` 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). -4. Add your language to the top of the [Makefile](Makefile) -5. Run `yarn compile`, then hit `F5` in VSCode, with this project open, to test your changes. -6. Submit a PR! +4. Update the `tree-sitter-wasms` dependency version in the `devDependencies` section of packages.json +6. Run `yarn compile`, then hit `F5` in VSCode, with this project open, to test your changes. +7. Submit a PR! ### Developing on WSL2 diff --git a/package.json b/package.json index 6ab8213..d2e0764 100644 --- a/package.json +++ b/package.json @@ -141,5 +141,6 @@ "jsonc-parser": "^2.1.0", "tar": ">=4.4.2", "web-tree-sitter": "^0.24.6" - } + }, + "packageManager": "yarn@4.6.0+sha512.5383cc12567a95f1d668fbe762dfe0075c595b4bfff433be478dbbe24e05251a8e8c3eb992a986667c1d53b6c3a9c85b8398c35a960587fbd9fa3a0915406728" } From fe0ef6e4e208713cc337b73c2d6b610637674daa Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 14 May 2025 08:58:53 +0200 Subject: [PATCH 3/3] Update version --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a3f2234..25127a2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "parse-tree", "displayName": "Parse tree", "description": "Access document syntax using tree-sitter", - "version": "0.36.0", + "version": "0.37.0", "publisher": "pokey", "repository": { "type": "git", @@ -26,11 +26,11 @@ "onLanguage:c", "onLanguage:clojure", "onLanguage:cpp", - "onLanguage:css", "onLanguage:csharp", + "onLanguage:css", "onLanguage:dart", - "onLanguage:elm", "onLanguage:elixir", + "onLanguage:elm", "onLanguage:gleam", "onLanguage:go", "onLanguage:haskell", @@ -39,8 +39,8 @@ "onLanguage:javascript", "onLanguage:javascriptreact", "onLanguage:json", - "onLanguage:jsonl", "onLanguage:jsonc", + "onLanguage:jsonl", "onLanguage:julia", "onLanguage:kotlin", "onLanguage:latex",