all repos

gopher.nvim @ v0.1.5

Minimalistic plugin for Go development

gopher.nvim/lua/gopher/installer.lua(view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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