style: reformat all lua code
This commit is contained in:
parent
4fee3543e0
commit
4b83da6d7f
8 changed files with 84 additions and 102 deletions
|
|
@ -11,18 +11,16 @@ return function(...)
|
||||||
|
|
||||||
local cmd_args = vim.list_extend({ "generate" }, args)
|
local cmd_args = vim.list_extend({ "generate" }, args)
|
||||||
|
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = c.go,
|
||||||
command = c.go,
|
args = cmd_args,
|
||||||
args = cmd_args,
|
on_exit = function(_, retval)
|
||||||
on_exit = function(_, retval)
|
if retval ~= 0 then
|
||||||
if retval ~= 0 then
|
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
||||||
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
return
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
u.notify("go generate was success runned", "info")
|
u.notify("go generate was success runned", "info")
|
||||||
end,
|
end,
|
||||||
})
|
}):start()
|
||||||
:start()
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,18 +18,16 @@ return function(...)
|
||||||
|
|
||||||
local cmd_args = vim.list_extend({ "get" }, args)
|
local cmd_args = vim.list_extend({ "get" }, args)
|
||||||
|
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = c.go,
|
||||||
command = c.go,
|
args = cmd_args,
|
||||||
args = cmd_args,
|
on_exit = function(_, retval)
|
||||||
on_exit = function(_, retval)
|
if retval ~= 0 then
|
||||||
if retval ~= 0 then
|
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
||||||
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
return
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
u.notify("go get was success runned", "info")
|
u.notify("go get was success runned", "info")
|
||||||
end,
|
end,
|
||||||
})
|
}):start()
|
||||||
:start()
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,16 @@ return function(...)
|
||||||
|
|
||||||
local cmd_args = vim.list_extend({ "mod" }, args)
|
local cmd_args = vim.list_extend({ "mod" }, args)
|
||||||
|
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = c.go,
|
||||||
command = c.go,
|
args = cmd_args,
|
||||||
args = cmd_args,
|
on_exit = function(_, retval)
|
||||||
on_exit = function(_, retval)
|
if retval ~= 0 then
|
||||||
if retval ~= 0 then
|
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
||||||
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
return
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
u.notify("go mod was success runned", "info")
|
u.notify("go mod was success runned", "info")
|
||||||
end,
|
end,
|
||||||
})
|
}):start()
|
||||||
:start()
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,18 @@ local M = {}
|
||||||
|
|
||||||
---@param cmd_args table
|
---@param cmd_args table
|
||||||
local function run(cmd_args)
|
local function run(cmd_args)
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = c.gotests,
|
||||||
command = c.gotests,
|
args = cmd_args,
|
||||||
args = cmd_args,
|
on_exit = function(_, retval)
|
||||||
on_exit = function(_, retval)
|
if retval ~= 0 then
|
||||||
if retval ~= 0 then
|
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
||||||
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
return
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
u.notify("unit test(s) generated", "info")
|
u.notify("unit test(s) generated", "info")
|
||||||
end,
|
end,
|
||||||
})
|
}):start()
|
||||||
:start()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param args table
|
---@param args table
|
||||||
|
|
|
||||||
|
|
@ -54,20 +54,18 @@ return function(...)
|
||||||
}
|
}
|
||||||
|
|
||||||
local res_data
|
local res_data
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = c.impl,
|
||||||
command = c.impl,
|
args = cmd_args,
|
||||||
args = cmd_args,
|
on_exit = function(data, retval)
|
||||||
on_exit = function(data, retval)
|
if retval ~= 0 then
|
||||||
if retval ~= 0 then
|
u.notify("command 'impl " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
||||||
u.notify("command 'impl " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
|
return
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
res_data = data:result()
|
res_data = data:result()
|
||||||
end,
|
end,
|
||||||
})
|
}):sync()
|
||||||
:sync()
|
|
||||||
|
|
||||||
local pos = vim.fn.getcurpos()[2]
|
local pos = vim.fn.getcurpos()[2]
|
||||||
table.insert(res_data, 1, "")
|
table.insert(res_data, 1, "")
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,18 @@ local urls = {
|
||||||
local function install(pkg)
|
local function install(pkg)
|
||||||
local url = urls[pkg] .. "@latest"
|
local url = urls[pkg] .. "@latest"
|
||||||
|
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = "go",
|
||||||
command = "go",
|
args = { "install", url },
|
||||||
args = { "install", url },
|
on_exit = function(_, retval)
|
||||||
on_exit = function(_, retval)
|
if retval ~= 0 then
|
||||||
if retval ~= 0 then
|
u.notify("command 'go install " .. url .. "' exited with code " .. retval, "error")
|
||||||
u.notify("command 'go install " .. url .. "' exited with code " .. retval, "error")
|
return
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
u.notify("install " .. url .. " finished", "info ")
|
u.notify("install " .. url .. " finished", "info ")
|
||||||
end,
|
end,
|
||||||
})
|
}):start()
|
||||||
:start()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Install required go deps
|
---Install required go deps
|
||||||
|
|
|
||||||
|
|
@ -41,23 +41,21 @@ local function modify(...)
|
||||||
|
|
||||||
-- get result of "gomodifytags" works
|
-- get result of "gomodifytags" works
|
||||||
local res_data
|
local res_data
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = c.gomodifytags,
|
||||||
command = c.gomodifytags,
|
args = cmd_args,
|
||||||
args = cmd_args,
|
on_exit = function(data, retval)
|
||||||
on_exit = function(data, retval)
|
if retval ~= 0 then
|
||||||
if retval ~= 0 then
|
u.notify(
|
||||||
u.notify(
|
"command 'gomodifytags " .. unpack(cmd_args) .. "' exited with code " .. retval,
|
||||||
"command 'gomodifytags " .. unpack(cmd_args) .. "' exited with code " .. retval,
|
"error"
|
||||||
"error"
|
)
|
||||||
)
|
return
|
||||||
return
|
end
|
||||||
end
|
|
||||||
|
|
||||||
res_data = data:result()
|
res_data = data:result()
|
||||||
end,
|
end,
|
||||||
})
|
}):sync()
|
||||||
:sync()
|
|
||||||
|
|
||||||
-- decode goted value
|
-- decode goted value
|
||||||
local tagged = vim.json.decode(table.concat(res_data))
|
local tagged = vim.json.decode(table.concat(res_data))
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,8 @@ describe("gopher.struct_tags", function()
|
||||||
local add = require("gopher.struct_tags").add
|
local add = require("gopher.struct_tags").add
|
||||||
local name = vim.fn.tempname() .. ".go"
|
local name = vim.fn.tempname() .. ".go"
|
||||||
local input_file = vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/add_input.go")
|
local input_file = vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/add_input.go")
|
||||||
local output_file = vim.fn.join(
|
local output_file =
|
||||||
vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/add_output.go"),
|
vim.fn.join(vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/add_output.go"), "\n")
|
||||||
"\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.fn.writefile(input_file, name)
|
vim.fn.writefile(input_file, name)
|
||||||
vim.cmd("silent exe 'e " .. name .. "'")
|
vim.cmd("silent exe 'e " .. name .. "'")
|
||||||
|
|
@ -33,10 +31,8 @@ describe("gopher.struct_tags", function()
|
||||||
local remove = require("gopher.struct_tags").remove
|
local remove = require("gopher.struct_tags").remove
|
||||||
local name = vim.fn.tempname() .. ".go"
|
local name = vim.fn.tempname() .. ".go"
|
||||||
local input_file = vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/remove_input.go")
|
local input_file = vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/remove_input.go")
|
||||||
local output_file = vim.fn.join(
|
local output_file =
|
||||||
vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/remove_output.go"),
|
vim.fn.join(vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/remove_output.go"), "\n")
|
||||||
"\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.fn.writefile(input_file, name)
|
vim.fn.writefile(input_file, name)
|
||||||
vim.cmd("silent exe 'e " .. name .. "'")
|
vim.cmd("silent exe 'e " .. name .. "'")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue