feat(forge): support bare repo-level forge refs (#135) (#140)

Problem: Forge refs required an issue/PR number (`gh:user/repo#42`).
Users wanting to link a repo without a specific issue had no option.

Solution: Accept `gh:user/repo` shorthand and `https://github.com/user/repo`
URLs as `type='repo'` refs with `number=nil`. These conceal and render
virtual text like numbered refs but skip all API calls (no validate, no
fetch, no close). `format_label` strips `#%n` for bare refs. Omnifunc
offers both `owner/repo#` and `owner/repo` completions.

Closes #135
This commit is contained in:
Barrett Ruth 2026-03-11 12:34:17 -04:00 committed by Barrett Ruth
parent 1064b7535a
commit 46b5d52b60
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
3 changed files with 261 additions and 88 deletions

View file

@ -194,9 +194,15 @@ function M.omnifunc(findstart, base)
local key = ref.owner .. '/' .. ref.repo
if not seen[key] then
seen[key] = true
local word = key .. '#'
if base == '' or word:sub(1, #base) == base then
table.insert(matches, { word = word, menu = '[' .. source .. ']' })
local word_num = key .. '#'
if base == '' or word_num:sub(1, #base) == base then
table.insert(matches, { word = word_num, menu = '[' .. source .. ']' })
end
if base == '' or key:sub(1, #base) == base then
table.insert(
matches,
{ word = key, menu = '[' .. source .. ']', info = 'Bare repo link' }
)
end
end
end