Skip to content

arkenidar/geany-zig-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geany Zig support

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.

What you get

  • 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 build
    Format zig fmt "%f"
    Run zig run "%f"
    Test zig test "%f"
  • Sensible defaults: 4-space indentation, // line comments, .zig + .zon recognized.

Requirements

  • Geany ≥ 2.0
  • Zig — either on your PATH, or installed somewhere you can point at (see Making zig resolvable below).

Files

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

Install

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.sh

If 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.sh

Manual install (equivalent)

cp 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).

Making zig resolvable

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 quirks worth knowing

  • 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_*.sh is deleted as soon as the program exits — it's a disposable wrapper, not something to edit.

Uninstall

./uninstall.sh   # Geany closed

Removes ~/.config/geany/filedefs/filetypes.Zig.conf and the Zig=*.zig;*.zon; line from filetype_extensions.conf.

How this was built (AI-assisted)

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/.zon mapping).
  • Diagnose a real zig: not found (exit 127) failure when running builds from Geany — tracing it to the GUI/systemd-user-session PATH not 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.

License

MIT — see LICENSE.

About

Zig language support for Geany 2.0 — custom filetype + Build menu (AI-assisted, built with Claude Code)

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages