tree-sitter-vhs
tree-sitter-vhs copied to clipboard
fix: inline anonymous nodes
Problem: The "trick" of wrapping an anonymous node into a single choice or seq no longer works as of https://github.com/tree-sitter/tree-sitter/pull/2577 since the wrapped anonymous nodes are no longer exposed to queries. This means generating with tree-sitter > 0.22.6 leads to a broken parser.
Solution: Inline anonymous nodes.
@amaanq
ping @maaslalani
ping @caarlos0
If this project is no longer officially maintained, consider archiving it so we can drop it from nvim-treesitter.
hey, sorry for the delay reviewing this
@clason @caarlos0
~Not sure if I'm maybe missing something~, but following this merge a number of tests now fail, specifically:
- examples: Glow
- all: Display
- all: Copy Paste
node.js 20.16.0 LTS
git clone [email protected]:charmbracelet/tree-sitter-vhs.git && cd tree-sitter-vhsnpm installnpm run generatenpm test
EDIT:
It seems to be because tree-sitter-cli in package-lock.json is pinned to 0.20.8 with version specified in devDependencies at 0.20.7. Upgrading to 0.22.6 fixes the issue.
ah, cool, thanks for investigating!
wanna PR it @nixpig ?
Not sure how I reached the conclusion that simply upgrading tree-sitter-cli fixed the broken tests. Looking at it again this morning, it seems the change in output is correct, i.e. what was previously (command (node)) is now simply (command).
If @clason can confirm, then I'm happy to submit a PR with updates to tests and upgrade to latest tree-sitter-cli.
Can you point me to these failing tests? The grammar change should not have affected any queries, and in particular should not make such a huge, sweeping, difference as the one you state.
And the first thing anybody should do is set up some workflows to run tests on PRs ;) (You can use https://github.com/tree-sitter-grammars/template as a base.)
npm installnpm run generatenpm test
Any tests using Hide, Show, Copy and Paste fail. For example, the Glow tests in test/corpus/examples.txt, the Display and Copy Paste tests in test/corpus/all.txt.
Yes, those tests need to be adapted since the corresponding nodes are now visible. Just do tree-sitter test -u, or edit the expected output manually.