refactor(impl): use new runner

This commit is contained in:
Smirnov Oleksandr 2023-08-09 13:11:39 +03:00
parent c90e0cd124
commit 9af6797ffc

View file

@ -1,5 +1,5 @@
local c = require("gopher.config").commands local c = require("gopher.config").commands
local Job = require "plenary.job" local r = require "gopher._utils.runner"
local ts_utils = require "gopher._utils.ts" local ts_utils = require "gopher._utils.ts"
local u = require "gopher._utils" local u = require "gopher._utils"
local impl = {} local impl = {}
@ -47,33 +47,24 @@ function impl.impl(...)
recv = string.format("%s %s", recv_name, recv) recv = string.format("%s %s", recv_name, recv)
end end
-- stylua: ignore local output = r.sync(c.impl, {
local cmd_args = { args = {
"-dir", vim.fn.fnameescape(vim.fn.expand "%:p:h"), ---@diagnostic disable-line: missing-parameter "-dir",
vim.fn.fnameescape(vim.fn.expand "%:p:h" --[[@as string]]),
recv, recv,
iface iface,
} },
on_exit = function(data, status)
local res_data if not status == 0 then
Job:new({ error("impl failed: " .. data, vim.log.levels.ERROR)
command = c.impl,
args = cmd_args,
on_exit = function(data, retval)
if retval ~= 0 then
u.deferred_notify(
"command '" .. c.impl .. " " .. unpack(cmd_args) .. "' exited with code " .. retval,
vim.log.levels.ERROR
)
return return
end end
res_data = data:result()
end, end,
}):sync() })
local pos = vim.fn.getcurpos()[2] local pos = vim.fn.getcurpos()[2]
table.insert(res_data, 1, "") table.insert(output, 1, "")
vim.fn.append(pos, res_data) vim.fn.append(pos, output)
end end
return impl return impl