Skip to content

Run and preview the definitions and outputs of custom or auto-generated tasks from a telescope prompt

License

Notifications You must be signed in to change notification settings

hgigas/telescope-tasks.nvim

 
 

Repository files navigation

Telescope tasks

telescope-tasks.nvim is a telescope.nvim extension, that allows running tasks directly from the telescope prompt and displaying their definitions and outputs in the telescope's previewer.

Demo

demo.mp4

The demo uses the default generators for Go and Python projects.

Installation

Packer

use {"lpoto/telescope-tasks.nvim"}

Vim-Plug

Plug  "lpoto/telescope-tasks.nvim"

Setup and usage

First setup and load the extension:

require("telescope").setup {
  extensions = {
    -- NOTE: this setup is optional
    tasks = {
      theme = "ivy",
      output = {
        style = "float", -- "vsplit" | "split" | "float"
        layout = "center", -- "bottom" | "left" | "right" | "center"
        scale = 0.4, -- output window to editor size ratio
        -- NOTE: layout and scale are only relevant when style == "float"
      },
      -- Directory to store the modified commands data to.
      -- Set it to false to disable saving modified commands.
      data_dir = Path:new(vim.fn.stdpath "data", "telescope_tasks"))
      -- other picker setup values
    },
  },
}
-- Load the tasks telescope extension
require("telescope").load_extension "tasks"

See Generators on how to generate tasks.

Then use the extension:

:Telescope tasks

or in lua:

require("telescope").extensions.tasks.tasks()

NOTE: See Mappings for the default mappings in the tasks prompt

The last opened output may then be toggled with:

 require("telescope").extensions.tasks.actions.toggle_last_output()

Generators

You may either use the Default Generators, or add Custom Generators.

Mappings

Key Description
<CR> Run the selected task, or kill it if it is already running.
<C-a> Run the selected task, but allow modifying the command before running it.
<C-o> Display the output of the selected task in another window.
<C-d> Delete the output of the selected task.
<C-k> Scroll the previewer up.
<C-j> Scroll the previewer down.
<C-q> Send a task's output to quickfix.

NOTE modified command will be saved, so the next time you run the same task, the modified command will be used.

About

Run and preview the definitions and outputs of custom or auto-generated tasks from a telescope prompt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%