completions

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClosedMsg

type ClosedMsg struct{}

ClosedMsg is sent when the completions are closed.

type CompletionItem

type CompletionItem struct {
	*list.Versioned
	// contains filtered or unexported fields
}

CompletionItem represents an item in the completions list.

func NewCompletionItem

func NewCompletionItem(text, desc string, value any, styles ItemStyles) *CompletionItem

NewCompletionItem creates a new completion item. desc may be empty.

func (*CompletionItem) Desc

func (c *CompletionItem) Desc() string

Desc returns the item's secondary description, if any.

func (*CompletionItem) Filter

func (c *CompletionItem) Filter() string

Filter implements list.FilterableItem.

func (*CompletionItem) Finished

func (c *CompletionItem) Finished() bool

Finished implements list.Item. Completion items render purely from (text, match, focus); any mutation (SetMatch / SetFocused) bumps Version() so the frozen cache entry invalidates on the next render. Marking them finished lets the F6 list memo skip the per-line work for the steady completions popup.

func (*CompletionItem) Render

func (c *CompletionItem) Render(width int) string

Render implements list.Item.

func (*CompletionItem) SetFocused

func (c *CompletionItem) SetFocused(focused bool)

SetFocused implements list.Focusable.

func (*CompletionItem) SetMatch

func (c *CompletionItem) SetMatch(m fuzzy.Match)

SetMatch implements list.MatchSettable.

func (*CompletionItem) SetNameColumnWidth

func (c *CompletionItem) SetNameColumnWidth(w int)

SetNameColumnWidth sets the shared name-column width used to align descriptions across all rows in the popup.

func (*CompletionItem) Text

func (c *CompletionItem) Text() string

Text returns the display text of the item.

func (*CompletionItem) Value

func (c *CompletionItem) Value() any

Value returns the value of the item.

type CompletionItemsLoadedMsg

type CompletionItemsLoadedMsg struct {
	Files     []FileCompletionValue
	Resources []ResourceCompletionValue
}

CompletionItemsLoadedMsg is sent when files have been loaded for completions.

type Completions

type Completions struct {
	// contains filtered or unexported fields
}

Completions represents the completions popup component.

func New

func New(styles Styles) *Completions

New creates a new completions component.

func (*Completions) Close

func (c *Completions) Close()

Close closes the completions popup.

func (*Completions) Filter

func (c *Completions) Filter(query string)

Filter filters the completions with the given query.

func (*Completions) HasItems

func (c *Completions) HasItems() bool

HasItems returns whether there are visible items.

func (*Completions) IsOpen

func (c *Completions) IsOpen() bool

IsOpen returns whether the completions popup is open.

func (*Completions) KeyMap

func (c *Completions) KeyMap() KeyMap

KeyMap returns the key bindings.

func (*Completions) Open

func (c *Completions) Open(depth, limit int) tea.Cmd

Open opens the completions with file items from the filesystem.

func (*Completions) Query

func (c *Completions) Query() string

Query returns the current filter query.

func (*Completions) Render

func (c *Completions) Render() string

Render renders the completions popup: a bordered box around the item list, with a scrollbar in the right margin when there are more items than fit in the visible height.

func (*Completions) SetItems

func (c *Completions) SetItems(files []FileCompletionValue, resources []ResourceCompletionValue)

SetItems sets the files and MCP resources and rebuilds the merged list.

func (*Completions) SetSkillItems

func (c *Completions) SetSkillItems(skillItems []SkillCompletionValue)

SetSkillItems sets the skill items and opens the popup. Unlike SetItems, the data is already resident in memory (loaded once at startup), so no filesystem scan or tea.Cmd is needed.

func (*Completions) SetStyles

func (c *Completions) SetStyles(styles Styles)

SetStyles updates the styles used when rendering completion items. Existing items are not restyled; subsequent SetItems calls pick up the new styles.

func (*Completions) Size

func (c *Completions) Size() (width, height int)

Size returns the full on-screen size of the popup, including the border and the scrollbar column (when shown).

func (*Completions) Update

func (c *Completions) Update(msg tea.KeyPressMsg) (tea.Msg, bool)

Update handles key events for the completions.

type FileCompletionValue

type FileCompletionValue struct {
	Path string
}

FileCompletionValue represents a file path completion value.

type ItemStyles

type ItemStyles struct {
	Normal, Focused, Match, Desc, Icon, Bar lipgloss.Style
}

ItemStyles bundles the styles a CompletionItem needs to render.

type KeyMap

type KeyMap struct {
	Down,
	Up,
	Select,
	Cancel key.Binding
	DownInsert,
	UpInsert key.Binding
}

KeyMap defines the key bindings for the completions component.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings for completions.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns the full help for the key bindings.

func (KeyMap) KeyBindings

func (k KeyMap) KeyBindings() []key.Binding

KeyBindings returns all key bindings as a slice.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns the short help for the key bindings.

type ResourceCompletionValue

type ResourceCompletionValue struct {
	MCPName  string
	URI      string
	Title    string
	MIMEType string
}

ResourceCompletionValue represents a MCP resource completion value.

type SelectionMsg

type SelectionMsg[T any] struct {
	Value    T
	KeepOpen bool // If true, insert without closing.
}

SelectionMsg is sent when a completion is selected.

type SkillCompletionValue

type SkillCompletionValue struct {
	Name        string
	Description string
}

SkillCompletionValue represents a skill completion value.

type Styles

type Styles struct {
	ItemStyles
	Border lipgloss.Style
}

Styles bundles everything needed to render the popup and its items.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL