refactor: small fixes

This commit is contained in:
Job Jobse
2026-08-29 13:03:23 +02:00
parent 1bb7c08186
commit 9f74d7a7a1
8 changed files with 206 additions and 143 deletions
+23 -21
View File
@@ -1,29 +1,29 @@
local function run_task(cmd)
local buf = vim.api.nvim_create_buf(true, true)
vim.api.nvim_buf_set_name(buf, "just://" .. cmd)
vim.notify("󰑮 Running: " .. cmd)
local M = {}
vim.api.nvim_buf_call(buf, function()
vim.fn.jobstart(cmd, {
term = true,
on_exit = function(_, code)
if code == 0 then
vim.notify("󰄬 " .. cmd .. " success")
vim.schedule(function()
pcall(vim.api.nvim_buf_delete, buf, { force = true })
end)
else
vim.notify("󰅚 " .. cmd .. " failed (" .. code .. ")", 4)
end
end,
})
end)
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
function pick_just_task()
--- 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", 3)
return vim.notify("No recipes or justfile found", vim.log.levels.WARN)
end
local recipes = vim.split(vim.trim(obj.stdout), "%s+")
@@ -37,3 +37,5 @@ function pick_just_task()
},
})
end
return M
+1 -1
View File
@@ -5,7 +5,7 @@ function M.open_terminal_app(cmd)
vim.cmd("enew")
vim.fn.termopen(cmd, {
on_exit = function()
vim.cmd("bdelete!")
pcall(vim.cmd, "bdelete!")
end,
})
end