Regarding to Command, vscode has a mechanism named Command, which can be used as Command Variable
If the predefined variables from above are not sufficient, you can use any VS Code command as a variable through the ${command:commandID} syntax.
A command variable is replaced with the (string) result from the command evaluation. The implementation of a command can range from a simple calculation with no UI, to some sophisticated functionality based on the UI features available via VS Code's extension API. If the command returns anything other than a string, then the variable replacement will not complete. Command variables must return a string.
For example, vscode-cmake-tools extension support lots of command variable, which can be used in launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
"cwd": "${workspaceFolder}",
"environment": [
{
// add the directory where our target was built to the PATHs
// it gets resolved by CMake Tools:
"name": "PATH",
"value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
}
]
}
]
}
What did I do
I add API named dap.register_command(identifier, handler) to do something same to vscode.commands.registerCommand . Which can help extension developer to enhance ability of dap.
e.g.
require("dap").register_command("cmake.launchTargetPath", function()
// run cmake build task, then return executable path
// can be a asynchronous coroutine
return coroutine.create(function()
// fake cmake build step
vim.defer_fn(function()
coroutine.resume(co, "/path/to/exectutable")
end, 2000)
end)
end)
Register command mechanism
Regarding to Command, vscode has a mechanism named
Command
, which can be used as Command VariableFor example, vscode-cmake-tools extension support lots of
command variable
, which can be used in launch.jsonWhat did I do
I add API named
dap.register_command(identifier, handler)
to do something same to vscode.commands.registerCommand . Which can help extension developer to enhance ability of dap.e.g.
Some Unit Test Added