feat(complete): add forge shorthand omnifunc completions

Problem: no completion support for `gh:`, `gl:`, or `cb:` tokens,
requiring users to type owner/repo from memory.

Solution: extend `omnifunc` to detect `gh:`/`gl:`/`cb:` prefixes and
complete with `owner/repo#` candidates from existing forge refs in
the store.
This commit is contained in:
Barrett Ruth 2026-03-10 17:44:36 -04:00
parent f4e62b148c
commit 3a994e6284

View file

@ -128,6 +128,9 @@ function M.omnifunc(findstart, base)
{ vim.pesc(dk) .. ':([%S]*)$', dk },
{ 'cat:([%S]*)$', 'cat' },
{ vim.pesc(rk) .. ':([%S]*)$', rk },
{ 'gh:([%S]*)$', 'gh' },
{ 'gl:([%S]*)$', 'gl' },
{ 'cb:([%S]*)$', 'cb' },
}
for _, check in ipairs(checks) do
@ -169,6 +172,24 @@ function M.omnifunc(findstart, base)
table.insert(matches, { word = c.word, menu = '[' .. source .. ']', info = c.info })
end
end
elseif source == 'gh' or source == 'gl' or source == 'cb' then
local s = require('pending.buffer').store()
if s then
local seen = {}
for _, task in ipairs(s:tasks()) do
if task._extra and task._extra._forge_ref then
local ref = task._extra._forge_ref
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 .. ']' })
end
end
end
end
end
end
return matches