Documentation
¶
Overview ¶
Package server implements the luascript language server: the concrete protocol.Server that drives the compiler front-end (lex -> parse -> typecheck -> analyze) to serve diagnostics, hover, completion, formatting and a document outline to any LSP-speaking editor over stdio.
The name "proxy" is historical — an earlier design proxied to an external tool. Today the server answers every request itself; there is nothing to proxy to.
Index ¶
- func Run(ctx context.Context, logger *slog.Logger, in io.ReadCloser, out io.WriteCloser) error
- type Server
- func (Server) CodeAction(context.Context, *protocol.CodeActionParams) ([]protocol.CodeAction, error)
- func (Server) CodeLens(context.Context, *protocol.CodeLensParams) ([]protocol.CodeLens, error)
- func (Server) CodeLensRefresh(context.Context) error
- func (Server) CodeLensResolve(context.Context, *protocol.CodeLens) (*protocol.CodeLens, error)
- func (Server) ColorPresentation(context.Context, *protocol.ColorPresentationParams) ([]protocol.ColorPresentation, error)
- func (s *Server) Completion(_ context.Context, params *protocol.CompletionParams) (*protocol.CompletionList, error)
- func (Server) CompletionResolve(context.Context, *protocol.CompletionItem) (*protocol.CompletionItem, error)
- func (Server) Declaration(context.Context, *protocol.DeclarationParams) ([]protocol.Location, error)
- func (Server) Definition(context.Context, *protocol.DefinitionParams) ([]protocol.Location, error)
- func (s *Server) DidChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) error
- func (Server) DidChangeConfiguration(context.Context, *protocol.DidChangeConfigurationParams) error
- func (Server) DidChangeWatchedFiles(context.Context, *protocol.DidChangeWatchedFilesParams) error
- func (Server) DidChangeWorkspaceFolders(context.Context, *protocol.DidChangeWorkspaceFoldersParams) error
- func (s *Server) DidClose(_ context.Context, params *protocol.DidCloseTextDocumentParams) error
- func (Server) DidCreateFiles(context.Context, *protocol.CreateFilesParams) error
- func (Server) DidDeleteFiles(context.Context, *protocol.DeleteFilesParams) error
- func (s *Server) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error
- func (Server) DidRenameFiles(context.Context, *protocol.RenameFilesParams) error
- func (s *Server) DidSave(ctx context.Context, params *protocol.DidSaveTextDocumentParams) error
- func (Server) DocumentColor(context.Context, *protocol.DocumentColorParams) ([]protocol.ColorInformation, error)
- func (Server) DocumentHighlight(context.Context, *protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error)
- func (Server) DocumentLink(context.Context, *protocol.DocumentLinkParams) ([]protocol.DocumentLink, error)
- func (Server) DocumentLinkResolve(context.Context, *protocol.DocumentLink) (*protocol.DocumentLink, error)
- func (s *Server) DocumentSymbol(_ context.Context, params *protocol.DocumentSymbolParams) ([]protocol.SymbolInformationOrDocumentSymbol, error)
- func (Server) ExecuteCommand(context.Context, *protocol.ExecuteCommandParams) (any, error)
- func (Server) Exit(context.Context) error
- func (Server) FoldingRanges(context.Context, *protocol.FoldingRangeParams) ([]protocol.FoldingRange, error)
- func (s *Server) Formatting(_ context.Context, params *protocol.DocumentFormattingParams) ([]protocol.TextEdit, error)
- func (s *Server) Hover(_ context.Context, params *protocol.HoverParams) (*protocol.Hover, error)
- func (Server) Implementation(context.Context, *protocol.ImplementationParams) ([]protocol.Location, error)
- func (Server) IncomingCalls(context.Context, *protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error)
- func (s *Server) Initialize(ctx context.Context, _ *protocol.InitializeParams) (*protocol.InitializeResult, error)
- func (s *Server) Initialized(context.Context, *protocol.InitializedParams) error
- func (Server) LinkedEditingRange(context.Context, *protocol.LinkedEditingRangeParams) (*protocol.LinkedEditingRanges, error)
- func (Server) LogTrace(context.Context, *protocol.LogTraceParams) error
- func (Server) Moniker(context.Context, *protocol.MonikerParams) ([]protocol.Moniker, error)
- func (Server) OnTypeFormatting(context.Context, *protocol.DocumentOnTypeFormattingParams) ([]protocol.TextEdit, error)
- func (Server) OutgoingCalls(context.Context, *protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error)
- func (Server) PrepareCallHierarchy(context.Context, *protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error)
- func (Server) PrepareRename(context.Context, *protocol.PrepareRenameParams) (*protocol.Range, error)
- func (Server) RangeFormatting(context.Context, *protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error)
- func (Server) References(context.Context, *protocol.ReferenceParams) ([]protocol.Location, error)
- func (Server) Rename(context.Context, *protocol.RenameParams) (*protocol.WorkspaceEdit, error)
- func (Server) Request(context.Context, string, any) (any, error)
- func (Server) SemanticTokensFull(context.Context, *protocol.SemanticTokensParams) (*protocol.SemanticTokens, error)
- func (Server) SemanticTokensFullDelta(context.Context, *protocol.SemanticTokensDeltaParams) (any, error)
- func (Server) SemanticTokensRange(context.Context, *protocol.SemanticTokensRangeParams) (*protocol.SemanticTokens, error)
- func (Server) SemanticTokensRefresh(context.Context) error
- func (Server) SetTrace(context.Context, *protocol.SetTraceParams) error
- func (Server) ShowDocument(context.Context, *protocol.ShowDocumentParams) (*protocol.ShowDocumentResult, error)
- func (s *Server) Shutdown(context.Context) error
- func (Server) SignatureHelp(context.Context, *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error)
- func (Server) Symbols(context.Context, *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error)
- func (Server) TypeDefinition(context.Context, *protocol.TypeDefinitionParams) ([]protocol.Location, error)
- func (Server) WillCreateFiles(context.Context, *protocol.CreateFilesParams) (*protocol.WorkspaceEdit, error)
- func (Server) WillDeleteFiles(context.Context, *protocol.DeleteFilesParams) (*protocol.WorkspaceEdit, error)
- func (Server) WillRenameFiles(context.Context, *protocol.RenameFilesParams) (*protocol.WorkspaceEdit, error)
- func (Server) WillSave(context.Context, *protocol.WillSaveTextDocumentParams) error
- func (Server) WillSaveWaitUntil(context.Context, *protocol.WillSaveTextDocumentParams) ([]protocol.TextEdit, error)
- func (Server) WorkDoneProgressCancel(context.Context, *protocol.WorkDoneProgressCancelParams) error
- type SourceMapCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the luascript LSP server. It keeps the set of open documents and re-derives everything else (diagnostics, symbols, hover) on demand from the current text — there is no persistent AST cache, because a full recompile of a single file is cheap.
func (Server) CodeAction ¶
func (Server) CodeAction(context.Context, *protocol.CodeActionParams) ([]protocol.CodeAction, error)
func (Server) CodeLensRefresh ¶
func (Server) CodeLensResolve ¶
func (Server) ColorPresentation ¶
func (Server) ColorPresentation(context.Context, *protocol.ColorPresentationParams) ([]protocol.ColorPresentation, error)
func (*Server) Completion ¶
func (s *Server) Completion(_ context.Context, params *protocol.CompletionParams) (*protocol.CompletionList, error)
Completion returns member completions after `namespace.` (e.g. `math.` -> floor, ceil, ...), otherwise the static keyword / global / module set. In the bare case it ignores finer context — the client filters by prefix.
func (Server) CompletionResolve ¶
func (Server) CompletionResolve(context.Context, *protocol.CompletionItem) (*protocol.CompletionItem, error)
func (Server) Declaration ¶
func (Server) Definition ¶
func (Server) DidChangeConfiguration ¶
func (Server) DidChangeConfiguration(context.Context, *protocol.DidChangeConfigurationParams) error
func (Server) DidChangeWatchedFiles ¶
func (Server) DidChangeWatchedFiles(context.Context, *protocol.DidChangeWatchedFilesParams) error
func (Server) DidChangeWorkspaceFolders ¶
func (Server) DidChangeWorkspaceFolders(context.Context, *protocol.DidChangeWorkspaceFoldersParams) error
func (Server) DidCreateFiles ¶
func (Server) DidCreateFiles(context.Context, *protocol.CreateFilesParams) error
func (Server) DidDeleteFiles ¶
func (Server) DidDeleteFiles(context.Context, *protocol.DeleteFilesParams) error
func (Server) DidRenameFiles ¶
func (Server) DidRenameFiles(context.Context, *protocol.RenameFilesParams) error
func (Server) DocumentColor ¶
func (Server) DocumentColor(context.Context, *protocol.DocumentColorParams) ([]protocol.ColorInformation, error)
func (Server) DocumentHighlight ¶
func (Server) DocumentHighlight(context.Context, *protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error)
func (Server) DocumentLink ¶
func (Server) DocumentLink(context.Context, *protocol.DocumentLinkParams) ([]protocol.DocumentLink, error)
func (Server) DocumentLinkResolve ¶
func (Server) DocumentLinkResolve(context.Context, *protocol.DocumentLink) (*protocol.DocumentLink, error)
func (*Server) DocumentSymbol ¶
func (s *Server) DocumentSymbol(_ context.Context, params *protocol.DocumentSymbolParams) ([]protocol.SymbolInformationOrDocumentSymbol, error)
DocumentSymbol returns the top-level declarations for the outline view.
func (Server) ExecuteCommand ¶
func (Server) FoldingRanges ¶
func (Server) FoldingRanges(context.Context, *protocol.FoldingRangeParams) ([]protocol.FoldingRange, error)
func (*Server) Formatting ¶
func (s *Server) Formatting(_ context.Context, params *protocol.DocumentFormattingParams) ([]protocol.TextEdit, error)
Formatting reformats the whole document via the shared formatter and returns a single full-range replacement edit.
func (Server) Implementation ¶
func (Server) IncomingCalls ¶
func (Server) IncomingCalls(context.Context, *protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error)
func (*Server) Initialize ¶
func (s *Server) Initialize(ctx context.Context, _ *protocol.InitializeParams) (*protocol.InitializeResult, error)
Initialize advertises the capabilities the server actually implements.
func (*Server) Initialized ¶
Initialized is a no-op today; the client is already captured in Initialize.
func (Server) LinkedEditingRange ¶
func (Server) LinkedEditingRange(context.Context, *protocol.LinkedEditingRangeParams) (*protocol.LinkedEditingRanges, error)
func (Server) OnTypeFormatting ¶
func (Server) OutgoingCalls ¶
func (Server) OutgoingCalls(context.Context, *protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error)
func (Server) PrepareCallHierarchy ¶
func (Server) PrepareCallHierarchy(context.Context, *protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error)
func (Server) PrepareRename ¶
func (Server) RangeFormatting ¶
func (Server) References ¶
func (Server) Rename ¶
func (Server) Rename(context.Context, *protocol.RenameParams) (*protocol.WorkspaceEdit, error)
func (Server) SemanticTokensFull ¶
func (Server) SemanticTokensFull(context.Context, *protocol.SemanticTokensParams) (*protocol.SemanticTokens, error)
func (Server) SemanticTokensFullDelta ¶
func (Server) SemanticTokensRange ¶
func (Server) SemanticTokensRange(context.Context, *protocol.SemanticTokensRangeParams) (*protocol.SemanticTokens, error)
func (Server) SemanticTokensRefresh ¶
func (Server) ShowDocument ¶
func (Server) ShowDocument(context.Context, *protocol.ShowDocumentParams) (*protocol.ShowDocumentResult, error)
func (*Server) Shutdown ¶
Shutdown / Exit round out the lifecycle. Exit terminates the process; the serve loop's connection is closed by the client immediately afterwards.
func (Server) SignatureHelp ¶
func (Server) SignatureHelp(context.Context, *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error)
func (Server) Symbols ¶
func (Server) Symbols(context.Context, *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error)
func (Server) TypeDefinition ¶
func (Server) WillCreateFiles ¶
func (Server) WillCreateFiles(context.Context, *protocol.CreateFilesParams) (*protocol.WorkspaceEdit, error)
func (Server) WillDeleteFiles ¶
func (Server) WillDeleteFiles(context.Context, *protocol.DeleteFilesParams) (*protocol.WorkspaceEdit, error)
func (Server) WillRenameFiles ¶
func (Server) WillRenameFiles(context.Context, *protocol.RenameFilesParams) (*protocol.WorkspaceEdit, error)
func (Server) WillSave ¶
func (Server) WillSave(context.Context, *protocol.WillSaveTextDocumentParams) error
func (Server) WillSaveWaitUntil ¶
func (Server) WorkDoneProgressCancel ¶
func (Server) WorkDoneProgressCancel(context.Context, *protocol.WorkDoneProgressCancelParams) error
type SourceMapCache ¶
type SourceMapCache struct {
// contains filtered or unexported fields
}
SourceMapCache is a cache of .templ file URIs to the source map.
func NewSourceMapCache ¶
func NewSourceMapCache() *SourceMapCache
func (*SourceMapCache) Delete ¶
func (fc *SourceMapCache) Delete(uri string)
func (*SourceMapCache) URIs ¶
func (fc *SourceMapCache) URIs() (uris []string)