refactor: simplify

This commit is contained in:
2026-09-03 19:50:47 +02:00
parent 11edf1e7d1
commit 29d7fd98c8
5 changed files with 45 additions and 69 deletions
+16 -16
View File
@@ -1,5 +1,21 @@
local M = {}
--- 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
require("mini.pick").start({
source = {
items = vim.split(vim.trim(obj.stdout), "%s+"),
name = "󱁤 Just Tasks",
choose = function(choice) run_task("just " .. choice) end,
},
})
end
local function run_task(cmd)
vim.notify("󰑮 Running: " .. cmd)
@@ -20,20 +36,4 @@ local function run_task(cmd)
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
require("mini.pick").start({
source = {
items = vim.split(vim.trim(obj.stdout), "%s+"),
name = "󱁤 Just Tasks",
choose = function(choice) run_task("just " .. choice) end,
},
})
end
return M
+6 -8
View File
@@ -3,21 +3,19 @@ local M = {}
--- Opens a TUI application in a simple centered floating window.
function M.open_terminal_app(cmd)
local buf = vim.api.nvim_create_buf(false, true)
local w, h = math.floor(vim.o.columns * 0.95), math.floor(vim.o.lines * 0.95)
-- Open a centered floating window (80% screen width/height)
local win = vim.api.nvim_open_win(buf, true, {
relative = "editor",
width = math.floor(vim.o.columns * 0.95),
height = math.floor(vim.o.lines * 0.95),
row = math.floor(vim.o.lines * 0.025),
col = math.floor(vim.o.columns * 0.025),
width = w,
height = h,
row = math.floor((vim.o.lines - h) / 2),
col = math.floor((vim.o.columns - w) / 2),
border = "rounded",
})
vim.fn.termopen(cmd, {
on_exit = function()
pcall(vim.api.nvim_win_close, win, true)
end,
on_exit = function() pcall(vim.api.nvim_win_close, win, true) end,
})
end