Smashes together the multi-command macros and ripgrep/fzf and then adds on top build commands that parse your zig build --help
output letting you select your build target easily.
- provides a parser for finding
zig build
targets - keyboard shortcut and VS Code commands for building the last target or choosing a target to build
- easy setup for debugging your last built target with CodeLLDB
cmd/ctrl+shift+r
runs thezig.buildLastTarget
command which will prompt you for a target the first time it is run and run it directly thereaftercmd/ctrl+shift+alt+r
runs thezig.buildTarget
command which will always prompt you for a target- you can also can wire those commands up to whatever keybindings you want or use the command palette to run them
- install the CodeLLDB extension
- add a launch.json file with the contents below
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Last Target",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/zig-cache/bin/${input:zigLastTarget}",
"args": [],
}
],
"inputs": [
{
"id": "zigLastTarget",
"type": "command",
"command": "zig.build.getLastTargetOrPrompt"
}
]
}
Open your tasks.json
file and create two new build tasks (the second is optional). Pay close attention to the input:
substitution in the build command and the relevant providers in the inputs
section.
{
"tasks": [
{
"label": "Build and Run Specific Target",
"type": "shell",
"command": "zig build ${input:zigTarget}",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
}
},
{
"label": "Build and Run Last Target",
"type": "shell",
"command": "zig build ${input:zigLastTarget}",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
}
}
],
"inputs": [
{
"id": "zigTarget",
"type": "command",
"command": "zig.build.getTargets",
},
{
"id": "zigLastTarget",
"type": "command",
"command": "zig.build.getLastTargetOrPrompt"
}
]
}
The key is to use the commands exposed by the extension as input for your own tasks.
zig.build.getTargets
: parses your build targets and provides a selection list to choose the one to executezig build TARGET
zig.build.getLastTargetOrPrompt
: if a previous target was used this skips parsing the build targets and just runs it, else it is that same aszig.build.getTargets
Note that zig
must be in your PATH
!
These settings allow you to create command sequence as one command and bind a key to run them or use the command palette (via the "Multi command: Execute multi command" entry). Commands are defined in your settings.json
file in the zig.multiCommand.commands
array.
See the documentation for details on use.
- install npm and the ludicrious amount of cruft it requires
- install Visual Studio Code Extensions
npm install -g @vscode/vsce
- install TypeScript and the ludicrous amount of cruft it requires (
npm install typescript -g
) - install ESBuild
npm i --save-dev esbuild
- run
npm install
to download a pile of dependency cruft - run
npm run compile
- run
vsce package
to generate thevsix
file