Skip to content

Merge vscode-parse-tree extension into Cursorless monorepo #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pokey opened this issue May 20, 2023 · 5 comments
Open

Merge vscode-parse-tree extension into Cursorless monorepo #1488

pokey opened this issue May 20, 2023 · 5 comments

Comments

@pokey
Copy link
Member

pokey commented May 20, 2023

The problem

  • Building tree-sitter-wasms locally is painful
  • We need a way to use tree-sitter outside vscode, eg in jetbrains, neovim, etc
  • Eventually enable automatically upgrading languages because we could use CI to make sure no scopes break

The solution

1. Publish npm package in CI containing pre-built wasms

We need to modify https://github.com/cursorless-dev/tree-sitter-wasms as follows:

2. Create a cursorless-tree-sitter package in our monorepo

  • Exposes a class CursorlessTreeSitter copied from JetBrainsTreeSitter
  • Depends on web-tree-sitter
  • Depends on @cursorless/tree-sitter-wasms
  • Takes path to directory containing wasms as a constructor argument

3. Modify our vscode setup to leverage the above

  • Modify extension.ts to construct a CursorlessTreeSitter and pass packages/cursorless-tree-sitter/node_modules/@cursorless/tree-sitter-wasms/out as directory in development. That should be subdir of cursorlessRepoRoot() or whatever the function is
  • In production, it should pass tree-sitter-wasms subdir of assets root
  • Modify our vscode packaging harness to copy packages/cursorless-tree-sitter/node_modules/@cursorless/tree-sitter-wasms/out to tree-sitter-wasms
  • Remove extension dependency on vscode-parse-tree

Future steps

Possibly useful links

@rinOfTheStars
Copy link

I've gotten the buildscripts nearly functional locally (13 or so packages fail to build out of what, 40-50?) for step one, but it fails spectacularly for reasons I don't fully understand when run via github actions. https://github.com/cocona20xx/tree-sitter-wasms/tree/issue-1488-restructure

My only guess is that how the buildscripts are set up is fundamentally incompatible with github actions due to how it stores dependencies temporarily? That'd explain the ENOENT on spawn for running the build commands, but idk how to fix that issue. Maybe storing the downloaded dependencies as part of the repo itself would work?

@pokey
Copy link
Member Author

pokey commented Jan 13, 2025

The github action works on the original repo, so presumably something broke from the tree-sitter version bump? Looks like this repo has it working, so maybe worth seeing if there's something to steal there? Can try just forking that branch onto your repo and running it to see if it also works for you for a start. Lmk if you wanna drop into a meet-up to debug

@rinOfTheStars
Copy link

rinOfTheStars commented Jan 16, 2025

I found a solution after a lot of trial and error (16 to 18 commits worth of it! 🫠):

pnpm config set node-linker hoisted causes pnpm's dependency storage to mimic npm's, which fixes the ENOENT spam, though this requires adding some extra stuff to package.json to properly install the tree sitter CLI (and it does so inefficiently due to some deps also having the CLI as prod deps)

Now that build behavior is the same on my machine as it is on Actions, the focus is going to be on getting every depenency package to actually build, which isn't happening just yet. I'll also probably add something to a prebuild script to handle running just the buildscripts for the root tree sitter CLI, since that'll save 10-20s per run.

@pokey
Copy link
Member Author

pokey commented Jan 16, 2025

Weird. Good work. Might be worth just switching to npm if it simplifies things 🤷‍♂️

@rinOfTheStars
Copy link

cursorless-dev/tree-sitter-wasms#1

After much ado, I think this is as far as I can take things for bullet point 1. Lmk if anything else is needed.

AndreasArvidsson pushed a commit to cursorless-dev/tree-sitter-wasms that referenced this issue Apr 5, 2025
Should complete the first bullet point of
cursorless-dev/cursorless#1488 as mentioned in
the title. Things are a bit more hacky than I'd like, and in the future
I might rewrite a good chunk of the code in order to only use `git
clone`'d packages, but this is good enough for now. Obviously I can't
test anything publishing related, so this is as far as I can take
things.

Note that the parser packages listed in `package.json` are only the ones
present in
[vscode-parse-tree](https://github.com/cursorless-dev/vscode-parse-tree)
(plus gdscript since I have a pr open for that which this makes somewhat
irrelevant if I understand things correctly?); please lmk if the parser
packages that were unique to this project should be readded!

Finally, please note that a few parser packages have had their versions
upgraded. IIrc most of these were due to issues building older versions,
as nearly all of the packages which are `git clone`'d in `build.ts` at
runtime require special linking to build their `.wasm` file, which
thankfully is present in fairly recent versions of said repos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants