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