fix: do not open terminal when running just

This commit is contained in:
Job Jobse
2026-09-01 21:35:01 +02:00
parent 2c429163b8
commit d7c6096095
+15 -17
View File
@@ -2,21 +2,22 @@ local M = {}
local function run_task(cmd)
vim.notify("󰑮 Running: " .. cmd)
vim.cmd("enew")
local buf = vim.api.nvim_get_current_buf()
local buf = vim.api.nvim_create_buf(true, true)
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,
})
vim.api.nvim_buf_call(buf, function()
vim.fn.termopen(cmd, {
on_exit = function(_, code)
if code == 0 then
vim.notify("󰄬 " .. cmd .. " success")
pcall(vim.api.nvim_buf_delete, buf, { force = true })
else
vim.notify("󰅚 " .. cmd .. " failed (" .. code .. ")", vim.log.levels.ERROR)
end
end,
})
end)
end
--- Interactive picker for selecting and running tasks defined in a Justfile.
@@ -26,14 +27,11 @@ function M.pick_just_task()
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,
items = vim.split(vim.trim(obj.stdout), "%s+"),
name = "󱁤 Just Tasks",
choose = function(choice)
run_task("just " .. choice)
end,
choose = function(choice) run_task("just " .. choice) end,
},
})
end