Skip to content

nkxxll/tasks.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

tasks.nvim

A small Neovim task runner inspired by Zed tasks.

tasks.nvim reads JSON task files, lets you pick a task, and runs it in a terminal split. Telescope is used automatically when available, otherwise it falls back to vim.ui.select.

Features

  • Global tasks from stdpath("config") .. "/tasks/tasks.json"
  • Project-local tasks from ./.tasks/tasks.json
  • Project-local tasks override global tasks with the same label
  • :TasksRun, :TasksRun <label>, and :TasksRerun commands
  • Optional default keymaps matching the original config: <leader>rt and <leader>rr
  • Telescope picker support with no hard dependency
  • Variable expansion for common editor/project values
  • Per-task cwd support

Installation

Using lazy.nvim:

{
  "nkxxll/tasks.nvim",
  config = function()
    require("tasks").setup()
  end,
}

For a local checkout:

{
  dir = "~/git/tasks.nvim",
  config = function()
    require("tasks").setup()
  end,
}

Task Files

Create global tasks at:

~/.config/nvim/tasks/tasks.json

Create project-local tasks at:

.tasks/tasks.json

Example:

[
  {
    "label": "test",
    "command": "npm test"
  },
  {
    "label": "run current lua file",
    "command": "lua ${file}",
    "cwd": "${fileDirname}"
  }
]

Usage

:TasksRun
:TasksRun test
:TasksRerun

Default mappings:

<leader>rt  Pick and run a task
<leader>rr  Rerun the last task

Configuration

Defaults:

require("tasks").setup({
  task_file_paths = function()
    return {
      vim.fn.stdpath("config") .. "/tasks/tasks.json",
      vim.fn.getcwd() .. "/.tasks/tasks.json",
    }
  end,
  keymaps = {
    run = "<leader>rt",
    rerun = "<leader>rr",
  },
  terminal = {
    direction = "split", -- "split", "vsplit", or "tab"
    size = nil,
    start_insert = true,
  },
  prefer_telescope = true,
})

Disable default mappings:

require("tasks").setup({
  keymaps = {
    run = false,
    rerun = false,
  },
})

Use custom task files:

require("tasks").setup({
  task_file_paths = function()
    return {
      vim.fn.stdpath("config") .. "/tasks/tasks.json",
      vim.fn.getcwd() .. "/.zed/tasks.json",
      vim.fn.getcwd() .. "/.tasks/tasks.json",
    }
  end,
})

Variables

Variables can be used in command and cwd:

${cwd}
${workspaceFolder}
${file}
${fileDirname}
${fileBasename}
${fileBasenameNoExtension}

Unknown variables are left unchanged.

About

A task runner for nvim inspired by zed tasks

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages