all repos

gopher.nvim @ 250d4de

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
local Job = require "plenary.job"
local urls = {
  gomodifytags = "github.com/fatih/gomodifytags",
  impl = "github.com/josharian/impl",
  gotests = "github.com/cweill/gotests",
}

---@param pkg string
local function install(pkg)
  local url = urls[pkg] .. "@latest"

  Job
    :new({
      command = "go",
      args = { "install", url },
      on_exit = function(_, ret_val)
        if ret_val ~= 0 then
          print("command exited with code " .. ret_val)
          return
        end

        print("install " .. url .. " finished")
      end,
    })
    :sync()
end

---Install required go deps
return function()
  for pkg, _ in pairs(urls) do
    install(pkg)
  end
end