Neovim Plugin to use build tasks similar to VScode
Note: this plugin is still in development and there might be some breaking changes
- Reads taks from a json file
- Very similar to VScode's
task.json
- Runs default build task in terminal
- Written in Lua, configured in Lua
- Neovim v0.6.0+ or nightly build
Recommended is to use packer.nvim
use({
'Arjun31415/BuildTask.nvim',
requires="rcarriga/nvim-notify"
})
The plugin config with default values-
require('buildtask').setup({default_shell = "$SHELL", default_task_file="task.json"})
<default_task_file>.json
config-
This file must be present in the working directory and must adhere to strict json format. An example file is given below-
{
"tasks": [
{
"type": "python run",
"label": "Python run active file",
"command": "/usr/bin/python",
"args": ["${file}"],
"options": {
"cwd": "${fileDirname}"
},
"group": {
"kind": "build",
"isDefault": true
},
"detail": "interpreter: /usr/bin/python"
},
{
"type": "cppbuild",
"label": "C/C++: g++-11 build active file",
"command": "/bin/g++",
"args": [
"-g",
"${file}",
"-std=c++20",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": false
},
"detail": "compiler: /bin/g++"
}
]
}
Field | Value | Type |
---|---|---|
tasks | An array of tasks to perform | Required |
type | The type of task it is | Optional |
label | label given to this task | Optional |
command | the command/executable which runs this task | Required |
args | the space separated command line arguments array to give to the executable specified in the command field. |
Required |
group | As of now it must contain a isDefault field which specifies if it is the default task or not |
Required |
detail | Any additional comments or details | Optional |
Any additional field are just ignored and not used.
It currently supports 3 variables in the json file -
${file}
- it is substituted for the file name in the active buffer${fileDirname}
- the current directory of the file (Note: The task.json file must be present in this directory )${fileBasenameNoExtension}
- the file name with the extension removed