gopher.nvim/lua/gopher/installer.lua
Smirnov Oleksandr 2f0edbfdfc
refactor: move requires in place where they used (#22)
* refactor(comment): move require to a function

* refactor(gotests): move requires inside of functions

* refactor(health): move requires inside of function

* refactor(iferr): move requires inside of a function

* refactor(impl): move some requires inside of functions

* refactor(installer): move requires inside of function

* refactor(struct_tags): move requires into function

* refactor(dap): move import into function

* refactor(utils): move import into functions
2022-12-19 11:47:43 +02:00

35 lines
822 B
Lua

local urls = {
gomodifytags = "github.com/fatih/gomodifytags",
impl = "github.com/josharian/impl",
gotests = "github.com/cweill/gotests/...",
iferr = "github.com/koron/iferr",
dlv = "github.com/go-delve/delve/cmd/dlv",
}
---@param pkg string
local function install(pkg)
local Job = require "plenary.job"
local u = require "gopher._utils"
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
u.notify("install " .. url .. " finished", "info ")
end,
}):start()
end
---Install required go deps
return function()
for pkg, _ in pairs(urls) do
install(pkg)
end
end