The Zig SDK is capable of integrating with ZLS and clangd. This means that any editor with support for those language servers (e.g. Visual Studio Code) can be used to edit a project using the Zig SDK.
Start by installing ZLS. The Visual Studio Code extension is highly recommended.
At the moment, no further configuration is necessary.
Start by installing clangd. The Visual Studio Code extension is highly recommended.
You have to tell clangd where to find the compile_commands.json
compilation database. The Zig SDK creates these files in IntermediateOutputPath
, i.e. obj/Debug/linux-x64
if you build with Configuration=Debug
and RuntimeIdentifier=linux-x64
. Due to the nature of C/C++ compilation, these compilation databases have to be dependent on build flags. So, you will have to pick one of them to use for your editing experience. The good news is that you can change which compilation database you use at any point if you need to.
To tell clangd where to find the compilation database, create a file called .clangd
in your project directory with the following contents:
(You may want to add this file to .gitignore
.)
You can now restart the clangd language server. You should start to see rich editor features like code completion, hover widgets, navigation, etc.