Skip to content

feat(lua): inline input completers with a bundled @-files source - #886

Open
Firaenix wants to merge 1 commit into
tontinton:mainfrom
Firaenix:pr/input-completers
Open

feat(lua): inline input completers with a bundled @-files source#886
Firaenix wants to merge 1 commit into
tontinton:mainfrom
Firaenix:pr/input-completers

Conversation

@Firaenix

Copy link
Copy Markdown

Independent of the other open PRs; based directly on main.

Typing a registered trigger char at a word boundary in the prompt opens a completion popup fed by a Lua handler:

maki.api.register_input_completer({
  trigger = "#",
  name = "issues",
  handler = function(query)
    return { { label = "#123 fix the thing", insert = "https://...", detail = "author" } }
  end,
})

The handler is re-queried on every keystroke and answers over a channel, so a slow source (a CLI call, an HTTP API) never blocks typing; the popup shows searching… until the first reply, no matches on an empty one, and closes on a handler error. Up/Down navigate, Tab/Enter replace the trigger and query with the selected item's insert text (defaulting to its label), Esc dismisses and keeps the literal text until the trigger context changes. Stale replies are discarded by generation, and /reload clears a plugin's completers.

A bundled file_mention plugin binds @ to project file paths (gitignore-aware, most recently modified first), so @ma<Tab> inserts src/main.rs out of the box.

Also adds maki.ui.insert_input(text), letting plugins put text into the prompt at the cursor without submitting it.

Covered by handler round-trip and registration tests on the Lua side, popup unit tests (trigger detection, re-query, accept, dismiss, failure), and app-level tests for accept-into-input and plain submit.

Plugins can now register inline completion sources for the prompt input:

    maki.api.register_input_completer({
      trigger = "#",
      name = "github-prs",
      handler = function(query)
        return { { label = "tontinton#123 fix the thing", insert = "https://..." } }
      end,
    })

Typing the trigger at a word boundary opens a popup above the input that
is re-queried on every keystroke. Up/Down navigate, Tab/Enter replace the
trigger and query with the selected item's insert text, and Esc keeps the
literal text. Handlers run on the plugin thread and answer over a
channel, so a slow source never blocks typing; a handler error simply
closes the popup.

A bundled file_mention plugin binds `@` to project file paths
(gitignore-aware, most recently modified first).

Also adds maki.ui.insert_input(text) so plugins can put text into the
prompt without submitting it.
@Firaenix
Firaenix force-pushed the pr/input-completers branch from 678eb04 to 007cd6d Compare August 27, 2026 13:41
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.

1 participant