ZigVS
Add support for using the Zig programming language to Visual Studio 2022
Note: This is an early work in progress release. Please submit feedback to help us improve this extension.
Note: The recommended setup method for Zig and ZLS has been changed to specifying the PATH environment variable.
Features
- Edit Zig code with Visual Studio Editor
- Zig language syntax highlighting
- Zig Language Server (ZLS) support (completions, tooltips, find references and more)
- Snippets
- Document Formatting
- Open Folder mode
- Build from Visual Studio using build.zig
- Zig Build System provides cross-platform build.
- Application templates [new!!]
- Project File mode
- Build from Visual Studio using project files
- Supports cross-platform build (windows, linux, Android, iOS, macOS, WASI / x86, x64, arm, arm64, wasm32) [new!!]
- Application, library, file templates
- build.zig and build.zig.zon generation from project file
- Debug Zig code with Visual Studio Debugger
- Support the Windows Native Debug Engine and MIEngine for cross-platform debugging (Linux, Android, MacOS, iOS) [new!!]
- Run code tests using Visual Studio Testing Tools
- Supports Visual Studio Profiler Tools
- CPU Usage, Memory Usage, Events, File I/O
- Zig Toolchain Installer
- Zig Package Installer
Install ZigVS from [Extensions] → [Manage Extension] or from Visual Studio Marketplace
[Extensions] → ZigVS → [Zig Toolchain Installer]
3.ToolChainInstaller window will be opened
a. Select Zig Toolchain Version
b. Select ZLS Version
c. Set Install Directory
d. Select if you set Environment Value 'PATH'
- Once everything is set up, the Install button will become active, so press the Install button
- The progress and results of the installation will be displayed in the output window
- You might need restart your Visual Studio
Note: If you see "Access to the path '....' is denied", the following scenarios might be considered
* File in use: Please close the application that is opening the file
* Directory without write permission: Please restart Visual Studio as Administrator
How to Set Up Manually
Install ZigVS from [Extensions] → [Manage Extension] or from Visual Studio Marketplace
Zig Compiler:
Download Zig and extract it to your desired location.
ZigVS has been tested with Zig ver 0.13.0.
ZLS Language Server:
Download Zig Language Server (zls) and place it in the same directory as the Zig Compiler.
Note: At the moment, there are compatibility issues between zls and the Language Client of Visual Studio 2022. To resolve this, it is necessary to modify the metaModel file of the language server protocol and rebuild zls accordingly. However, as this process is expected to take some time, a temporary solution is provided here with a working version.
Binary
Source code
The tools path can be set in any of these ways.
a. Add the directories containing the Zig compiler and ZLS to the 'PATH' environment variable (recommendation)
b. Set the ZIG_TOOL_PATH environment variable to a directory with Zig compiler and ZLS binaries
(The path specified for ZIG_TOOL_PATH needs to end with a backslash '' )
c. Set the paths in the [Tools] → [Options...] → ZigVS settings page inside VS 2022.
d. Set the tool path in Visual Studio project properties (Project mode only)
How to use
ZigVS supports Open folder mode and Project file mode
Open folder mode
Open a folder with an existing zig project.
Uses the zig build system with a build.zig file.
Project file mode
Create and manage zig projects (.zigproj) using the VS2022 IDE.
Use the zig compiler along with MSBuild and VS2022 project management.
Link C/C++ libraries and zig libraries in a VS2022 solution file.
To start with open folder mode
A. If creating a new Zig package:
A-1. Select [File] → [New] → [Zig Package (zig.exe init)].
A-2. Select the directory and package name, choose whether to open the folder, and then press the create button.
B. If selecting a template
B-1. Use the wizard and select [Create a new project].
The project template supports both project mode and open folder mode.
C. If opening an existing Zig Package:
C-1. Use the wizard and select [Open a local folder], then choose the folder containing Build.zig.
D. Select [File] → [Open] → [Folder] and choose the folder containing Build.zig.
To select the Build.zig to use, right-click on it and choose [Set as Startup Item].
The [Build] menu, [Debug] menu, [Start] button, and [Configuration] selection pull-down are enabled and you can start working.
If you want to change settings, select [Tools] → [Options] and make changes in the Options window under [ZigVS].
To start with project file mode
From the wizard, select [Open a project or solution] or [Create a new project]
Select a Zig template and use the Wizard to create the project.
To change settings, open the project Property Pages.
The [Build] menu, [Debug] menu, [Start] button, and [Configuration] selection pull-down are enabled and you can start working.
See User Manual Page
Profiler
- [Debug] > [Start Debugging] (or Start on the toolbar, or F5).
When the app finishes loading, the Summary view of the Diagnostics Tools appears. If you need to open the window, click Debug > Windows > Show Diagnostic Tools.
- When you choose Record CPU Profile, Visual Studio will begin recording your functions and how much time they take to execute. You can only view this collected data when your application is halted at a breakpoint.
Testing
To perform tests, select [Test] → [Test Explorer] to open the Test Explorer window. If .zig source code includes unit tests, their filenames will be listed.
Package Installer
1, [Extensions] → ZigVS → [Zig Package Installer]
2, Browse to the repository and branch that you want to install in the WebView.
3, Select a Installation Method from the dropdown.
Currently, git and unzip are working correctly.
4. Once everything is set up, the Install button will become active, so press the Install button
Editor Setting
[Tools]→[Options]→[Text Editor]→[Zig]
Syntax Highlighting
Example of changing Literals and Operators
You can change the colors and fonts of the Syntax Highlighting. It is possible to create a more color-coded and visually appealing screen than the default settings of Visual Studio. The following Display Items can be modified.
- Plain Text
- Comment
- Keyword
- Literal
- Operator
- String
- Type
- Inlay Hints - Parameters
- Inlay Hints - Types
[Tool]→[Environment]→[Fonts and Colors]→[Display items]
Snippets
- Open Snippet manager
[Tool] → [Code Snippets Manager] → [Zig]
- Insert Snippets
Right-click in the code editor → Snippets → [Insert Snippet]
Note: Code snippets: what they are and how to add one
Right-click in the solution explorer and select ‘zig fmt’
Help
[Extensions] → ZigVS → [User Manual Page]
Questions, Requests, etc.
Please use the Q&A page on Visual Studio Marketplace. Support is available in both English and Japanese.
Version History
Version 0.13.0.12 (2024/08/17):
The user manual for ZigVS, which was included in the Visual Studio extension package,
has been removed from the package to reduce its size by hosting it on GitHub.
Updated the packages that ZigVS depends on.
Corrected some spelling errors.
Fixed minor bugs.
Compatibility:
Visual Studio 2022 17.11.0
Zig Tool chain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.13.0.11 (2024/08/15):
In the previous version of ZigVS, unit tests could only be managed and executed on
a file-by-file basis from the Test Explorer. Now, they can be managed and executed individually.
Additionally, it is now possible to debug unit tests from the Test Explorer.
Compatibility:
Visual Studio 2022 17.10.5
Zig Toolchain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.13.0.10 (2024/08/11):
You can now toggle inlay hints on and off using Alt + F1.
We fixed the issue where typing '_' would prematurely end the completion.
Compatibility:
Visual Studio 2022 17.10.5
Zig Toolchain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.13.0.9 (2024/07/08):
In Open Folder mode
the debugger and tests now function correctly even when you open a folder higher than the one containing build.zig.
We have accelerated the startup of the debugger from the second time onward.
Compatibility:
Visual Studio 2022 17.10.3
Zig Toolchain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.13.0.8 (2024/07/07):
Due to a bug in the extension installer, an exception occurred when creating a new project unless the user manually installed Desktop Development with C++. We have fixed the installer to ensure that the necessary components are installed automatically.
We have improved the error messages to make the situation clearer when zig.exe or zls.exe cannot be found.
We have made the behavior of the key to confirm autocomplete similar to C#.
Compatibility:
Visual Studio 2022 17.10.3
Zig Toolchain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.13.0.3 (2024/06/18):
We have fixed the issue where you had to type the key twice for autocomplete.
Compatibility:
Visual Studio 2022 17.10.1
Zig Toolchain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.13.0.2 (2024/06/17):
You can now create a new Zig package by going to [File] → [New] → [Zig Package].
The project template now includes build.zig, so the project can be built from both build.zig and .zigproj files.
Compatibility:
Visual Studio 2022 17.10.1
Zig Toolchain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.13.0.1 (2024/06/11):
We have released the compatible ZIGVS version due to the release of ZIG and ZLS version 0.13.0.
We have added support for building WebAssembly (WASM).
We have modified the message for cases where tests are skipped due to compilation errors.
We have improved the icons and logos.
Compatibility:
Visual Studio 2022 17.10.1
Zig Toolchain: zig-windows-x86_64-0.13.0.zip
ZLS Language Server: 0.13.0.VisualStudioCompatible
Version 0.12.0.4 (2024/05/26):
1, The project file generated for new projects now supports incremental builds. This prevents unnecessary zig builds.
2, The UI for setting modules in the project properties has been changed to allow multi-line editing instead of a single line.
3, The 'zig fetch' command now runs correctly for package installation through the package installer. Previously, the command was given a GitHub zip file, but zig couldn't handle the zip properly. Switching to .tar.gz resolved the issue.
Compatibility:
Visual Studio 2022 17.10.0
Zig Toolchain: zig-windows-x86_64-0.12.0.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
Version 0.12.0.3 (2024/05/23):
We have added an explanation on how to further color-code using Syntax Highlighting.
To fix the issue with ZLS not functioning correctly, the recommended setup method for the Zig Toolchain has been changed from using the ZIG_TOOL_PATH environment variable to using the PATH environment variable. Consequently, the installer has also been modified to set the PATH.
Compatibility:
Visual Studio 2022 17.10.0
Zig Toolchain: zig-windows-x86_64-0.12.0.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
Version 0.12.0.2 (2024/05/13):
In ZigVS unit tests, we use the 'zig.exe test' command,
but the result output format of the test command was changed in Zig 0.12.0.
We have fixed cases where ZigVS could not correctly retrieve the test results.
Additionally, if the output of 'zig.exe test' changes in the future and ZigVS can no longer read it,
an error message will now be displayed to indicate this.
Compatibility:
Visual Studio 2022 17.9.6
Zig Toolchain: zig-windows-x86_64-0.12.0.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
Version 0.12.0.1 (2024/05/07):
We have released the compatible ZIGVS version due to the release of ZIG and ZLS version 0.12.0.
Replace zig logo
Compatibility:
Visual Studio 2022 17.9.6
Zig Toolchain: zig-windows-x86_64-0.12.0.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
Version 0.1.8 (2024/03/23):
cross-platform build and debug
fix a bug ZigVS disables CMake Project Debugger
Compatibility:
Visual Studio 2022 17.9.3
Zig Toolchain: zig-windows-x86_64-0.12.0-dev.1849+bb0f7d55e.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
Version 0.1.6 (2024/02/24):
Add Package Installer
Compatibility:
Visual Studio 2022 17.9
Zig Toolchain: zig-windows-x86_64-0.12.0-dev.1849+bb0f7d55e.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
Version 0.1.5 (2024/01/28):
Visual Studio Profiling Tools are working
Miner Bug fix
Compatibility:
Visual Studio 2022 17.8.5
Zig Toolchain: zig-windows-x86_64-0.12.0-dev.1849+bb0f7d55e.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
Version 0.1.4 (2024/01/21):
Add Snippets Manager
Version 0.1.3.1 (2024/01/14):
ToolChainInstaller
Add check if install path already exists
Add extract directory even if it is empty
Version 0.1.3 (2024/01/14):
Project Property
Header files directory field handles both relative and absolute paths
Add library list and library directory fields
Implemented modules and dependencies field
Fix an issue where the User Manual does not appear in some cases
Add Zig Toolchain Installer Window
Version 0.1.2 (2024/01/07):
Add file icon
Support document formatting
Version 0.1.1 (2023/12/30):
Fix the issue of not being able to specify the output destination in project mode
Add editor settings
Version 0.1 (2023/12/26):
Initial release
Compatibility:
Zig Toolchain: zig-windows-x86_64-0.12.0-dev.1849+bb0f7d55e.zip
ZLS Language Server: 0.12.0.VisualStudioCompatible
License
Refer to the LICENSE.txt file for licensing information.
Extension Name
ZigVS
Publisher
LuckyStar Studio LLC