Skip to content

Repository files navigation

taskfile.nvim

A Neovim plugin for working w/ Taskfiles

Example

Installation

vim.pack

Requires Neovim v0.12+

vim.pack.add({
  --- .....
  {
    source = 's0cks/taskfile.nvim',
    setup = function()
      require('taskfile').setup({
        ---@see lua/taskfile/config.lua
      })
    end
  },
  --- .....
})

Lazy
{
  's0cks/taskfile.nvim',
  opts = {},
  config = function(_, opts)
    require('taskfile').setup(opts)
  end,
}

Default Config

Here is the default config:

---@class taskfile.Opts
---@field notify? fun(msg, level, opts) The notify function
{
  notify = vim.notify,
}

See lua/taskfile/config.lua for an up-to-date version

Dependencies

  • taskfile-lsp --- A language-server (LSP) for working w/ Taskfiles Optional / Highly Recommended

Commands

This plugin creates the following commands:

Command Description
:Task Spawn vim.ui.select and run the selected task

Filetypes

This plugin creates the following filetypes:

Filetype Source Description
yaml.taskfile Filenames:
- Taskfile.{yaml,yml}
A filetype for taskfiles w/ YAML filetype combinator

API

---@class taskfile.Task
---@field name string The name of the task
---@field desc string The description of the task

---@class taskfile.SelectOpts : vim.ui.select.Opts

---@class taskfile.TaskJobOpts
---@field notify? fun(msg, level, opts) The notify function
---@field on_finished? fun() The callback to invoke when finished

Getting a list of tasks

You can get a list of tasks from the Taskfile:

local tasks = require('taskfile').list_tasks()

--- List the available tasks
---@return taskfile.Task[]
function M.list_tasks() end

Opening a vim.ui.select for a list of tasks

You can open vim.ui.select for a list of tasks using:

local taskfile = require('taskfile')
local tasks = taskfile.list_tasks()
taskfile.select_task(tasks, function(task)
  --- do something
end)

--- Open a select prompt for a list of tasks
---@param tasks taskfile.Task[] The tasks to select from
---@param on_choice fun(task: taskfile.Task) The callback when a choice is selected
---@param opts? taskfile.SelectOpts The opts to use
function M.select_task(tasks, on_choice, opts) end

Starting a task job

You can start a job for a task by doing:

require('taskfile').start_task_job('default')

--- Start a job running the task
---@param task string The name of the task to run
---@param opts? taskfile.TaskJobOpts
function M.start_task_job(task, opts) end

Credits

  • The Task team --- For task 🫶

License

See LICENSE

About

Neovim plugin for working w/ Taskfiles

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages