diff --git a/lua/gopher/gomod.lua b/lua/gopher/gomod.lua new file mode 100644 index 0000000..f05cf80 --- /dev/null +++ b/lua/gopher/gomod.lua @@ -0,0 +1,19 @@ +local Job = require "plenary.job" + +return function(...) + local args = { ... } + local cmd_args = vim.list_extend({ "mod" }, args) + + Job + :new({ + command = "go", + args = cmd_args, + on_exit = function(_, retval) + if retval ~= 0 then + print("command exited with code " .. retval) + return + end + end, + }) + :sync() +end diff --git a/lua/gopher/init.lua b/lua/gopher/init.lua index 93047ed..e580f8a 100644 --- a/lua/gopher/init.lua +++ b/lua/gopher/init.lua @@ -4,5 +4,6 @@ local gopher = {} gopher.install_deps = require("gopher.installer").install_all gopher.tags_add = tags.add gopher.tags_rm = tags.remove +gopher.mod = require "gopher.gomod" return gopher