refactor(struct_tags): use new runner
This commit is contained in:
parent
18866eb6ab
commit
12b01a95ec
1 changed files with 7 additions and 25 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
local ts_utils = require "gopher._utils.ts"
|
local ts_utils = require "gopher._utils.ts"
|
||||||
local Job = require "plenary.job"
|
local r = require "gopher._utils.runner"
|
||||||
local c = require("gopher.config").commands
|
local c = require("gopher.config").commands
|
||||||
local u = require "gopher._utils"
|
local u = require "gopher._utils"
|
||||||
local struct_tags = {}
|
local struct_tags = {}
|
||||||
|
|
@ -39,31 +39,17 @@ local function modify(...)
|
||||||
table.insert(cmd_args, "json")
|
table.insert(cmd_args, "json")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get result of "gomodifytags" works
|
local output = r.sync(c.gomodifytags, {
|
||||||
local res_data
|
|
||||||
Job:new({
|
|
||||||
command = c.gomodifytags,
|
|
||||||
args = cmd_args,
|
args = cmd_args,
|
||||||
on_exit = function(data, retval)
|
on_exit = function(data, status)
|
||||||
if retval ~= 0 then
|
if not status == 0 then
|
||||||
u.deferred_notify(
|
error("gotag failed: " .. data, vim.log.levels.ERROR)
|
||||||
"command '"
|
|
||||||
.. c.gomodifytags
|
|
||||||
.. " "
|
|
||||||
.. unpack(cmd_args)
|
|
||||||
.. "' exited with code "
|
|
||||||
.. retval,
|
|
||||||
vim.log.levels.ERROR
|
|
||||||
)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
res_data = data:result()
|
|
||||||
end,
|
end,
|
||||||
}):sync()
|
})
|
||||||
|
|
||||||
-- decode goted value
|
-- decode goted value
|
||||||
local tagged = vim.json.decode(table.concat(res_data))
|
local tagged = vim.json.decode(table.concat(output))
|
||||||
if
|
if
|
||||||
tagged.errors ~= nil
|
tagged.errors ~= nil
|
||||||
or tagged.lines == nil
|
or tagged.lines == nil
|
||||||
|
|
@ -73,10 +59,6 @@ local function modify(...)
|
||||||
u.deferred_notify("failed to set tags " .. vim.inspect(tagged), vim.log.levels.ERROR)
|
u.deferred_notify("failed to set tags " .. vim.inspect(tagged), vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, v in ipairs(tagged.lines) do
|
|
||||||
tagged.lines[i] = u.rtrim(v)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- write goted tags
|
-- write goted tags
|
||||||
vim.api.nvim_buf_set_lines(
|
vim.api.nvim_buf_set_lines(
|
||||||
0,
|
0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue