lsptools

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lsptools serves the language server's workspace over MCP: the documents under the root, their diagnostics, navigation, editing and rendering, as tools an agent calls instead of an editor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(s *mcp.Server, h *Host)

Register adds the workspace tools and resources to s.

Types

type ApplyModelEditInput

type ApplyModelEditInput struct {
	Path       string                   `json:"path" jsonschema:"the document the operations address, absolute or relative to the workspace root"`
	Operations []lsp.ModelEditOperation `json:"operations"`
	Apply      bool                     `` /* 192-byte string literal not displayed */
}

ApplyModelEditInput carries model-level operations against a document.

type CloseDocumentInput

type CloseDocumentInput struct {
	Path string `json:"path" jsonschema:"an open document, absolute or relative to the workspace root"`
}

CloseDocumentInput names the open document to release.

type CodeAction

type CodeAction struct {
	Title       string      `json:"title"`
	Kind        string      `json:"kind,omitempty"`
	IsPreferred bool        `json:"isPreferred,omitempty"`
	Diagnostics []string    `json:"diagnostics,omitempty" jsonschema:"messages of the diagnostics the action addresses"`
	Changes     []FileEdits `json:"changes" jsonschema:"the edits the action makes, per document"`
}

CodeAction is a quick fix or refactoring with its edits.

type CodeActionsResult

type CodeActionsResult struct {
	Actions []CodeAction `json:"actions"`
}

CodeActionsResult lists actions.

type CompletionItem

type CompletionItem struct {
	Label         string `json:"label"`
	Kind          string `json:"kind,omitempty"`
	Detail        string `json:"detail,omitempty"`
	Documentation string `json:"documentation,omitempty"`
	InsertText    string `json:"insertText,omitempty" jsonschema:"the text to insert when it differs from the label"`
}

CompletionItem is one completion proposal.

type CompletionResult

type CompletionResult struct {
	Items        []CompletionItem `json:"items"`
	IsIncomplete bool             `json:"isIncomplete,omitempty"`
}

CompletionResult lists proposals.

type Diagnostic

type Diagnostic struct {
	Path     string `json:"path"`
	Range    Range  `json:"range"`
	Severity string `json:"severity" jsonschema:"error, warning, info or hint"`
	Code     string `json:"code,omitempty" jsonschema:"the stable identifier of the check"`
	Message  string `json:"message"`
	Source   string `json:"source,omitempty" jsonschema:"the pass that produced the diagnostic"`
}

Diagnostic is one finding of the analysis.

type DiagnosticsInput

type DiagnosticsInput struct {
	Path string `` /* 133-byte string literal not displayed */
}

DiagnosticsInput names one document, or none for the whole workspace.

type DiagnosticsResult

type DiagnosticsResult struct {
	Diagnostics []Diagnostic `json:"diagnostics"`
	Errors      int          `json:"errors"`
	Warnings    int          `json:"warnings"`
	Documents   int          `json:"documents" jsonschema:"documents analyzed"`
}

DiagnosticsResult lists diagnostics with counts.

type DocumentState

type DocumentState struct {
	Path        string       `json:"path"`
	Version     int          `json:"version" jsonschema:"the buffer's version, incremented by each update"`
	Open        bool         `json:"open" jsonschema:"whether the server now holds an open buffer for the document"`
	Diagnostics []Diagnostic `json:"diagnostics" jsonschema:"the diagnostics of the text now held"`
}

DocumentState reports an open document's version and diagnostics after a change.

type DocumentSymbolsResult

type DocumentSymbolsResult struct {
	Symbols []Symbol `json:"symbols"`
}

DocumentSymbolsResult is a document's outline.

type FileEdits

type FileEdits struct {
	Path  string     `json:"path"`
	Edits []TextEdit `json:"edits" jsonschema:"edits to the document's current text, non-overlapping, in document order"`
}

FileEdits is the edits a change makes to one document.

type FormatInput

type FormatInput struct {
	Path  string `json:"path" jsonschema:"the document to format, absolute or relative to the workspace root"`
	Range *Range `json:"range,omitempty" jsonschema:"format only the lines this range touches; omitted, the whole document"`
	Apply bool   `` /* 189-byte string literal not displayed */
}

FormatInput names the document, and optionally the lines, to format.

type FormatResult

type FormatResult struct {
	Path    string     `json:"path"`
	Edits   []TextEdit `json:"edits" jsonschema:"the edits that format the document; empty when it is already formatted"`
	Text    string     `json:"text" jsonschema:"the document's text with the edits applied"`
	Applied bool       `json:"applied" jsonschema:"whether the text was written to disk"`
}

FormatResult is the formatting of a document.

type Host

type Host struct {
	Root      string
	Server    *lsp.Server
	Workspace *model.Workspace
	// contains filtered or unexported fields
}

Host is the language server the tools call, initialized over the workspace root with no editor attached: the tools are its client.

func NewHost

func NewHost(ctx context.Context, root string, ws *model.Workspace, version string) (*Host, error)

NewHost starts a language server over root and indexes the model documents under it.

func (*Host) Close

func (h *Host) Close(ctx context.Context) error

Close ends the language server session, releasing what it holds.

func (*Host) Refresh

func (h *Host) Refresh(ctx context.Context)

Refresh reconciles the workspace with the root as it is on disk now. An editor reports file changes to the language server as they happen; an agent edits files with its own tools and tells no one, so every tool that reads the workspace refreshes it first.

type HoverResult

type HoverResult struct {
	Markdown string `json:"markdown" jsonschema:"the hover text, Markdown; empty when nothing is at the position"`
	Range    *Range `json:"range,omitempty" jsonschema:"the span the hover applies to"`
}

HoverResult is what hovering a position shows.

type ImportDiagramInput added in v0.12.0

type ImportDiagramInput struct {
	Path    string `json:"path" jsonschema:"the document declaring the view, absolute or relative to the workspace root"`
	File    string `` /* 129-byte string literal not displayed */
	Content string `` /* 159-byte string literal not displayed */
	View    string `json:"view,omitempty" jsonschema:"the view to import when the file has several pages; omitted, the one page's view"`
	Inline  bool   `json:"inline,omitempty" jsonschema:"write the annotations beside the elements rather than in the view's body"`
	Apply   bool   `` /* 135-byte string literal not displayed */
}

ImportDiagramInput names the document whose view a draw.io file draws and the file, edited in draw.io after render_view wrote it with form drawio.

type ImportDiagramResult added in v0.12.0

type ImportDiagramResult struct {
	View      string                  `json:"view" jsonschema:"the view the file draws"`
	Edits     []lsp.ImportDiagramEdit `json:"edits" jsonschema:"the DiagramLayout annotations the import plans, each from one cell"`
	Unmatched []string                `json:"unmatched,omitempty" jsonschema:"elements the file names that the rendering lacks; their cells are not imported"`
	Unknown   []string                `json:"unknown,omitempty" jsonschema:"cells naming no element; nothing is created for them"`
	Deleted   []string                `json:"deleted,omitempty" jsonschema:"elements whose cells the file lost; nothing is deleted for them"`
	Notices   []string                `json:"notices,omitempty" jsonschema:"changes the file shows that no annotation carries yet"`
	Refused   []lsp.ModelEditRefusal  `json:"refused,omitempty" jsonschema:"the planned edit the model editor refused, with why"`
	Changes   []FileEdits             `json:"changes" jsonschema:"the text edits, per document"`
	Applied   bool                    `json:"applied" jsonschema:"whether the edits were written to disk"`
}

ImportDiagramResult is what the import plans and leaves alone, and the text edits the plan amounts to, written when apply was asked.

type InlayHint

type InlayHint struct {
	Position toolkit.Position `json:"position"`
	Label    string           `json:"label"`
	Kind     string           `json:"kind,omitempty" jsonschema:"type or parameter"`
	Tooltip  string           `json:"tooltip,omitempty"`
}

InlayHint is text shown inline without being in the document.

type InlayHintsResult

type InlayHintsResult struct {
	Hints []InlayHint `json:"hints"`
}

InlayHintsResult lists hints.

type Location

type Location struct {
	Path  string `json:"path"`
	Range Range  `json:"range"`
}

Location is a span of a document.

type LocationsResult

type LocationsResult struct {
	Locations []Location `json:"locations"`
}

LocationsResult lists locations.

type ModelEditResult

type ModelEditResult struct {
	Changes []FileEdits            `json:"changes" jsonschema:"the text edits the operations amount to, per document; empty when every operation was refused"`
	Refused []lsp.ModelEditRefusal `` /* 149-byte string literal not displayed */
	Version int                    `json:"version" jsonschema:"the version of the document the edits apply to"`
	Applied bool                   `json:"applied" jsonschema:"whether the edits were written to disk"`
}

ModelEditResult is the outcome of apply_model_edit.

type NoInput

type NoInput struct{}

NoInput takes no arguments.

type OpenDocumentInput

type OpenDocumentInput struct {
	Path string `json:"path" jsonschema:"the document, absolute or relative to the workspace root; it need not exist on disk yet"`
	Text string `json:"text" jsonschema:"the full text to hold as the document's content"`
}

OpenDocumentInput names a document and the text to hold open for it.

type PathInput

type PathInput struct {
	Path string `` /* 142-byte string literal not displayed */
}

PathInput names a document.

type PositionInput

type PositionInput struct {
	Path     string           `` /* 142-byte string literal not displayed */
	Position toolkit.Position `json:"position" jsonschema:"the position (1-based line and character column)"`
}

PositionInput is a document position.

type Range

type Range struct {
	Start toolkit.Position `json:"start" jsonschema:"first character of the span (1-based line and column)"`
	End   toolkit.Position `json:"end" jsonschema:"character after the span (1-based line and column)"`
}

Range is a span of a document in 1-based lines and character columns; End is exclusive, as in the protocol.

type RangeInput

type RangeInput struct {
	Path  string `json:"path" jsonschema:"the document, absolute or relative to the workspace root"`
	Range *Range `json:"range,omitempty" jsonschema:"the lines of interest (1-based); omitted, the whole document"`
}

RangeInput names a range of a document.

type ReferencesInput

type ReferencesInput struct {
	PositionInput
	IncludeDeclaration bool `json:"includeDeclaration,omitempty" jsonschema:"also list the declaration itself"`
}

ReferencesInput adds whether the declaration counts as a reference.

type RenameInput

type RenameInput struct {
	Path     string           `json:"path" jsonschema:"the document, absolute or relative to the workspace root"`
	Position toolkit.Position `json:"position" jsonschema:"a position on the name to rename (1-based line and column)"`
	NewName  string           `json:"newName" jsonschema:"the new name"`
	Apply    bool             `` /* 192-byte string literal not displayed */
}

RenameInput names the symbol at a position and its new name.

type RenderDocumentInput

type RenderDocumentInput struct {
	Name         string   `json:"name" jsonschema:"the qualified name of a document definition (doc def), as documents lists"`
	DiagramForm  string   `` /* 171-byte string literal not displayed */
	Show         []string `` /* 242-byte string literal not displayed */
	LinkTemplate string   `` /* 141-byte string literal not displayed */
}

RenderDocumentInput names a document definition to render.

type RenderViewInput

type RenderViewInput struct {
	Path         string   `json:"path" jsonschema:"the document, absolute or relative to the workspace root"`
	View         string   `` /* 299-byte string literal not displayed */
	Form         string   `` /* 232-byte string literal not displayed */
	Palette      string   `` /* 225-byte string literal not displayed */
	Style        string   `` /* 153-byte string literal not displayed */
	Ports        string   `` /* 176-byte string literal not displayed */
	Lines        string   `json:"lines,omitempty" jsonschema:"how dot and plantuml route edges: splines (the default), ortho or polyline"`
	Compartments string   `` /* 352-byte string literal not displayed */
	Show         []string `` /* 288-byte string literal not displayed */
	Depth        int      `` /* 219-byte string literal not displayed */
	Overlay      string   `` /* 168-byte string literal not displayed */
	LinkTemplate string   `` /* 141-byte string literal not displayed */
}

RenderViewInput asks for one rendering of a document's view.

type Signature

type Signature struct {
	Label         string   `json:"label"`
	Documentation string   `json:"documentation,omitempty"`
	Parameters    []string `json:"parameters"`
}

Signature is one callable signature.

type SignatureHelpResult

type SignatureHelpResult struct {
	Signatures      []Signature `json:"signatures"`
	ActiveSignature int         `json:"activeSignature"`
	ActiveParameter int         `json:"activeParameter"`
}

SignatureHelpResult describes the call around a position.

type Symbol

type Symbol struct {
	Name           string   `json:"name"`
	Kind           string   `json:"kind" jsonschema:"the LSP symbol kind name (Class, Property, Package, ...)"`
	Detail         string   `json:"detail,omitempty"`
	Range          Range    `json:"range" jsonschema:"the whole declaration"`
	SelectionRange Range    `json:"selectionRange" jsonschema:"the name"`
	Children       []Symbol `json:"children,omitempty"`
}

Symbol is an element a document declares, with the elements it owns.

type TextEdit

type TextEdit struct {
	Range   Range  `json:"range"`
	NewText string `json:"newText" jsonschema:"the text that replaces the range; empty deletes it"`
}

TextEdit replaces the text of Range with NewText.

type UpdateDocumentInput

type UpdateDocumentInput struct {
	Path string `json:"path" jsonschema:"an open document, absolute or relative to the workspace root"`
	Text string `json:"text" jsonschema:"the full new text of the document"`
}

UpdateDocumentInput replaces the text of an open document.

type WorkspaceEditResult

type WorkspaceEditResult struct {
	Changes []FileEdits `json:"changes" jsonschema:"the edits, per document"`
	Applied bool        `json:"applied" jsonschema:"whether the edits were written to disk"`
}

WorkspaceEditResult is a change spanning documents.

type WorkspaceInfo

type WorkspaceInfo struct {
	Root      string   `json:"root" jsonschema:"the workspace folder the server indexed"`
	Documents []string `json:"documents" jsonschema:"paths of the model documents indexed, the standard library excluded"`
	Open      []string `json:"open,omitempty" jsonschema:"documents whose text is held open with edits not yet on disk"`
}

WorkspaceInfo describes the workspace the server holds.

type WorkspaceInfoInput

type WorkspaceInfoInput struct{}

WorkspaceInfoInput takes no arguments.

type WorkspaceSymbol

type WorkspaceSymbol struct {
	Name      string `json:"name"`
	Kind      string `json:"kind"`
	Container string `json:"container,omitempty" jsonschema:"the name of the owning element"`
	Location  Location
}

WorkspaceSymbol is an element matched by name.

type WorkspaceSymbolsInput

type WorkspaceSymbolsInput struct {
	Query string `json:"query,omitempty" jsonschema:"case-insensitive substring of the name; empty lists every named element"`
	Limit int    `json:"limit,omitempty" jsonschema:"at most this many matches; default 200"`
}

WorkspaceSymbolsInput filters symbols by name.

type WorkspaceSymbolsResult

type WorkspaceSymbolsResult struct {
	Symbols []WorkspaceSymbol `json:"symbols"`
	Total   int               `json:"total" jsonschema:"matches before the limit"`
}

WorkspaceSymbolsResult lists matches.

Jump to

Keyboard shortcuts

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