gopher.nvim/lua/gopher/installer.lua
Smirnov Oleksandr 2e89cea6f3 refactor: commands runner (#42)
* feat(utils): first impl of own commands runner

* refactor(gotests): uses own runner instead of vendored

* refactor(utils): back to plenary.job

* refactor(gotests): use new runner, clean code

* fix(runner): now it returns output correctly

* refactor(iferr): use vim.system

i have tried to use _utils.runner, but i can't figure out how to make `< file.go` for the command

* refactor(impl): use new runner

* refactor(installer): use new runner

* refactor(struct_tags): use new runner

* refactor: commands such as :GoGet runs with new runner

* refactor: throw errors in more lua way, i think

* refactor(utils): notify now has title

* refactor: use more correct way of notifying

* refactor(runner): write error message on error
2023-08-10 12:11:26 +03:00

36 lines
838 B
Lua

local c = require("gopher.config").commands
local r = require "gopher._utils.runner"
local u = require "gopher._utils"
local installer = {}
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 url = urls[pkg] .. "@latest"
r.sync(c.go, {
args = { "install", url },
on_exit = function(data, status)
if not status == 0 then
error("go install failed: " .. data)
return
end
u.notify("installed: " .. url)
end,
})
end
---Install required go deps
function installer.install_deps()
for pkg, _ in pairs(urls) do
install(pkg)
end
end
return installer