Documentation
¶
Overview ¶
This script automates fetching and setting up Tree-sitter grammars for a Go project. It is a necessary workaround for `go mod vendor`, which fails to include the required C source files.
The script performs three main steps:
1. **Fetch Runtimes:** Downloads the `go-tree-sitter` Go wrapper and the core `tree-sitter` C library, arranging them into a single, CGO-compatible package.
2. **Apply CGO Fixes:** To prevent common build errors, it performs two critical fixes:
- Deletes `lib.c` (a unity build file) to avoid "multiple definition" linker errors.
- Patches Go files to remove the corresponding `#include "lib.c"` line.
3. **Fetch Grammars:** It reads `grammars.yaml` and downloads each specified language grammar, extracting its C source (`src/`) and Go bindings (`bindings/go/`).
Click to show internal directories.
Click to hide internal directories.