lsp

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package lsp provides LSP query operations for the type system.

Index

Constants

This section is empty.

Variables

View Source
var LuaBuiltins = map[string]bool{
	"_G": true, "_ENV": true, "_VERSION": true,
	"print": true, "error": true, "assert": true,
	"type": true, "pairs": true, "ipairs": true,
	"next": true, "select": true, "tonumber": true,
	"tostring": true, "pcall": true, "xpcall": true,
	"require": true, "load": true, "loadfile": true,
	"dofile": true, "rawget": true, "rawset": true,
	"rawequal": true, "rawlen": true, "setmetatable": true,
	"getmetatable": true, "collectgarbage": true,
}

LuaBuiltins contains standard Lua built-in functions.

View Source
var LuaKeywordSet = func() map[string]bool {
	m := make(map[string]bool, len(LuaKeywords))
	for _, kw := range LuaKeywords {
		m[kw] = true
	}
	return m
}()

LuaKeywordSet provides O(1) keyword lookup.

View Source
var LuaKeywords = []string{
	"and", "break", "do", "else", "elseif", "end",
	"false", "for", "function", "goto", "if", "in",
	"local", "nil", "not", "or", "repeat", "return",
	"then", "true", "until", "while",
}

LuaKeywords contains all Lua reserved words.

Functions

func FormatType

func FormatType(t any) string

FormatType formats a type for display in hover/completion.

func IsLuaBuiltin

func IsLuaBuiltin(name string) bool

IsLuaBuiltin returns true if name is a Lua built-in.

func IsLuaKeyword

func IsLuaKeyword(name string) bool

IsLuaKeyword returns true if name is a Lua reserved word.

Types

type DefinitionResult

type DefinitionResult struct {
	File string
	Span diag.Span
}

DefinitionResult contains go-to-definition target.

type DocumentSymbol

type DocumentSymbol struct {
	Name     string
	Kind     index.SymbolKind
	Span     diag.Span
	Children []*DocumentSymbol
}

DocumentSymbol represents a symbol for document outline.

type HoverResult

type HoverResult struct {
	Type      any // The type at the position (core.Type)
	Signature string
	Symbol    *index.Symbol
	Span      diag.Span
}

HoverResult contains information for hover display.

type ManifestRegistry

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

ManifestRegistry stores type manifests for cross-module resolution.

func NewManifestRegistry

func NewManifestRegistry() *ManifestRegistry

NewManifestRegistry creates an empty manifest registry.

func (*ManifestRegistry) All

func (r *ManifestRegistry) All() []*io.Manifest

All returns all registered manifests.

func (*ManifestRegistry) Clear

func (r *ManifestRegistry) Clear()

Clear removes all manifests.

func (*ManifestRegistry) FindType

func (r *ManifestRegistry) FindType(name string) (*io.Manifest, typ.Type)

FindType searches for a type by name across all manifests. Supports both "TypeName" and "module.TypeName" formats.

func (*ManifestRegistry) Lookup

func (r *ManifestRegistry) Lookup(path string) *io.Manifest

Lookup retrieves a manifest by module path.

func (*ManifestRegistry) Register

func (r *ManifestRegistry) Register(manifest *io.Manifest)

Register adds a manifest to the registry.

func (*ManifestRegistry) Remove

func (r *ManifestRegistry) Remove(path string)

Remove removes a manifest by path.

func (*ManifestRegistry) SearchSymbols

func (r *ManifestRegistry) SearchSymbols(query string) []*index.WorkspaceSymbol

SearchSymbols searches for symbols across all manifests.

type ReferenceKind

type ReferenceKind int

ReferenceKind indicates the type of reference.

const (
	RefRead ReferenceKind = iota
	RefWrite
	RefDefinition
)

type ReferenceResult

type ReferenceResult struct {
	File string
	Span diag.Span
	Kind ReferenceKind
}

ReferenceResult contains find-references results.

type Service

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

Service provides LSP query operations.

func NewService

func NewService(cache *index.DB, symbols *index.SymbolIndex, callGraph *index.CallGraph) *Service

NewService creates a new LSP service with the given indexes.

func (*Service) Cache

func (s *Service) Cache() *index.DB

Cache returns the cache database.

func (*Service) CallGraph

func (s *Service) CallGraph() *index.CallGraph

CallGraph returns the call graph.

func (*Service) CalleesOf

func (s *Service) CalleesOf(file string, line, col int) []*index.CallEdge

CalleesOf returns all functions called by the function at the given position.

func (*Service) CallersOf

func (s *Service) CallersOf(file string, line, col int) []*index.CallEdge

CallersOf returns all callers of the function at the given position.

func (*Service) Clear

func (s *Service) Clear()

Clear clears all cached data.

func (*Service) DefinitionAt

func (s *Service) DefinitionAt(file string, line, col int) *DefinitionResult

DefinitionAt returns the definition location for symbol at position.

func (*Service) DocumentSymbols

func (s *Service) DocumentSymbols(file string) []*DocumentSymbol

DocumentSymbols returns all symbols in a file for document outline.

func (*Service) HoverAt

func (s *Service) HoverAt(file string, line, col int) *HoverResult

HoverAt returns type information at the given position.

func (*Service) InvalidateFile

func (s *Service) InvalidateFile(file string)

InvalidateFile invalidates cache, symbols, and call graph for a file.

func (*Service) Manifests

func (s *Service) Manifests() *ManifestRegistry

Manifests returns the manifest registry.

func (*Service) ReferencesAt

func (s *Service) ReferencesAt(file string, line, col int, includeDecl bool) []ReferenceResult

ReferencesAt returns all references to the symbol at position.

func (*Service) RegisterManifest

func (s *Service) RegisterManifest(manifest *io.Manifest)

RegisterManifest adds a manifest to the service.

func (*Service) Symbols

func (s *Service) Symbols() *index.SymbolIndex

Symbols returns the symbol index.

func (*Service) WorkspaceSymbols

func (s *Service) WorkspaceSymbols(query string) []*index.WorkspaceSymbol

WorkspaceSymbols searches for symbols matching a query across all files.

Directories

Path Synopsis
Package completion provides code completion for LSP.
Package completion provides code completion for LSP.
Package edit provides text editing utilities for the language server.
Package edit provides text editing utilities for the language server.
Package index provides per-function indexing for type checking results.
Package index provides per-function indexing for type checking results.
Package refactor provides code refactoring operations for the language server.
Package refactor provides code refactoring operations for the language server.
Package semantic provides semantic token analysis for syntax highlighting.
Package semantic provides semantic token analysis for syntax highlighting.
Package signature provides function signature help for the language server.
Package signature provides function signature help for the language server.

Jump to

Keyboard shortcuts

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