Minimal Zig language support for Geany 2.0, packaged
as a drop-in filetype plus a Build menu. Geany 2.0 has no built-in Zig lexer, so
this defines Zig as a custom filetype that reuses the C lexer/tag-parser for
"good enough" syntax highlighting and a symbol tree, adds Zig's keyword set, and
wires the zig toolchain into Geany's Build menu.
Tested on Geany 2.0 (GTK 3.24, Debian 13) with Zig 0.17.0-dev. It is plain configuration — no plugin, no build step — so it should work on any Geany 2.x.
-
Syntax highlighting for Zig keywords and primitive types (via the C lexer).
-
Symbol tree / function list (via the C tag-parser) — approximate but useful.
-
Build menu entries:
Menu item Command Compile zig build-exe "%f"Build zig buildFormat zig fmt "%f"Run zig run "%f"Test zig test "%f" -
Sensible defaults: 4-space indentation,
//line comments,.zig+.zonrecognized.
- Geany ≥ 2.0
- Zig — either on your
PATH, or installed somewhere you can point at (see Makingzigresolvable below).
geany-zig-support/
├── filedefs/filetypes.Zig.conf the Zig filetype definition
├── install.sh copy it into place + map .zig/.zon
├── uninstall.sh remove it
├── optional/environment.d/90-zig.conf optional PATH helper for GUI launches
├── README.md
└── LICENSE
Close Geany first. Geany reads filetype files only at startup and rewrites the
[build-menu]section from memory when it exits — so a running Geany would overwrite the install when you close it.
./install.shIf zig is not on your PATH, pass an absolute path and the Build menu will use
it directly:
ZIG_BIN="$HOME/apps/zig/zig" ./install.shcp filedefs/filetypes.Zig.conf ~/.config/geany/filedefs/
# then ensure ~/.config/geany/filetype_extensions.conf contains, under [Extensions]:
# Zig=*.zig;*.zon;Start Geany, open a .zig file, and use Build (or the keyboard shortcuts).
The Build menu calls zig. If it isn't found you'll see, in the run terminal:
.../geany_run_script_XXXX.sh: 7: zig: not found
(program exited with code: 127)
Exit code 127 = "command not found": the zig binary isn't on the PATH that
Geany inherited. Pick whichever fits how you launch Geany:
| How you launch Geany | Where to put ~/apps/zig (or your install dir) on PATH |
|---|---|
| From a terminal | ~/.bashrc (interactive shells) |
| Login shell | ~/.profile (login shells) |
| From a menu / dock / IDE | ~/.config/environment.d/90-zig.conf — see optional/. The systemd user session reads this at login, and GUI apps inherit it. Requires logout/login. |
| Don't want to touch PATH | Re-run ZIG_BIN="/abs/path/to/zig" ./install.sh to bake an absolute path into the Build menu. |
The absolute-path route is the most robust (works immediately, no logout) and is harmless once PATH is also fixed.
- Geany loads filetype files only at startup — restart it after installing.
- Geany re-serializes the
[build-menu]from memory on exit, so always edit the config (or run the scripts) with Geany closed, or your changes vanish. - The run script under
/tmp/geany_run_script_*.shis deleted as soon as the program exits — it's a disposable wrapper, not something to edit.
./uninstall.sh # Geany closedRemoves ~/.config/geany/filedefs/filetypes.Zig.conf and the Zig=*.zig;*.zon;
line from filetype_extensions.conf.
This configuration was authored, debugged, and packaged interactively with Claude Code — Anthropic's CLI coding agent (model: Claude Opus). The AI specifically helped to:
- Craft the Zig keyword and primitive-type lists and the C-lexer-based
[styling=C]filetype, since Geany 2.0 has no native Zig lexer. - Tweak the Build menu commands (
zig build-exe / build / fmt / run / test) and the editor defaults (indentation, comment style,.zig/.zonmapping). - Diagnose a real
zig: not found(exit 127) failure when running builds from Geany — tracing it to the GUI/systemd-user-sessionPATHnot including the local Zig build — and apply the absolute-path workaround. - Install it on the author's machine and isolate it into this documented, reusable bundle (these scripts + this README).
Everything was verified by running it, not taken on faith: the filetype was installed, Geany was launched, and a Zig program was built and run to a clean exit (code 0) before this was published. If you reuse or modify it, treat the config as a starting point and re-verify against your own Geany / Zig versions.
MIT — see LICENSE.