[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", 9 impl = "github.com/josharian/impl", 10 gotests = "github.com/cweill/gotests/...", 11 iferr = "github.com/koron/iferr", 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 u.deferred_notify("go install failed: " .. url) 19 log.error("go install failed:", "url", url, "opt", vim.inspect(opt)) 20 return 21 end 22 23 u.deferred_notify("go install-ed: " .. url) 24end 25 26---@param url string 27local function install(url) 28 r.async({ c.go, "install", url }, function(opt) 29 handle_intall_exit(opt, url) 30 end) 31end 32 33---@param url string 34local function install_sync(url) 35 local rs = r.sync { c.go, "install", url } 36 handle_intall_exit(rs, url) 37end 38 39---Install required go deps 40---@param opts? {sync:boolean} 41function installer.install_deps(opts) 42 opts = opts or {} 43 for pkg, _ in pairs(urls) do 44 local url = urls[pkg] .. "@latest" 45 if opts.sync then 46 install_sync(url) 47 else 48 install(url) 49 end 50 end 51end 52 53return installer