feat(zig): add Zig 0.16+ language support#1
Open
guysenpai wants to merge 3 commits into
Open
Conversation
Tree-sitter-zig WASM from tree-sitter-wasms, no native build required. Extracts: top-level functions, structs with fields/methods, enums, error sets (as enums), @import statements, test declarations, and function calls. Pub/private visibility is detected from the anonymous `pub` token. Known limitation: comptime-generated types (e.g. `fn Foo(comptime T: type) type { return struct {...}; }`) are not extractable at the AST level and are documented in zig.ts. https://claude.ai/code/session_017AQjdPam3enwct9vFi4G1S
Adds **/*.zig and **/*.zon to DEFAULT_CONFIG.include so the CLI picks up Zig sources without manual config. Documents the new language support and the comptime-type limitation in CHANGELOG. https://claude.ai/code/session_017AQjdPam3enwct9vFi4G1S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tree-sitter-zig, indexing.zigand.zonfiles@import(as import nodes with unresolvedimportsreferences),pubvisibility, plain constants/variables, andtest "..." { ... }blocks (as functions)**/*.zigand**/*.zontoDEFAULT_CONFIG.includeso the scanner picks them up out of the boxImplementation notes
src/extraction/languages/zig.ts(modelled afterrust.ts)src/extraction/languages/index.tszigadded toLANGUAGESconst insrc/types.tstree-sitter-wasmspackage (no local wasm file needed)isInsideClassLikeNode()scope-stack mechanism intree-sitter.ts— no changes to core extractorsparametersAST node has no field name, sogetSignaturefinds it by type instead ofgetChildByFieldpubis an anonymous token in the tree-sitter-zig grammar — detected by iterating childrenKnown limitation (documented in code + CHANGELOG)
Comptime-generated types like
fn Physics(comptime R: type) type { return struct { ... }; }are not resolvable at the tree-sitter level (would require full type inference). Methods on such types are not extracted.Test plan
__tests__/extraction.test.tsunderdescribe('Zig Extraction', ...)covering: function declarations (pub/private), signatures, structs + fields, struct methods + containment, enums + members, error sets,@import(simple + chained), constants/variables, test blocks, function callsnpm run test→ 531/531 pass (withGIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=falseto bypass the unrelated test-env GPG signing failures)npm run build→ cleancallsedge between Zig nodesGenerated by Claude Code