Yeesh.Completion (Yeesh v0.8.1)

View Source

Tab completion engine.

Phase 1 (Milestone 1): command name prefix matching. Phase 2 (Milestone 2): argument-level completion via Command.completions/2.

Summary

Functions

Finds the longest common prefix among a list of strings.

Returns completions for the given input and cursor position.

Functions

common_prefix(list)

@spec common_prefix([String.t()]) :: String.t()

Finds the longest common prefix among a list of strings.

complete(input, cursor_pos, session)

@spec complete(String.t(), non_neg_integer(), Yeesh.Session.t()) ::
  {[String.t()], String.t()}

Returns completions for the given input and cursor position.

Command names may be multi-word (e.g. "mix run"), so the prefix matched against the registry may itself contain spaces. Internal runs of whitespace in the input are collapsed to a single space before matching so that "mix ru" and "mix ru" behave alike.

If no registered command starts with the (normalized) prefix and the input contains a space, delegate to the command's completions/2 callback (if implemented).