Ctags for zig

Is there a tool to generate tag file that includes the definitions and references for functions/methods/procedures and global variables?
I know of ZLS but I have my setup for c and would like to keep using my etags.

If not, I would like to make one but at the moment I have a hard time using zig AstGen so if someone has an example of a project parsing zig files it would be appreciated

I haven’t used it, but I am aware of this project gpanders/ztags: Generate tags files for Zig projects. - Codeberg.org

Thanks, I looked into it a while ago and couldn’t make it to work. I will try again. Thank you again.

Wow. I was curious, and built it successfully, with two different patches to bring it up-to-date WRT zig 0.14.0, and try and deal with the tabs. But really, zig doesn’t allow tab characters inside of string literals? How does one deal with this? The ‘naive’ way (replacing literal tabs by \t) isn’t the way. And yeah there’s tools out there we might wanna generate TSV for, surely we want to allow tabs in strings?

First difference occurs on line 3:
expected:
MyEnum\ta.zig\t/^const MyEnum = enum {$/;"\tenum
      ^ ('\x5c')
found:
MyEnum	a.zig	/^const MyEnum = enum {$/;"	enum
      ^ ('\x09')

ztags.patch.txt (5.4 KB)

Even worse it doesn’t allow tabs in comments, so anyone who uses tabs can’t comment out code.
Here is the relevant issue defining the specificiation: grammar clarifications regarding tabs and carriage returns · Issue #38 · ziglang/zig-spec · GitHub

std.testing.expectEqualStrings probably needs to learn how to deal with \t vs. at the very, very least. Also other supported escape sequences - it just does a std.mem.indexOfDiff which doesn’t handle escape sequences.

EDIT/Addition: the above is/was factually wrong. The error cause is/was multi-line strings not supporting escape sequence, as per design and documentation, which slipped me. expectEqualStrings is fine as-is.

I just used zig 0.13.0 and it compiled successfully but emacs complains that the tag file is formatted poorly. I have no knowledge in tag file format so I don’t know if it is a problem in my emacs setup

if you compiled successfully, I asume you ran zig fmt on it implicitly and zig fmt has replaced the tabs by spaces and that’s not a valid tags file. Or emacs did. Tags are TSV.

it is true that tags file generated was not a tsv file but I just removed the first two lines:

!_TAG_FILE_SORTED	1	/1 = sorted/
!_TAG_FILE_ENCODING	utf-8

and I managed to read it with python pandas

import pandas as pd
print(pd.read_csv("new_tags",sep="\t"))

but emacs still complains. I will just use the good old search regex and thankfully andrew made function definition saner than c