Documentation
¶
Overview ¶
Package completion provides code completion for LSP.
Package completion provides code completion for the Lua language server.
It analyzes the cursor position and context to suggest relevant completions including local variables, global symbols, table fields, and type members.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
File string
Line int
Col int
Trigger TriggerKind
TriggerChar string
Prefix string // text before cursor on current "word"
Kind ContextKind // detected context kind
// ReceiverType is the resolved type of the receiver for member access (after ".").
ReceiverType typ.Type
// LocalSymbols holds in-scope locals at the completion site.
// When provided, identifier completions will prefer these symbols.
LocalSymbols []*index.Symbol
}
Context describes the completion context.
type ContextKind ¶
type ContextKind int
ContextKind describes what kind of completion is needed.
const ( ContextUnknown ContextKind = iota ContextIdentifier // local variable, function name ContextMember // after "." - field/method access ContextKeyword // language keywords )
type Item ¶
type Item struct {
Label string // display text
Kind Kind // item kind
Detail string // type signature
Documentation string // doc comment
InsertText string // text to insert (may differ from label)
IsSnippet bool // if InsertText contains $1, $2 placeholders
SortText string // for ordering
FilterText string // for filtering
Deprecated bool // whether this item is deprecated
Type typ.Type // the type of the completed item
}
Item represents a completion suggestion.
type Kind ¶
type Kind int
Kind represents completion item kind (matches LSP CompletionItemKind).
const ( KindText Kind = iota + 1 KindMethod KindFunction KindConstructor KindField KindVariable KindClass KindInterface KindModule KindProperty KindUnit KindValue KindEnum KindKeyword KindSnippet KindColor KindFile KindReference KindFolder KindEnumMember KindConstant KindStruct KindEvent KindOperator KindTypeParameter )
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider handles completion requests.
func NewProvider ¶
func NewProvider(symbols *index.SymbolIndex) *Provider
NewProvider creates a completion provider.
func (*Provider) ResolveItem ¶
ResolveItem adds detail to a completion item (lazy loading).
func (*Provider) SetTypeFormatter ¶
func (p *Provider) SetTypeFormatter(f TypeFormatter)
SetTypeFormatter sets a custom type formatter for completion details.
type TriggerKind ¶
type TriggerKind int
TriggerKind describes how completion was triggered.
const ( TriggerInvoked TriggerKind = iota + 1 TriggerCharacter TriggerIncomplete )