refactor(struct_tags): use new runner
)
This commit is contained in:
parent
ddf7d0c77b
commit
2307043fda
1 changed files with 18 additions and 17 deletions
|
|
@ -38,15 +38,8 @@ local function modify(...)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- stylua: ignore
|
|
||||||
local cmd_args = {
|
|
||||||
"-transform", c.gotag.transform,
|
|
||||||
"-format", "json",
|
|
||||||
"-file", fpath,
|
|
||||||
"-w"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- by struct name of line pos
|
-- by struct name of line pos
|
||||||
|
local cmd_args = {}
|
||||||
if ns.name == nil then
|
if ns.name == nil then
|
||||||
local _, csrow, _, _ = unpack(vim.fn.getpos ".")
|
local _, csrow, _, _ = unpack(vim.fn.getpos ".")
|
||||||
table.insert(cmd_args, "-line")
|
table.insert(cmd_args, "-line")
|
||||||
|
|
@ -67,17 +60,25 @@ local function modify(...)
|
||||||
table.insert(cmd_args, "json")
|
table.insert(cmd_args, "json")
|
||||||
end
|
end
|
||||||
|
|
||||||
local output = r.sync(c.commands.gomodifytags, {
|
-- NOTE: later this part will be refactored
|
||||||
args = cmd_args,
|
local rs = r.sync {
|
||||||
on_exit = function(data, status)
|
c.commands.gomodifytags,
|
||||||
if not status == 0 then
|
"-transform",
|
||||||
error("gotag failed: " .. data)
|
c.gotag.transform,
|
||||||
end
|
"-format",
|
||||||
end,
|
"json",
|
||||||
})
|
"-w",
|
||||||
|
"-file",
|
||||||
|
fpath,
|
||||||
|
unpack(cmd_args),
|
||||||
|
}
|
||||||
|
|
||||||
|
if rs.code ~= 0 then
|
||||||
|
error("failed to set tags " .. rs.stderr)
|
||||||
|
end
|
||||||
|
|
||||||
-- decode value
|
-- decode value
|
||||||
local tagged = vim.json.decode(table.concat(output))
|
local tagged = vim.json.decode(rs.stdout)
|
||||||
if
|
if
|
||||||
tagged.errors ~= nil
|
tagged.errors ~= nil
|
||||||
or tagged.lines == nil
|
or tagged.lines == nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue