@@ 16,5 16,6 @@ return {
check_executable('git', false)
check_executable('go', true)
+ check_executable('env', true)
end,
}
@@ 13,6 13,8 @@ local M = {}
--- @field history_url (fun(RepoUrl.InfoOpts): string)?
--- @field raw_url (fun(RepoUrl.InfoOpts): string)?
+local fallback_gocache_dir = nil
+
--- @type fun(RepoUrl.InfoOpts, string, string?): string
local pos_to_path = function(opts, format1, format2)
if opts == nil or opts.line1 == nil then
@@ 148,6 150,21 @@ local function go_modcache_info(filename)
return false
end
+ if not json.Origin then
+ -- XXX: This will be super slow in most cases. Need to find a better way and
+ -- potentially make everything async..
+ output = vim.fn.system { 'env', 'GOPROXY=direct', 'GOMODCACHE=' .. fallback_gocache_dir, 'go', 'mod', 'download', '-json', module }
+ if output == '' then
+ return false
+ end
+
+ json = vim.fn.json_decode(output)
+ if not json then
+ return false
+ end
+ return false
+ end
+
if not json.Origin or json.Origin.VCS ~= 'git' then
return false
end