hedzr/vscode-ext-zig-main-runner
run or debug a zig main function in-place
Run or Debug zig main function in-place.
Also, Run or Debug test cases, build the whole workspace.
See the CHANGELOG.
This extension adds few commands for Zig development:
We add some codelens links at the top of function main(), tests, and first line of a zig file, like the following
Our inspirations are from go-main-runner, and zig-language-extras.
You may disable or enable vscode codelens totally.
With settings:
"zig-main-runner.main.enableCodeLens": false,
Default is true.
You may enable or disable vscode codelen for test cases.
With settings:
"zig-main-runner.main.enableCodeLensForTests": true,
Default is false(disabled).
You may add additional test command arguments.
With settings
{
"zig-main-runner.test.args": "--deps zlib=zlib --mod zlib::../zig-zlib/src/main.zig --library z",
}
But why?
The launching of main() function will be emitted to a Terminal window (as a vscode Task or a normal terminal session). By default, launching it as a Task allows you reinvoke it easily (by using vscode command Tasks: Rerun Last Task)
TIP
Requesting a keybinding to it is a good hit. Our private
keybindings.jsonis a reference:[ { "key": "cmd+; cmd+;", "command": "workbench.action.tasks.reRunTask" } ]It is useful while you are invoking
main.zigagain and again.
When you're debugging with Zig build.zig, only a main() whom has same name with its directory name can be supported because we have no plan to analysis build.zig for multiple executables. This structure is good:
<root>
- src/
- example/
main.zig # exe target should be named to 'example'
main.zig # exe target should be named to '<root>'
build.zig
This works by running zig build.
This works by running zig build test.
We assume the debugger is in your PATH to debug main() function or test cases.
To avoid unnecessary dependencies, our extension has only one dep to zig laguage. Here's some extensions for debugging:
But, you could manage the debuggers with OS package managers.
The default debugger types for each platform are as follows:
Users appreciate release notes as you update your extension.
First public release
Enjoy!