feat: add goget support

feat(goget): remove http or https from provided url
This commit is contained in:
Smirnov Olexander 2022-06-07 01:17:51 +03:00
parent f507a37a72
commit 04e1af228b
4 changed files with 38 additions and 0 deletions

27
lua/gopher/goget.lua Normal file
View file

@ -0,0 +1,27 @@
local Job = require "plenary.job"
return function(...)
local args = { ... }
for i, arg in ipairs(args) do
local m = string.match(arg, "^https://(.*)$") or string.match(arg, "^http://(.*)$") or arg
table.remove(args, i)
table.insert(args, i, m)
end
local cmd_args = vim.list_extend({ "get" }, args)
Job
:new({
command = "go",
args = cmd_args,
on_exit = function(_, retval)
if retval ~= 0 then
print("command exited with code " .. retval)
return
else
print "command runs successfully"
end
end,
})
:start()
end

View file

@ -5,5 +5,6 @@ gopher.install_deps = require("gopher.installer").install_all
gopher.tags_add = tags.add
gopher.tags_rm = tags.remove
gopher.mod = require "gopher.gomod"
gopher.get = require "gopher.goget"
return gopher