refactor: simplify
This commit is contained in:
+17
-16
@@ -1,21 +1,6 @@
|
||||
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
|
||||
|
||||
--- Runs a command in an ephemeral scratch buffer.
|
||||
local function run_task(cmd)
|
||||
vim.notify(" Running: " .. cmd)
|
||||
|
||||
@@ -36,4 +21,20 @@ local function run_task(cmd)
|
||||
end)
|
||||
end
|
||||
|
||||
--- Interactive picker for standard Justfile targets.
|
||||
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
|
||||
|
||||
+3
-2
@@ -1,9 +1,10 @@
|
||||
local M = {}
|
||||
|
||||
--- Opens a TUI application in a simple centered floating window.
|
||||
--- Opens a command 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)
|
||||
local w = math.floor(vim.o.columns * 0.95)
|
||||
local h = math.floor(vim.o.lines * 0.95)
|
||||
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
|
||||
Reference in New Issue
Block a user