refactor(impl): use new runner

This commit is contained in:
Oleksandr Smirnov 2025-02-26 13:25:02 +02:00
parent 2307043fda
commit 55ee6bd9d6
No known key found for this signature in database

View file

@ -64,7 +64,7 @@ function impl.impl(...)
iface = vim.fn.input "impl: generating method stubs for interface: "
vim.cmd "redraw!"
if iface == "" then
u.deferred_notify("usage: GoImpl f *File io.Reader", vim.log.levels.INFO)
u.notify("usage: GoImpl f *File io.Reader", vim.log.levels.INFO)
return
end
elseif #args == 1 then -- :GoImpl io.Reader
@ -82,21 +82,14 @@ function impl.impl(...)
recv = string.format("%s %s", recv_name, recv)
end
local output = r.sync(c.impl, {
args = {
"-dir",
vim.fn.fnameescape(vim.fn.expand "%:p:h" --[[@as string]]),
recv,
iface,
},
on_exit = function(data, status)
if not status == 0 then
error("impl failed: " .. data)
end
end,
})
local rs = r.sync { c.impl, "-dir", vim.fn.fnameescape(vim.fn.expand "%:p:h"), recv, iface }
if rs.code ~= 0 then
error("failed to implement interface: " .. rs.stderr)
end
local pos = vim.fn.getcurpos()[2]
local output = vim.fn.split(rs.stdout, "\n")
table.insert(output, 1, "")
vim.fn.append(pos, output)
end