diff --git a/lua/gopher/gogenerate.lua b/lua/gopher/gogenerate.lua index 93f78da..5df4390 100644 --- a/lua/gopher/gogenerate.lua +++ b/lua/gopher/gogenerate.lua @@ -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 diff --git a/lua/gopher/goget.lua b/lua/gopher/goget.lua index 8d79626..2740179 100644 --- a/lua/gopher/goget.lua +++ b/lua/gopher/goget.lua @@ -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 diff --git a/lua/gopher/gomod.lua b/lua/gopher/gomod.lua index 61f19a2..f53ba28 100644 --- a/lua/gopher/gomod.lua +++ b/lua/gopher/gomod.lua @@ -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 diff --git a/lua/gopher/gotests.lua b/lua/gopher/gotests.lua index c71243e..2e43017 100644 --- a/lua/gopher/gotests.lua +++ b/lua/gopher/gotests.lua @@ -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 diff --git a/lua/gopher/impl.lua b/lua/gopher/impl.lua index 1c504ee..ee0aa3c 100644 --- a/lua/gopher/impl.lua +++ b/lua/gopher/impl.lua @@ -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, "") diff --git a/lua/gopher/installer.lua b/lua/gopher/installer.lua index cfd7a00..3251d71 100644 --- a/lua/gopher/installer.lua +++ b/lua/gopher/installer.lua @@ -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 diff --git a/lua/gopher/struct_tags.lua b/lua/gopher/struct_tags.lua index 27cfe39..1d577ce 100644 --- a/lua/gopher/struct_tags.lua +++ b/lua/gopher/struct_tags.lua @@ -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)) diff --git a/spec/gopher_struct_tags_spec.lua b/spec/gopher_struct_tags_spec.lua index 826933b..359275d 100644 --- a/spec/gopher_struct_tags_spec.lua +++ b/spec/gopher_struct_tags_spec.lua @@ -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 .. "'")