[mirror] Make your go dev experience better
github.com/olexsmir/gopher.nvim
neovim
golang
1local Job = require "plenary.job"
2local c = require("gopher.config").config.commands
3local u = require "gopher._utils"
4
5---run "go get"
6return function(...)
7 local args = { ... }
8 if #args == 0 then
9 u.notify("please provide a package url to get", "error")
10 return
11 end
12
13 for i, arg in ipairs(args) do
14 local m = string.match(arg, "^https://(.*)$") or string.match(arg, "^http://(.*)$") or arg
15 table.remove(args, i)
16 table.insert(args, i, m)
17 end
18
19 local cmd_args = vim.list_extend({ "get" }, args)
20
21 Job
22 :new({
23 command = c.go,
24 args = cmd_args,
25 on_exit = function(_, retval)
26 if retval ~= 0 then
27 u.notify("command 'go " .. unpack(cmd_args) .. "' exited with code " .. retval, "error")
28 return
29 end
30
31 u.notify("go get was success runned", "info")
32 end,
33 })
34 :start()
35end