Creating Lua modules (aka Neovim plugins) with Zig

If you’re a Neovim user like myself, and love tinkering with your Neovim configs in Lua, you might have wondered - can I write a Neovim plugin in Zig? Well, the answer is yes! The Lua C API is quite elegant, and as it turns out, it’s extremely easy to create a shared library compatible with Lua using Zig.

Check out a complete (but minimal) example on my Github here.

And if you’re wondering, why bother? Well, my end goal is to connect my (WIP) Markdown parser and renderer with Neovim to get a sort of VSCode-style “Preview Pane” plugin. Of course, the simple option is to just compile it as an executable and run it via a system command, but the thought of a tight integration sounds :ok_hand:

11 Likes