gopher.nvim/lua/gopher/installer.lua
Smirnov Oleksandr 26b41bf68c
refactor of public plugin's api (#37)
* refactor: move all plugin functionality to init.lua

* fix(commands): now it uses correct module paths

* refactor(config): change way how it handles options

* refactor(gotests): use correct config, change way how deps required, fix some typos

* fix(healthchecker): use correct config

* refactor(iferr): change api

* refactor(impl): change api

* refactor(installer): change api

* refactor(struct_tags): change way of importting deps

* refactor(struct_tags): rename M to struct_tags

* run stylua

* refactor(dap): make it all in one file, and make some refactoring

* refactor(_utils): change way how it organizes

* fix: use new _utils api

* refactor(_utils.health): reorganize module

* refactor(_utils.ts): some renameing, moving requires lines

* run stylua
2023-07-19 23:38:23 +03:00

42 lines
990 B
Lua

local Job = require "plenary.job"
local c = require("gopher.config").commands
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"
Job:new({
command = c.go,
args = { "install", url },
on_exit = function(_, retval)
if retval ~= 0 then
u.deferred_notify(
"command 'go install " .. url .. "' exited with code " .. retval,
vim.log.levels.ERROR
)
return
end
u.deferred_notify("install " .. url .. " finished", vim.log.levels.INFO)
end,
}):start()
end
---Install required go deps
function installer.install_deps()
for pkg, _ in pairs(urls) do
install(pkg)
end
end
return installer