Skip to content

feat: omnifunc completion for compose buffer metadata#53

Merged
barrettruth merged 1 commit intomainfrom
feat/compose-completion
Apr 4, 2026
Merged

feat: omnifunc completion for compose buffer metadata#53
barrettruth merged 1 commit intomainfrom
feat/compose-completion

Conversation

@barrettruth
Copy link
Copy Markdown
Owner

Summary

Adds context-aware completion for metadata fields in compose buffers (PR create, PR edit, issue create). Closes #45.

When the cursor is on a Labels:, Assignees:, Reviewers:, or Milestone: line inside the compose comment block, completion candidates are fetched from the forge API and offered via Neovim's built-in omnifunc.

How it works

  • lua/forge/completion.lua — new module implementing the omnifunc

    • Detects which metadata field the cursor is on via line pattern matching
    • Fetches candidates from f:completion_cmd(field) (newline-delimited output)
    • Caches results per-forge per-field with a 5-minute TTL
    • Filters by typed prefix (case-insensitive)
  • completion_cmd(field) — new backend method on all 3 forges:

    Field GitHub GitLab Codeberg
    labels gh label list --json name --jq .[].name glab label list tea api /repos/:owner/:repo/labels
    assignees/reviewers gh api repos/{nwo}/collaborators --jq .[].login glab api projects/:id/members/all tea api /repos/:owner/:repo/collaborators
    milestone gh api repos/{nwo}/milestones --jq .[].title glab api projects/:id/milestones?state=active tea api /repos/:owner/:repo/milestones?state=open
  • compose.lua — sets omnifunc on all compose buffers via create_compose_buf()

User experience

  • With blink.cmp or nvim-cmp: completions appear automatically (both plugins pick up omnifunc sources)
  • Without a completion plugin: trigger with Ctrl-X Ctrl-O (standard Vim omni-completion)
  • Completions only activate on metadata lines inside the <!-- --> comment block — no interference with title/body editing

Files changed

  • lua/forge/completion.lua — new (omnifunc + cache)
  • lua/forge/compose.lua — +1 line (set omnifunc)
  • lua/forge/github.lua — +completion_cmd()
  • lua/forge/gitlab.lua — +completion_cmd()
  • lua/forge/codeberg.lua — +completion_cmd()
  • lua/forge/config.lua — +type annotation

Test plan

  • All 158 existing tests pass
  • StyLua formatting clean
  • Manual: open compose buffer, cursor on Labels line, Ctrl-X Ctrl-O shows repo labels
  • Manual: cursor on Assignees line shows collaborators
  • Manual: cursor on Milestone line shows milestones
  • Manual: completions are cached (second trigger is instant)
  • Manual: works with blink.cmp auto-completion

Add context-aware completion for compose buffers with two modes:

Metadata fields (in <!-- --> comment block):
- Draft: true/false
- Labels, Assignees, Reviewers, Milestone from forge API

Body triggers (in title/body text):
- #  → issue/PR number completion with titles shown in menu
- @  → user mention completion from collaborators list

The omnifunc detects context automatically: comment block lines get
field-based completion, body text gets trigger-based completion on
# and @. Results are cached for 5 minutes per forge per field.

Works automatically with blink.cmp and nvim-cmp. Without a completion
plugin, trigger via Ctrl-X Ctrl-O.

Closes #45
@barrettruth barrettruth force-pushed the feat/compose-completion branch from ad479c2 to e1c7b90 Compare April 4, 2026 23:25
@barrettruth barrettruth merged commit 283c267 into main Apr 4, 2026
7 checks passed
@barrettruth barrettruth deleted the feat/compose-completion branch April 4, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enable blink completion/custom completion in our lines/fetch via github api/blink integration

1 participant