lookup

package
v0.21.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: 6 Imported by: 0

Documentation

Overview

Package lookup turns LSP textDocument lookups (hover, definition) into async tea.Cmd factories. The host model fires a Cmd from a key handler and reacts to the matching message a few milliseconds later.

The package owns the request timeout (2s — gopls responses are sub-second in the common case) and the nil-client guard, so the host doesn't have to branch on "do we have an LSP yet" before binding the key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeActionCmd added in v0.10.0

func CodeActionCmd(client *nooklsp.Client, path string, row, col int) tea.Cmd

CodeActionCmd returns a tea.Cmd that calls client.CodeAction and wraps the result in CodeActionMsg. nil-client behavior mirrors HoverCmd: the message carries errNoClient so the host can bind Alt+Enter unconditionally.

func CompletionCmd

func CompletionCmd(client *nooklsp.Client, path string, row, col, prefixLen int) tea.Cmd

CompletionCmd returns a tea.Cmd that calls client.Completion and wraps the result in CompletionMsg. nil-client returns a message carrying errNoClient so the host can bind a trigger key (Ctrl+Space) regardless of LSP readiness.

func DefinitionCmd

func DefinitionCmd(client *nooklsp.Client, path string, row, col int) tea.Cmd

DefinitionCmd returns a tea.Cmd that calls client.Definition and wraps the result in DefinitionMsg. nil-client behavior matches HoverCmd: the message carries errNoClient instead of panicking.

func FormattingCmd added in v0.8.0

func FormattingCmd(client *nooklsp.Client, path string, version int32, tabSize int, insertSpaces bool) tea.Cmd

FormattingCmd returns a tea.Cmd that calls client.Formatting and wraps the result in FormattingMsg. version echoes the LSP didChange version the caller knew about at request time so a stale response can be detected and ignored. nil-client returns a message carrying errNoClient so the host can bind Ctrl+S unconditionally and degrade to a plain save.

func HoverCmd

func HoverCmd(client *nooklsp.Client, path string, row, col int) tea.Cmd

HoverCmd returns a tea.Cmd that calls client.Hover and wraps the result in HoverMsg. A nil client short-circuits to a HoverMsg with errNoClient — the host can bind the key unconditionally.

func InlayHintCmd added in v0.14.0

func InlayHintCmd(client *nooklsp.Client, path string, version int32, startLine, endLine int) tea.Cmd

InlayHintCmd returns a tea.Cmd that calls client.InlayHint over a line range and wraps the result in InlayHintMsg. startLine is inclusive, endLine is exclusive (LSP semantics; pass the row past the last visible line). nil-client returns a message carrying errNoClient so the host can trigger fetches unconditionally and degrade gracefully.

func PrepareRenameCmd added in v0.10.0

func PrepareRenameCmd(client *nooklsp.Client, path string, row, col int) tea.Cmd

PrepareRenameCmd returns a tea.Cmd that calls client.PrepareRename and wraps the result in PrepareRenameMsg. nil-client returns errNoClient so the host can bind F2 unconditionally and surface a status hint.

func RenameCmd added in v0.10.0

func RenameCmd(client *nooklsp.Client, path string, row, col int, newName string) tea.Cmd

RenameCmd returns a tea.Cmd that calls client.Rename and wraps the result in RenameMsg. nil-client behavior matches the other lookups.

Types

type CodeActionMsg added in v0.10.0

type CodeActionMsg struct {
	Path  string
	Row   int
	Col   int
	Items []nooklsp.CodeActionItem
	Err   error
}

CodeActionMsg carries the result of a textDocument/codeAction request back to the host model. Path/Row/Col echo the cursor at request time so a stale response (the user moved the cursor) can be discarded by comparing them. Items is empty when the server returned nothing.

type CompletionMsg

type CompletionMsg struct {
	Path      string
	Row       int
	Col       int
	PrefixLen int
	Items     []nooklsp.CompletionItem
	Err       error
}

CompletionMsg carries the result of a completion lookup. Items is empty when the server returned nothing useful. PrefixLen is the word-prefix length the host captured at request time so it can be fed straight back into complete.Popup.WithItems.

type DefinitionMsg

type DefinitionMsg struct {
	Path      string
	Row       int
	Col       int
	Locations []nooklsp.Location
	Err       error
}

DefinitionMsg carries the result of a go-to-definition lookup. Locations is empty when the symbol has no known definition (e.g. cursor over whitespace or an unresolved import).

type FormattingMsg added in v0.8.0

type FormattingMsg struct {
	Path    string
	Version int32
	Edits   []nooklsp.TextEdit
	Err     error
}

FormattingMsg carries the result of a textDocument/formatting request back to the host model. Version echoes the LSP didChange version the request was issued against so a stale response (the user typed more after Ctrl+S) can be discarded by comparing it. Edits is empty when the server thinks the file is already well-formatted.

type HoverMsg

type HoverMsg struct {
	Path string
	Row  int
	Col  int
	Info nooklsp.HoverInfo
	Err  error
}

HoverMsg carries the result of a hover lookup back to the host model. Path/Row/Col echo the request inputs so a late response that arrived after the user moved on can be discarded by comparing them.

type InlayHintMsg added in v0.14.0

type InlayHintMsg = inlayhint.HintsMsg

InlayHintMsg carries a batch of inlay hints for a single file back to the host. Path is the file the request was pinned to; Version echoes the LSP didChange version at request time so a stale response (the user typed after the request was sent) can be discarded. Hints is keyed by row.

type PrepareRenameMsg added in v0.10.0

type PrepareRenameMsg struct {
	Path   string
	Row    int
	Col    int
	Result nooklsp.PrepareRenameResult
	Err    error
}

PrepareRenameMsg carries the result of a textDocument/prepareRename request. Path/Row/Col echo the cursor at request time so a stale response can be discarded.

type RenameMsg added in v0.10.0

type RenameMsg struct {
	Path    string
	NewName string
	Edit    nooklsp.WorkspaceEditChange
	Err     error
}

RenameMsg carries the result of a textDocument/rename request. Path is the file the rename was initiated from (useful for sourcing the cursor when applying); NewName is the name the user typed (echoed so the host can surface "renamed X to Y" status); Edit is the workspace edit to apply.

Jump to

Keyboard shortcuts

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