style: reformat all lua code

This commit is contained in:
Smirnov Oleksandr 2022-07-07 14:09:48 +03:00
parent 4fee3543e0
commit 4b83da6d7f
8 changed files with 84 additions and 102 deletions

View file

@ -11,18 +11,16 @@ return function(...)
local cmd_args = vim.list_extend({ "generate" }, args)
Job
:new({
command = c.go,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
Job:new({
command = c.go,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
u.notify("go generate was success runned", "info")
end,
})
:start()
u.notify("go generate was success runned", "info")
end,
}):start()
end

View file

@ -18,18 +18,16 @@ return function(...)
local cmd_args = vim.list_extend({ "get" }, args)
Job
:new({
command = c.go,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
Job:new({
command = c.go,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
u.notify("go get was success runned", "info")
end,
})
:start()
u.notify("go get was success runned", "info")
end,
}):start()
end

View file

@ -12,18 +12,16 @@ return function(...)
local cmd_args = vim.list_extend({ "mod" }, args)
Job
:new({
command = c.go,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
Job:new({
command = c.go,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
u.notify("go mod was success runned", "info")
end,
})
:start()
u.notify("go mod was success runned", "info")
end,
}):start()
end

View file

@ -6,20 +6,18 @@ local M = {}
---@param cmd_args table
local function run(cmd_args)
Job
:new({
command = c.gotests,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
Job:new({
command = c.gotests,
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
u.notify("unit test(s) generated", "info")
end,
})
:start()
u.notify("unit test(s) generated", "info")
end,
}):start()
end
---@param args table

View file

@ -54,20 +54,18 @@ return function(...)
}
local res_data
Job
:new({
command = c.impl,
args = cmd_args,
on_exit = function(data, retval)
if retval ~= 0 then
u.notify("command 'impl " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
Job:new({
command = c.impl,
args = cmd_args,
on_exit = function(data, retval)
if retval ~= 0 then
u.notify("command 'impl " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
return
end
res_data = data:result()
end,
})
:sync()
res_data = data:result()
end,
}):sync()
local pos = vim.fn.getcurpos()[2]
table.insert(res_data, 1, "")

View file

@ -10,20 +10,18 @@ local urls = {
local function install(pkg)
local url = urls[pkg] .. "@latest"
Job
:new({
command = "go",
args = { "install", url },
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go install " .. url .. "' exited with code " .. retval, "error")
return
end
Job:new({
command = "go",
args = { "install", url },
on_exit = function(_, retval)
if retval ~= 0 then
u.notify("command 'go install " .. url .. "' exited with code " .. retval, "error")
return
end
u.notify("install " .. url .. " finished", "info ")
end,
})
:start()
u.notify("install " .. url .. " finished", "info ")
end,
}):start()
end
---Install required go deps

View file

@ -41,23 +41,21 @@ local function modify(...)
-- get result of "gomodifytags" works
local res_data
Job
:new({
command = c.gomodifytags,
args = cmd_args,
on_exit = function(data, retval)
if retval ~= 0 then
u.notify(
"command 'gomodifytags " .. unpack(cmd_args) .. "' exited with code " .. retval,
"error"
)
return
end
Job:new({
command = c.gomodifytags,
args = cmd_args,
on_exit = function(data, retval)
if retval ~= 0 then
u.notify(
"command 'gomodifytags " .. unpack(cmd_args) .. "' exited with code " .. retval,
"error"
)
return
end
res_data = data:result()
end,
})
:sync()
res_data = data:result()
end,
}):sync()
-- decode goted value
local tagged = vim.json.decode(table.concat(res_data))

View file

@ -9,10 +9,8 @@ describe("gopher.struct_tags", function()
local add = require("gopher.struct_tags").add
local name = vim.fn.tempname() .. ".go"
local input_file = vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/add_input.go")
local output_file = vim.fn.join(
vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/add_output.go"),
"\n"
)
local output_file =
vim.fn.join(vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/add_output.go"), "\n")
vim.fn.writefile(input_file, name)
vim.cmd("silent exe 'e " .. name .. "'")
@ -33,10 +31,8 @@ describe("gopher.struct_tags", function()
local remove = require("gopher.struct_tags").remove
local name = vim.fn.tempname() .. ".go"
local input_file = vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/remove_input.go")
local output_file = vim.fn.join(
vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/remove_output.go"),
"\n"
)
local output_file =
vim.fn.join(vim.fn.readfile(cur_dir .. "/spec/fixtures/tags/remove_output.go"), "\n")
vim.fn.writefile(input_file, name)
vim.cmd("silent exe 'e " .. name .. "'")