Minimal zig-ts-mode for emacs

https://codeberg.org/krl/zig-ts-mode

Hello all fellow emacsians, i have made a minimalist ts mode for emacs that i have been running for a while now.

The other zig-ts-modes i have found have either been incomplete or outdated, as well as containing a lot of stuff that i don’t need and/or understand (justfiles, tests).

Especially indentation has been flaky before, so far i think i’ve caught most edge cases here.

Happy to accept add (small) things that might be missing, but this along with eglot-zls covers all my personal use well.

6 Likes

I’ve not really become familiar with tree-sitter modes in Emacs. I can see they’re a lot easier to develop than traditional language modes such as https://codeberg.org/ziglang/zig-mode, but I’m not sure why I’d choose one over the other as a user.

Any insight?

I have not seriously attempted writing any modes except for tree sitter ones, but in general it’s about performance and correctness.

Using regex for parsing is slower, and in my experience error prone.

One example i’ve encountered recently is ‘janet-mode’, that completely breaks on the standard impl of janet, and gets confused what is a string or not halfway through.

What i like about tree sitter modes is that it deals solely with highligting and indentation, leaving any other functionality to better suited tools (lsp, reformatter)

Yesssss thank you! I’m a pretty new Emacs user and it seems like I’m dipping my toe in right as some nice quality of life improvements are landing in Emacs 31 (the improved tree-sitter stuff).