An asynchronous task system like VSCode on Vim This script written by vim9, make sure vim >= 9.1
- support terminal
- support quickfix
- support vim-floaterm
- list in LeaderF
You can visit wiki for details.
VSCode uses a .vscode/tasks.json
file to define project specific tasks. Similar, Tasks uses a .tasks.json
file in your project folders for local tasks and uses ~/.vim/tasks.json
for vim
to define global tasks for generic projects.
For vim-plug
Plug 'caoshenghui/vim-tasks'
Plug 'voldikss/vim-floaterm'
in your .vimrc
or init.vim
, then restart vim and run :PlugInstall
Start a task called taskname:
:TaskRun[!] taskname
Maybe you need to visit the Task configuration so that you can configure your tasks.
Example:
-
run your python file using vim-floaterm
{ "tasks": [ { "label": "test-run", "type": "floaterm", "options": { "cwd": "${workspaceFolder}" }, "command": "python3", "args": ["${file}"] } ] }
Run
:TaskRun test-run
, it will executepython3 ${file}
,${file}
and${workspaceFolder}
are predefinedvars.
If you want to use floaterm's options you can put it's options to json's typeOptions
.If you don't set floaterm's options in tasks.json, when you start a task, it's settings depend on floaterm's options
Example:
{
"type": "floaterm",
"typeOptions": {"autoclose": 0, "name": "vim-task", "position": "center"},
"command": "python3",
"args": ["${file}"],
"options": {
"cwd": "${workspaceFolder}",
},
"presentation": {
// when `panel='shared'`, it will reuse floaterm's windows next
"panel": "shared",
// if you omit `options['silent']`, `reveal` will decide whether silent
"reveal": "silent",
}
}
If you want to list tasks in LeaderF, you need configure the following option:
g:TasksUsingLeaderF = 1
Using :LeaderfTask
or :Leaderf --nowrap task
to start
skywind3000/asynctasks.vim
voldikss/vim-floaterm
Yggdroot/LeaderF
MIT