local M = {} local function run_task(cmd) vim.notify("󰑮 Running: " .. cmd) vim.cmd("enew") local buf = vim.api.nvim_get_current_buf() pcall(vim.api.nvim_buf_set_name, buf, "just://" .. cmd) vim.fn.termopen(cmd, { on_exit = function(_, code) if code == 0 then vim.notify("󰄬 " .. cmd .. " success") pcall(vim.cmd, "bdelete!") else vim.notify("󰅚 " .. cmd .. " failed (" .. code .. ")", vim.log.levels.ERROR) end end, }) end --- Interactive picker for selecting and running tasks defined in a Justfile. function M.pick_just_task() local obj = vim.system({ "just", "--summary" }, { text = true }):wait() if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then return vim.notify("No recipes or justfile found", vim.log.levels.WARN) end local recipes = vim.split(vim.trim(obj.stdout), "%s+") require("mini.pick").start({ source = { items = recipes, name = "󱁤 Just Tasks", choose = function(choice) run_task("just " .. choice) end, }, }) end return M