codeaction

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package codeaction renders nook's LSP code-action picker — a small bordered menu listing the actions the language server proposed at the cursor. The user picks one with the arrow keys and accepts with Enter; the host then applies the chosen action's workspace edit.

The popup is a pure value: the host owns when it appears and what items it carries. codeaction.Popup knows only how to navigate its own list and render a bordered menu at a requested width.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

Popup is the immutable state of the code-action menu. New() returns an empty popup; WithItems re-arms it with a fresh result set and resets the selection.

func New

func New() Popup

New returns an empty popup. View() on an empty popup returns "".

func (Popup) Empty

func (p Popup) Empty() bool

Empty reports whether the popup has nothing to show.

func (Popup) Len

func (p Popup) Len() int

Len returns the number of items in the popup.

func (Popup) MoveDown

func (p Popup) MoveDown() Popup

MoveDown shifts the highlight down one row, wrapping to the top.

func (Popup) MoveUp

func (p Popup) MoveUp() Popup

MoveUp shifts the highlight up one row, wrapping to the bottom.

func (Popup) Selected

func (p Popup) Selected() (nooklsp.CodeActionItem, bool)

Selected returns the currently-highlighted action and true, or the zero value and false if the popup is empty or the highlighted action is disabled (the host should refuse to apply a disabled action).

func (Popup) View

func (p Popup) View(t theme.Theme, width, maxRows int) string

View renders the popup at the requested outer width and row cap. Returns "" for an empty popup so the host can render unconditionally.

func (Popup) WithItems

func (p Popup) WithItems(items []nooklsp.CodeActionItem) Popup

WithItems returns a popup carrying these items, with the first non-disabled item selected by default. If every item is disabled, the first one is selected anyway so the popup has a stable cursor.

Jump to

Keyboard shortcuts

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