Setup Neovim With Zig

Table of Contents
Update: 25 May 2025
After trying many different setups, I’d recommend you not read any furthter and use kickstart.nvim. It is very simple, a near one shot setup and works out of the box. You may have to set your zls version separately sometimes if you run into issues, but overall, I highly recommend it for a quick and easy setup.
Video outlining the process: https://www.youtube.com/watch?v=m8C0Cq9Uv9o
Here is what I do to configure Neovim to work with Zig for syntax highlighting and the language server:
Skip to just the files
You will need the following: #
- A MacOS device
- Neovim >=0.8 installed
- Zig installed
zlsversion that matches the Zig version above installedtree-sitter-cliinstalled (can use homebrew:brew install tree-sitter)
Configuration: #
1. Install a Neovim package manager #
I used the lazy.nvim package manager for Neovim. Install it like this:
git clone --filter=blob:none https://github.com/folke/lazy.nvim.git ~/.local/share/nvim/lazy/lazy.nvimThen we configure Neovim to use lazy.nvim. Edit the file ~/.config/nvim/init.lua and add:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)Restart Neovim to check if the installation succeeded. You should be able to bring up the lazy.nvim interface by typing :Lazy in Neovim. Exit it by using :q
2. Add the relevant plugins for Zig #
We are going to use the nvim-lspconfig to setup zls and tree-sitter for syntax highlighting. So let’s first install those as plugins from lazy.nvim.
Add these lines to your ~/.config/nvim/init.lua:
| |
Restart your Neovim and let the plugins get installed.
3. Configure the plugins #
We only need to setup nvim-lspconfig so create a directory called lua in your ~/.config/nvim directory. Create a file lsp.lua in that directory:
~/.config/nvim/lua/lsp.lua contents:
| |
Next we have to edit our ~/.config/nvim/init.lua to use the plugins in neovim. Add the following to your init.lua:
require("lsp")
require("nvim-treesitter.configs").setup {
ensure_installed = { "zig" },
highlight = { enable = true },
}Restart your Neovim if you had it open and you should be all set. Here’s the full contents of all files:
TL;DR Just the contents of the files: #
~/.config/nvim/init.lua:
| |
~/.config/nvim/lua/lsp.lua:
| |