lsp

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package lsp serves the Language Server Protocol for TDL: diagnostics, go to definition, hover, document symbols, and formatting.

See docs/design/lsp.md and docs/design/lsp-plan.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, rwc io.ReadWriteCloser, opts ...sema.Option) error

Serve runs a server over one connection and returns when it ends.

protocol.NewServer builds the connection because only its unexported codec decodes union-typed parameters. Nothing is logged, since stdout is the stream on a stdio server.

Types

type Server

type Server struct {
	protocol.UnimplementedServer
	// contains filtered or unexported fields
}

Server answers protocol requests about the documents an editor has open. A request it does not implement gets "method not found" from the embedded protocol.UnimplementedServer.

func NewServer

func NewServer(opts ...sema.Option) *Server

NewServer returns a server analyzing every document with opts. The server appends its own loader, so an import of an open document resolves to its unsaved text. The client comes from each request's context.

func (*Server) Definition

Definition answers where the name under the cursor was declared, read from the index sema records while it resolves. It returns nothing when the cursor is not on a name, the name did not resolve, or it resolved into the embedded prelude.

func (*Server) DidChange

func (s *Server) DidChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) error

DidChange replaces a document's text and re-analyzes it. With full sync the last change carries the whole document; a range change was never advertised and is ignored. A change for a file never opened is dropped.

func (*Server) DidClose

func (s *Server) DidClose(ctx context.Context, params *protocol.DidCloseTextDocumentParams) error

DidClose forgets a document and clears what it published. Every other open document is re-analyzed, since an import of this one reads the disk from here on.

func (*Server) DidOpen

func (s *Server) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error

DidOpen analyzes a document the editor has opened.

func (*Server) DidSave

func (s *Server) DidSave(ctx context.Context, params *protocol.DidSaveTextDocumentParams) error

DidSave re-analyzes, because a file this document imports may have been written by something other than the editor.

func (*Server) DocumentSymbol

DocumentSymbol is the outline of a document: each declaration, with its fields and variants as children. It reads the tree, so a file that does not parse still outlines what the parser recovered.

func (*Server) Exit

func (s *Server) Exit(context.Context) error

func (*Server) Formatting

Formatting is `tdl fmt` over the editor's text, returned as one edit replacing the whole document. The client's formatting options are ignored. A file that does not parse is left alone, since printing its tree would delete what the parser could not read.

func (*Server) Hover

func (s *Server) Hover(_ context.Context, params *protocol.HoverParams) (*protocol.Hover, error)

Hover describes the name under the cursor: the declaration it refers to in canonical form, its deprecation, and its doc comment. A reference is answered from the index Definition reads, including one into the prelude; a declaration's own name is found in the tree.

func (*Server) Initialize

Initialize reports what this server serves. Text synchronization is full: a .tdl file is small, and incremental sync would add a way for the server's copy to drift from the editor's.

func (*Server) Initialized

func (*Server) SetTrace

func (*Server) Shutdown

func (s *Server) Shutdown(context.Context) error

Jump to

Keyboard shortcuts

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