lsptool

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package lsptool adapts an *lsp.Client into ds4go.ToolHandler values so a model running in a ds4go.ToolLoop can query a language server.

Index

Constants

View Source
const DefaultDiagnosticsTimeout = 5 * time.Second

DefaultDiagnosticsTimeout bounds the wait in the diagnostics tool.

Variables

This section is empty.

Functions

func NewCompletionTool

func NewCompletionTool(q Querier) ds4go.ToolHandler

NewCompletionTool returns a tool that returns completion suggestions at a 1-based line and character position in a document.

func NewDiagnosticsTool

func NewDiagnosticsTool(q Querier) ds4go.ToolHandler

NewDiagnosticsTool returns a tool that reports diagnostics for a document. If "code" is supplied, the document is updated and re-checked first. Without "code" it returns the latest buffered diagnostics, which may lag the most recent edit.

func NewHoverTool

func NewHoverTool(q Querier) ds4go.ToolHandler

NewHoverTool returns a tool that returns hover info at a 1-based line and character position in a document.

func NewSymbolsTool

func NewSymbolsTool(q Querier) ds4go.ToolHandler

NewSymbolsTool returns a tool that lists the document outline for a document.

Types

type Querier

type Querier interface {
	Update(ctx context.Context, uri, text string) (int, error)
	WaitForDiagnostics(ctx context.Context, uri string, timeout time.Duration) ([]lsp.Diagnostic, error)
	Diagnostics(uri string) []lsp.Diagnostic
	Hover(ctx context.Context, uri string, line, col int) (string, error)
	Symbols(ctx context.Context, uri string) ([]lsp.Symbol, error)
	Completion(ctx context.Context, uri string, line, col, limit int) ([]string, int, error)
}

Querier is the subset of *lsp.Client the tools need. *lsp.Client satisfies it; tests substitute a fake.

Jump to

Keyboard shortcuts

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