Use native tree-sitter bindings instead of web-tree-sitter #7

Merged
marfavi merged 16 commits from tree-sitter-native into tree-sitter 2026-10-02 10:37:11 +02:00
Owner

fixes #4

fixes #4
- Load the tree-sitter-crocq grammar as a native ESM addon and drop the committed .wasm and the web-tree-sitter dependency.
- Import the AST node type from tree-sitter in annotations, diagnostics and util.
- Build the grammar with node-gyp and ship a Node-API prebuild (npm run prebuild:native) so the packaged extension needs no C++ toolchain.
- CI: install the native toolchain before npm ci, cache both lockfiles, and generate prebuilds.
- Pin tree-sitter to ^0.25.1 (grammar ABI 15) and keep tree-sitter-c dev-only.
Merge remote-tracking branch 'origin/tree-sitter' into tree-sitter-native
All checks were successful
CI / Format, types, lint, tests (pull_request) Successful in 1m24s
2da993a1a2
# Conflicts:
#	extension/src/parser.ts
marfavi changed title from Tree sitter native to WIP: Tree sitter native 2026-10-01 12:53:10 +02:00
Add grammar testing; Split CI workflows for extension and grammar testing
Some checks failed
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m37s
Grammar / Corpus and binding tests (pull_request) Failing after 41s
c3734210fd
- github.workflow is not part of the Forgejo context, so both workflows evaluated to the same group and could cancel each other; the groups are now named explicitly
- the grammar workflow is no longer expected to fail: the corpus suite passes
- clause_contents no longer swallows the closing */ (tree-sitter regexes have no lookahead, so a * is accepted only when not followed by /)
- clause_contents accepts backslashes, so Verifiable C separating conjunctions parse as clause contents
- invalid_clause no longer requires a trailing newline
- comment parses the empty comment
- consecutive annotations stay separate nodes, so the expectation of that corpus case is corrected and the stale FIXME notes are dropped
- regenerate src/parser.c and src/grammar.json (array.h is churn from the pinned tree-sitter CLI)
- tsconfig.json checks grammar.js with the tree-sitter CLI DSL globals; they are listed explicitly because a types reference cannot resolve the tree-sitter-cli/dsl subpath
- declare the untyped tree-sitter-c/grammar.js module, which ships no declarations (TS7016)
- add npm run generate
Add refresh:grammar and make the native prebuild step idempotent
All checks were successful
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m27s
Grammar / Corpus and binding tests (pull_request) Successful in 36s
50fad86509
- npm run refresh:grammar re-copies ../tree-sitter-crocq and rebuilds its prebuild; because .npmrc sets install-links=true npm copies the file: dependency, so npm install alone will not replace the snapshot
- prebuild:native now rebuilds only while the grammar sources are present, so packaging can run it more than once
- document the grammar edit workflow and the split CI workflows in the README
Merge remote-tracking branch 'origin/tree-sitter' into tree-sitter-native
All checks were successful
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m52s
Grammar / Corpus and binding tests (pull_request) Successful in 43s
9280eadd8a
- hover.ts: keep the new development-mode gate, adapted to the native tree-sitter node types (the node is non-null, so the redundant check is dropped to satisfy the type-aware lint rules)
- corpus: keep the corrected test names; those cases pass now, so the FIXME notes and the issue link they point at are obsolete
Minor formatting
Some checks failed
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m37s
Grammar / Corpus and binding tests (pull_request) Has been cancelled
c87d05634c
Remove changelog
All checks were successful
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m28s
Grammar / Corpus and binding tests (pull_request) Successful in 38s
408913841c
Nitpick a comment
All checks were successful
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m32s
Grammar / Corpus and binding tests (pull_request) Successful in 42s
306fb3c13b
Simplify extension/package.json slightly
All checks were successful
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m30s
Grammar / Corpus and binding tests (pull_request) Successful in 37s
ddfbf50682
Fix grammar for comments and add test cases
All checks were successful
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m40s
Grammar / Corpus and binding tests (pull_request) Successful in 39s
5c34e69c24
Make test rebuild the grammar
All checks were successful
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m29s
Grammar / Corpus and binding tests (pull_request) Successful in 38s
e0fbbaf102
marfavi changed title from WIP: Tree sitter native to Tree sitter native 2026-10-02 10:34:27 +02:00
marfavi changed title from Tree sitter native to Use native tree-sitter bindings instead of web-tree-sitter 2026-10-02 10:36:47 +02:00
marfavi merged commit 139132cb49 into tree-sitter 2026-10-02 10:37:11 +02:00
marfavi deleted branch tree-sitter-native 2026-10-02 10:37:12 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code2rocq/crocq!7
No description provided.