refactor(struct_tags): use new runner

)
This commit is contained in:
Oleksandr Smirnov 2025-02-26 13:21:47 +02:00
parent ddf7d0c77b
commit 2307043fda
No known key found for this signature in database

View file

@ -38,15 +38,8 @@ local function modify(...)
return
end
-- stylua: ignore
local cmd_args = {
"-transform", c.gotag.transform,
"-format", "json",
"-file", fpath,
"-w"
}
-- by struct name of line pos
local cmd_args = {}
if ns.name == nil then
local _, csrow, _, _ = unpack(vim.fn.getpos ".")
table.insert(cmd_args, "-line")
@ -67,17 +60,25 @@ local function modify(...)
table.insert(cmd_args, "json")
end
local output = r.sync(c.commands.gomodifytags, {
args = cmd_args,
on_exit = function(data, status)
if not status == 0 then
error("gotag failed: " .. data)
-- NOTE: later this part will be refactored
local rs = r.sync {
c.commands.gomodifytags,
"-transform",
c.gotag.transform,
"-format",
"json",
"-w",
"-file",
fpath,
unpack(cmd_args),
}
if rs.code ~= 0 then
error("failed to set tags " .. rs.stderr)
end
end,
})
-- decode value
local tagged = vim.json.decode(table.concat(output))
local tagged = vim.json.decode(rs.stdout)
if
tagged.errors ~= nil
or tagged.lines == nil