lsp

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 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 lsp talks to language servers for the agent's code intelligence (spec_parity_027 PAR-TOOL-03): definitions, references, hover, symbols and diagnostics, from servers started lazily per language.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoServer = errors.New("no language server for this kind of file")

ErrNoServer means no language server is configured for the file.

Functions

This section is empty.

Types

type Diagnostic

type Diagnostic struct {
	Line     int    `json:"line"`
	Column   int    `json:"column"`
	Severity string `json:"severity"`
	Message  string `json:"message"`
	Source   string `json:"source,omitempty"`
}

Diagnostic is a problem a server reports.

type Launcher

type Launcher func(ctx context.Context, argv []string) (Process, error)

Launcher starts a server's command in the workspace (the engine's runs it guarded, in the OS sandbox).

type Location

type Location struct {
	Path   string `json:"path"`
	Line   int    `json:"line"`
	Column int    `json:"column"`
	Text   string `json:"text,omitempty"`
}

Location is a place in a file, for people: the path (relative to the workspace when inside it), 1-based line and column, and the line.

type Manager

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

Manager starts language servers as files need them, one per language, and keeps the files it asks about in sync with the disk.

func NewManager

func NewManager(root string, servers []Server, launch Launcher) *Manager

NewManager is a manager for the workspace root.

func (*Manager) Close

func (m *Manager) Close()

Close shuts the servers down, and ends the starts under way, waiting for them.

func (*Manager) Definition

func (m *Manager) Definition(ctx context.Context, path string, line, col int) ([]Location, error)

Definition is where the symbol at (line, col) of path is defined.

func (*Manager) Diagnostics

func (m *Manager) Diagnostics(ctx context.Context, path string, wait time.Duration) ([]Diagnostic, error)

Diagnostics are the problems the server reports for path as it is on disk, waiting up to wait for them.

func (*Manager) For

func (m *Manager) For(ctx context.Context, path string) (*server, error)

For finds the server for path, starting it if need be. A start runs on its own (startTimeout, or until Close), not on ctx: callers wait for it, each giving up with its own ctx, and other languages go on meanwhile.

func (*Manager) Hover

func (m *Manager) Hover(ctx context.Context, path string, line, col int) (string, error)

Hover is what the server says about the symbol at (line, col).

func (*Manager) References

func (m *Manager) References(ctx context.Context, path string, line, col int) ([]Location, error)

References are where the symbol at (line, col) of path is used.

func (*Manager) Running

func (m *Manager) Running(path string) bool

Running reports whether a server runs for files like path (edits then report diagnostics without starting one).

func (*Manager) Symbols

func (m *Manager) Symbols(ctx context.Context, path, query string) ([]Symbol, error)

Symbols are the workspace's symbols matching query, from the server for files like path.

type Process

type Process interface {
	Stdin() io.WriteCloser
	Stdout() io.ReadCloser
	Stop()
}

Process is a started language server: its stdin and stdout, and how to stop it.

type Server

type Server struct {
	Language   string
	Command    []string
	Extensions []string // with the dot: .go
}

Server is how to run a language's server, and which files it's for.

type Symbol

type Symbol struct {
	Name      string   `json:"name"`
	Kind      string   `json:"kind"`
	Container string   `json:"container,omitempty"`
	Location  Location `json:"location"`
}

Symbol is a workspace symbol.

Directories

Path Synopsis
Package lsptest is a fake language server for tests: the test binary runs it when started with BLITZ_FAKE_LSP=1 (call MaybeServe first in TestMain), and Launcher starts that.
Package lsptest is a fake language server for tests: the test binary runs it when started with BLITZ_FAKE_LSP=1 (call MaybeServe first in TestMain), and Launcher starts that.

Jump to

Keyboard shortcuts

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