all repos

gopher.nvim @ 04e1af2

Minimalistic plugin for Go development
4 files changed, 38 insertions(+), 0 deletions(-)
feat: add goget support

feat(goget): remove http or https from provided url
Author: Smirnov Olexander ss2316544@gmail.com
Committed at: 2022-06-07 01:35:34 +0300
Parent: f507a37
M README.md

@@ -43,6 +43,15 @@ :GoMod tidy " Runs `go mod tidy`

:GoMod init asdf " Runs `go mod init asdf` ``` +1. Run `go get` command +Link can has a `http` or `https` prefix. + +You can provide more that one package url. + +```viml +:GoGet github.com/gorilla/mux +``` + ## Thanks - [go.nvim](https://github.com/ray-x/go.nvim)
A lua/gopher/goget.lua

@@ -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
M lua/gopher/init.lua

@@ -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
M plugin/gopher.vim

@@ -1,4 +1,5 @@

command! -nargs=* GoTagAdd :lua require"gopher".tags_add(<f-args>) command! -nargs=* GoTagRm :lua require"gopher".tags_rm(<f-args>) command! -nargs=* GoMod :lua require"gopher".mod(<f-args>) +command! -nargs=* GoGet :lua require"gopher".get(<f-args>) command! GoInstallDeps :lua require"gopher".install_deps()