A simple plugin to execute tasks in nvim using .vscode/tasks.json file
Lua
0
7 commits
updated Oct 4, 2026
A lightweight, single-file Neovim plugin that runs the tasks defined in your project's .vscode/tasks.json inside terminal buffers, with a Telescope picker and a clickable tab bar for switching between running tasks.
.vscode/tasks.json with Telescopeexecutable and args)presentation.focusUsing lazy.nvim:
return {
"HarshK200/taskspawner.nvim",
-- lazy load on key press
keys = { "<M-t>" },
-- lazy load on commands
cmd = { "TasksToggle", "Spawn", "SpawnPrevious" },
dependencies = {
"nvim-telescope/telescope.nvim",
},
config = function()
require("taskspawner").setup()
-- keymaps setup
vim.keymap.set("n", "<M-t>", "<cmd>SpawnPrevious<cr>")
end,
}
setup() takes no options. It registers the user commands and an autocommand that removes closed task buffers from the tab bar. Keymaps are up to you.
.vscode/tasks.json file in your project (see .vscode/tasks.json below) and open Neovim in the project root. The file is read from Neovim's current working directory.:Spawn and choose a task in the Telescope picker.:Spawn again to start another task; it opens in a new buffer and gets its own tab in the winbar.:TasksToggle to hide or show the terminal split.:SpawnPrevious to re-run the last task you picked.| Command | Description |
|---|---|
:Spawn | Opens a Telescope picker listing every task in .vscode/tasks.json and runs the selected one. |
:SpawnPrevious | Re-runs the task last selected with :Spawn. Reloads tasks.json and looks the task up by label. |
:TasksToggle | Closes the terminal split if open; otherwise reopens it with the existing task buffers. |
Notes:
:SpawnPrevious only knows about tasks picked with :Spawn in the current Neovim session. If none has been picked, it shows a warning.label no longer exists in tasks.json, an error is shown.:TasksToggle shows a warning if there are no task buffers to show..vscode/tasks.jsonTasks are read from .vscode/tasks.json in the current working directory each time you run :Spawn or :SpawnPrevious, so edits take effect immediately.
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "make build",
"presentation": {
"focus": false
}
},
{
"label": "build-and-run",
"command": "./build.sh && ./out/app",
"options": {
"shell": {
"executable": "sh",
"args": ["-c"]
}
},
"presentation": {
"focus": true
}
}
]
}
| Field | Type | Description |
|---|---|---|
version | string | Schema version (e.g. "2.0.0"). |
tasks | array | List of tasks. |
tasks[].label | string | Name shown in the picker and on the winbar tab. |
tasks[].command | string | Command to run. |
options.shell.executable | string | Shell used to run the command (optional). |
options.shell.args | string[] | Arguments passed to the shell before the command (optional). |
presentation.focus | boolean | Whether the terminal window keeps focus after the task starts. |
Include a presentation object with focus in every task. The plugin reads it unconditionally when a task starts.
If options.shell is set, the plugin builds the command as:
<executable> <args...> <command>
For the build-and-run task above that is sh -c "./build.sh && ./out/app". This is useful for running shell syntax such as && under a specific shell, for example sh.exe on Windows.
If options.shell is omitted, command is passed directly to Neovim's default shell handling.
Tasks run with Neovim's current working directory as their cwd.
"focus": true: the cursor stays in the task's terminal window."focus": false: the cursor returns to the window you were in when the task was started.'splitright' setting.require("taskspawner").switch_task(index) yourself, where index is the 1-based tab position.:TasksToggle closes only the window. Buffers and running jobs stay alive, and reopening shows the first task's buffer.:bwipeout), it is removed from the tab bar automatically.This plugin supports only a small subset of the VS Code task schema:
versiontaskslabelcommandoptions.shell.executableoptions.shell.argspresentation.focusOther VS Code task features are not supported and are ignored. This includes type, group, dependsOn, problemMatcher, args, options.cwd, options.env, input variables and platform-specific overrides.
Other things to be aware of:
:Spawn shows an error..vscode/tasks.json in the current working directory is used.:SpawnPrevious history is not kept between Neovim sessions.MIT, see LICENSE.
Lua
100.0%
A simple plugin to execute tasks in nvim using .vscode/tasks.json file
Lua
0
7 commits
updated Oct 4, 2026
A lightweight, single-file Neovim plugin that runs the tasks defined in your project's .vscode/tasks.json inside terminal buffers, with a Telescope picker and a clickable tab bar for switching between running tasks.
.vscode/tasks.json with Telescopeexecutable and args)presentation.focusUsing lazy.nvim:
return {
"HarshK200/taskspawner.nvim",
-- lazy load on key press
keys = { "<M-t>" },
-- lazy load on commands
cmd = { "TasksToggle", "Spawn", "SpawnPrevious" },
dependencies = {
"nvim-telescope/telescope.nvim",
},
config = function()
require("taskspawner").setup()
-- keymaps setup
vim.keymap.set("n", "<M-t>", "<cmd>SpawnPrevious<cr>")
end,
}
setup() takes no options. It registers the user commands and an autocommand that removes closed task buffers from the tab bar. Keymaps are up to you.
.vscode/tasks.json file in your project (see .vscode/tasks.json below) and open Neovim in the project root. The file is read from Neovim's current working directory.:Spawn and choose a task in the Telescope picker.:Spawn again to start another task; it opens in a new buffer and gets its own tab in the winbar.:TasksToggle to hide or show the terminal split.:SpawnPrevious to re-run the last task you picked.| Command | Description |
|---|---|
:Spawn | Opens a Telescope picker listing every task in .vscode/tasks.json and runs the selected one. |
:SpawnPrevious | Re-runs the task last selected with :Spawn. Reloads tasks.json and looks the task up by label. |
:TasksToggle | Closes the terminal split if open; otherwise reopens it with the existing task buffers. |
Notes:
:SpawnPrevious only knows about tasks picked with :Spawn in the current Neovim session. If none has been picked, it shows a warning.label no longer exists in tasks.json, an error is shown.:TasksToggle shows a warning if there are no task buffers to show..vscode/tasks.jsonTasks are read from .vscode/tasks.json in the current working directory each time you run :Spawn or :SpawnPrevious, so edits take effect immediately.
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "make build",
"presentation": {
"focus": false
}
},
{
"label": "build-and-run",
"command": "./build.sh && ./out/app",
"options": {
"shell": {
"executable": "sh",
"args": ["-c"]
}
},
"presentation": {
"focus": true
}
}
]
}
| Field | Type | Description |
|---|---|---|
version | string | Schema version (e.g. "2.0.0"). |
tasks | array | List of tasks. |
tasks[].label | string | Name shown in the picker and on the winbar tab. |
tasks[].command | string | Command to run. |
options.shell.executable | string | Shell used to run the command (optional). |
options.shell.args | string[] | Arguments passed to the shell before the command (optional). |
presentation.focus | boolean | Whether the terminal window keeps focus after the task starts. |
Include a presentation object with focus in every task. The plugin reads it unconditionally when a task starts.
If options.shell is set, the plugin builds the command as:
<executable> <args...> <command>
For the build-and-run task above that is sh -c "./build.sh && ./out/app". This is useful for running shell syntax such as && under a specific shell, for example sh.exe on Windows.
If options.shell is omitted, command is passed directly to Neovim's default shell handling.
Tasks run with Neovim's current working directory as their cwd.
"focus": true: the cursor stays in the task's terminal window."focus": false: the cursor returns to the window you were in when the task was started.'splitright' setting.require("taskspawner").switch_task(index) yourself, where index is the 1-based tab position.:TasksToggle closes only the window. Buffers and running jobs stay alive, and reopening shows the first task's buffer.:bwipeout), it is removed from the tab bar automatically.This plugin supports only a small subset of the VS Code task schema:
versiontaskslabelcommandoptions.shell.executableoptions.shell.argspresentation.focusOther VS Code task features are not supported and are ignored. This includes type, group, dependsOn, problemMatcher, args, options.cwd, options.env, input variables and platform-specific overrides.
Other things to be aware of:
:Spawn shows an error..vscode/tasks.json in the current working directory is used.:SpawnPrevious history is not kept between Neovim sessions.MIT, see LICENSE.
Lua
100.0%