Grabs zig bindings for tree-sitter
Find a file
Grace Yoder 1a6b1024e1
All checks were successful
ci/crow/push/test Pipeline was successful
fix: various
2026-07-17 20:11:23 -06:00
.crow fix: various 2026-07-17 13:57:30 -06:00
src fix: various 2026-07-17 20:11:23 -06:00
.gitignore init 2026-07-15 21:35:27 -06:00
build.zig fix: various 2026-07-17 20:11:23 -06:00
build.zig.zon fix: various 2026-07-17 13:57:30 -06:00
languages.md fix: various 2026-07-17 20:11:23 -06:00
LICENSE init 2026-07-15 21:35:27 -06:00
README.md misc: readme update 2026-07-15 21:52:23 -06:00

EZTS

Easy Zig Tree Sitter

Managed Grammars and Highlight Queries for use with Tree-Sitter Zig Bindings

How to use

Grab Dependencies

zig fetch --save git+https://github.com/tree-sitter/zig-tree-sitter.git

# official source
zig fetch --save git+https://git.gae.moe/grace/eazy-zig-tree-sitter.git
# mirrors
zig fetch --save git+https://github.com/gyoder/eazy-zig-tree-sitter.git
zig fetch --save git+https://tangled.org/grace.pink/eazy-zig-tree-sitter.git

build.zig

const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const ezts = b.dependency("eazy_zig_tree_sitter", .{
        .target = target,
        .optimize = optimize,
        .use_all_langs = false
        .use_langs = &.{"c", "js", "ts", "py", "rs"},
        .third_party = true,  // optional, for community grammars
    });

    const exe = b.addExecutable(.{
        .name = "my_project",
        .root_module = b.createModule(.{
            .root_source_file = b.path("src/main.zig"),
            .target = target,
            .optimize = optimize,
            .imports = &.{
                .{ .name = "eazy_zig_tree_sitter", .module = ezts.module("eazy_zig_tree_sitter") },
                .{ .name = "tree-sitter", .module = ezts.module("tree-sitter") },
            },
        }),
    });
    b.installArtifact(exe);
}

main.zig

const std = @import("std");
const ts = @import("tree-sitter");
const ezts = @import("eazy_zig_tree_sitter");

pub fn main() !void {
    const source =
        \\fn fib(n: u32) u32 {
        \\    if n < 2 { return n; }
        \\    return fib(n - 1) + fib(n - 2);
        \\}
    ;

    const lang = (ezts.getLang("rs") orelse return error.NoLang).?;
    defer lang.destroy();

    var parser = ts.Parser.create();
    defer parser.destroy();
    try parser.setLanguage(lang);

    const tree = (parser.parseString(source, null) orelse return error.ParseFailed);
    defer tree.destroy();

    std.debug.print("tree: {s}\n", .{tree.rootNode().string()});
}

LLM Notice

An LLM was used to aggregate dependencies. It was not used in any of the (quite minimal) logic of this repo. That was all done by hand by me without LLM influence.