[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang
at main 1.6 kB view raw
1local c = require "gopher.config" 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 json2go = "olexsmir.xyz/json2go/cmd/json2go@latest", 13} 14 15---@param opt vim.SystemCompleted 16---@param url string 17local function handle_intall_exit(opt, url) 18 if opt.code ~= 0 then 19 vim.schedule(function() 20 u.notify("go install failed: " .. url) 21 end) 22 23 log.error("go install failed:", "url", url, "opt", vim.inspect(opt)) 24 return 25 end 26 27 vim.schedule(function() 28 u.notify("go install-ed: " .. url) 29 end) 30end 31 32---@param url string 33local function install(url) 34 vim.schedule(function() 35 u.notify("go install-ing: " .. url) 36 end) 37 38 r.async({ c.commands.go, "install", url }, function(opt) 39 handle_intall_exit(opt, url) 40 end, { timeout = c.installer_timeout }) 41end 42 43---@param url string 44local function install_sync(url) 45 vim.schedule(function() 46 u.notify("go install-ing: " .. url) 47 end) 48 49 local rs = r.sync({ c.commands.go, "install", url }, { timeout = c.installer_timeout }) 50 handle_intall_exit(rs, url) 51end 52 53---Install required go deps 54---@param opts? {sync:boolean} 55function installer.install_deps(opts) 56 opts = opts or {} 57 for _, url in pairs(urls) do 58 if opts.sync then 59 install_sync(url) 60 else 61 install(url) 62 end 63 end 64end 65 66return installer