smhk

Setting up Zig on Windows for VS Code

TL;DR: On Windows, I recommend installing Zig via Scoop, then setting up the ZLS (Zig Language Server) with VS Code.

Install Scoop §

  1. Install Scoop.

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

Install Zig §

  1. Use scoop to install Zig:

    $ scoop install zig
  2. Query Zig version:

    $ zig version
    0.13.0

Install ZLS (Zig Language Server) §

ZLS provides better integration with Zig for editors that support LSP (Language Server Protocol).

  1. For Windows, go here and type in the Zig verson.
  2. Click “Prebuilt Binary”.
  3. Download the ZIP for OS: Windows, Arch: x86_64.
  4. Place it somewhere, e.g. C:\my_bin\zls-windows-x86_64-0.13.0.
  5. Add the location to your PATH: Edit the System Environment Variables → Environment Variables → System Variables → Path → Edit… → New.

Verify Zig and ZLS §

Open and shell (e.g. Git Bash) and verify that both zig and zls are on the PATH, and that the versions match:

$ zig version
0.13.0
$ zls --version
0.13.0

Set up VS Code §

Open VS Code.

  1. File → New Window.
  2. File → Add Folder to Workspace…
  3. Choose the location of your project.
  4. Ctrl + Shift + P → Extensions: Install Extensions
  5. Type “Zig”, choose “Zig Language”, and click Install.
  6. Respond to the following prompts:
Screenshot of Windows 7 Device Manager with hidden devices hidden
Choose Use Zig in PATH.
Screenshot of Windows 7 Device Manager with hidden devices hidden
Choose Use ZLS in PATH.

Verify Zig and ZLS integration §

  1. Open a ZIG source file. It should have syntax highlighting, which shows the Zig Language extension is working.
  2. Try something like right-clicking on a symbol and selecting Go to Definition. This shows that ZLS is working.