From d7c6096095e19c73ed105d2e5f8a83040b82652f Mon Sep 17 00:00:00 2001 From: Job Jobse Date: Tue, 1 Sep 2026 21:35:01 +0200 Subject: [PATCH] fix: do not open terminal when running just --- lua/just.lua | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lua/just.lua b/lua/just.lua index 0989601..6196e80 100644 --- a/lua/just.lua +++ b/lua/just.lua @@ -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