[mirror] Make your go dev experience better
github.com/olexsmir/gopher.nvim
neovim
golang
1local c = require("gopher.config").commands
2local r = require "gopher._utils.runner"
3local u = require "gopher._utils"
4local log = require "gopher._utils.log"
5local installer = {}
6
7local urls = {
8 gomodifytags = "github.com/fatih/gomodifytags@latest",
9 impl = "github.com/josharian/impl@latest",
10 gotests = "github.com/cweill/gotests/...@develop",
11 iferr = "github.com/koron/iferr@latest",
12}
13
14---@param opt vim.SystemCompleted
15---@param url string
16local function handle_intall_exit(opt, url)
17 if opt.code ~= 0 then
18 vim.schedule(function()
19 u.notify("go install failed: " .. url)
20 end)
21
22 log.error("go install failed:", "url", url, "opt", vim.inspect(opt))
23 return
24 end
25
26 vim.schedule(function()
27 u.notify("go install-ed: " .. url)
28 end)
29end
30
31---@param url string
32local function install(url)
33 r.async({ c.go, "install", url }, function(opt)
34 handle_intall_exit(opt, url)
35 end)
36end
37
38---@param url string
39local function install_sync(url)
40 local rs = r.sync { c.go, "install", url }
41 handle_intall_exit(rs, url)
42end
43
44---Install required go deps
45---@param opts? {sync:boolean}
46function installer.install_deps(opts)
47 opts = opts or {}
48 for _, url in pairs(urls) do
49 if opts.sync then
50 install_sync(url)
51 else
52 install(url)
53 end
54 end
55end
56
57return installer