Using Zig as a C/C++ Build System with Neovim

Hola todos,

Recently, I’ve been working on porting an old asteroids game written in C to Zig. Now, I’m at a stage where I’m thinking about extending the functionality of the game, but my knowledge of SDL is quite limited so I’m working my way through the tutorials written in C++. I’ve set up a simple build.zig file to work with the C++ files. Everything is wonderful. :innocent:

However, when I open the C++ source file in Neovim, it doesn’t know where the header files are. In the end, I wrote a makefile to build the files, and used Bear to generate the compile_commands.json which Neovim uses to locate the header files. My question is, is there a way to avoid having to write this makefile when using build.zig?

Gracias.

There is a simple example I made for a c++ project.

You can also chek this repo

I used the compile_commands.zig from there to generate the compiler database for clangd

2 Likes

Thanks, @a.maza.

I got it working :rocket: with the Zig 0.13.0 version and with the patch for version 0.14.0.

Cheers.