Skip to content

Arjun31415/BuildTask.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BuildTask.nvim

Neovim Plugin to use build tasks similar to VScode

Table of Contents

Features

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

Requirements

  • Neovim v0.6.0+ or nightly build

Installation

Recommended is to use packer.nvim

use({
    'Arjun31415/BuildTask.nvim',
    requires="rcarriga/nvim-notify"
    })

Config

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++"
    }
  ]
}

Fields and values

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 -

  1. ${file} - it is substituted for the file name in the active buffer
  2. ${fileDirname} - the current directory of the file (Note: The task.json file must be present in this directory )
  3. ${fileBasenameNoExtension} - the file name with the extension removed

Usage

As of now it provides a single command :BtBuildDefault which runs the default build task

Feature Plan

  • Command to run other tasks apart from default tasks

Contributing

Contributions are welcome, If you find any issues please create a new issue in Github

About

Neovim lua plugin for running tasks from task.json file

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages