lsp

package
v0.0.0-...-cb3f5c8 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParseError     = -32700
	InvalidRequest = -32600
	MethodNotFound = -32601
	InvalidParams  = -32602
	InternalError  = -32603
)

JSON-RPC error codes

Variables

This section is empty.

Functions

func ApplyTextEdits

func ApplyTextEdits(content string, edits []*pb.TextEdit) (string, error)

ApplyTextEdits applies LSP text edits to the provided content and returns the updated text.

func BuildEditorContext

func BuildEditorContext(uri, language, content string, selection *pb.Range) *pb.EditorContext

BuildEditorContext constructs a minimal EditorContext for a single document.

func WriteMessage

func WriteMessage(writer io.Writer, msg *JSONRPCMessage) error

WriteMessage writes a JSON-RPC message to the writer

Types

type Bridge

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

Bridge implements LSP server that bridges to ACP coordinator

func NewBridge

func NewBridge(config *BridgeConfig) (*Bridge, error)

NewBridge creates a new LSP bridge instance

func (*Bridge) ApplyEdits

func (b *Bridge) ApplyEdits(ctx context.Context, req *pb.ApplyEditsRequest) (*pb.ApplyEditsResponse, error)

ApplyEdits forwards apply edits to ACP.

func (*Bridge) CancelStream

func (b *Bridge) CancelStream(streamID string) error

CancelStream cancels an active stream by ID

func (*Bridge) ConnectToCoordinator

func (b *Bridge) ConnectToCoordinator(ctx context.Context) error

ConnectToCoordinator establishes gRPC connection to the ACP coordinator

func (*Bridge) DisconnectFromCoordinator

func (b *Bridge) DisconnectFromCoordinator() error

DisconnectFromCoordinator closes the gRPC connection

func (*Bridge) Exit

func (b *Bridge) Exit(ctx context.Context) error

Exit handles LSP exit notification

func (*Bridge) HandleMessage

func (b *Bridge) HandleMessage(ctx context.Context, msg *JSONRPCMessage) *JSONRPCMessage

HandleMessage processes a JSON-RPC message and returns a response

func (*Bridge) HandleStreamQuery

func (b *Bridge) HandleStreamQuery(ctx context.Context, query string, callback StreamCallback) (string, error)

HandleStreamQuery processes a streaming query

func (*Bridge) HandleTextQuery

func (b *Bridge) HandleTextQuery(ctx context.Context, query string) (string, error)

HandleTextQuery processes a text query and returns a response

func (*Bridge) Initialize

func (b *Bridge) Initialize(ctx context.Context, params InitializeParams) (*InitializeResult, error)

Initialize handles LSP initialize request

func (*Bridge) Initialized

func (b *Bridge) Initialized(ctx context.Context) error

Initialized handles LSP initialized notification

func (*Bridge) ProposeEdits

func (b *Bridge) ProposeEdits(ctx context.Context, req *pb.ProposeEditsRequest) (*pb.ProposeEditsResponse, error)

ProposeEdits calls the ACP propose edits RPC.

func (*Bridge) ServeStdio

func (b *Bridge) ServeStdio(ctx context.Context, reader io.Reader, writer io.Writer) error

ServeStdio starts the LSP server on stdio

func (*Bridge) Shutdown

func (b *Bridge) Shutdown(ctx context.Context) error

Shutdown handles LSP shutdown request

func (*Bridge) StreamInlineCompletions

func (b *Bridge) StreamInlineCompletions(ctx context.Context, req *pb.InlineCompletionRequest, cb InlineCompletionCallback) (string, error)

StreamInlineCompletions streams inline completions to the callback.

func (*Bridge) UpdateEditorState

func (b *Bridge) UpdateEditorState(ctx context.Context, req *pb.UpdateEditorStateRequest) (*pb.UpdateEditorStateResponse, error)

UpdateEditorState retrieves editor state snapshot (plan/TODO/approvals).

type BridgeConfig

type BridgeConfig struct {
	// CoordinatorAddr is the endpoint for gRPC connection
	CoordinatorAddr string

	// AgentID for this bridge instance
	AgentID string

	// Capabilities to advertise
	Capabilities []string
}

BridgeConfig holds LSP bridge configuration

type CancelParams

type CancelParams struct {
	ID json.RawMessage `json:"id"`
}

CancelParams represents parameters for $/cancelRequest

type ClientCapabilities

type ClientCapabilities struct {
	TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"`
}

ClientCapabilities represents client capabilities

type ClientInfo

type ClientInfo struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

ClientInfo holds client information

type InitializeParams

type InitializeParams struct {
	ProcessID    *int               `json:"processId"`
	ClientInfo   *ClientInfo        `json:"clientInfo,omitempty"`
	RootURI      string             `json:"rootUri"`
	Capabilities ClientCapabilities `json:"capabilities"`
}

InitializeParams represents LSP initialize request params

type InitializeResult

type InitializeResult struct {
	Capabilities ServerCapabilities `json:"capabilities"`
	ServerInfo   *ServerInfo        `json:"serverInfo,omitempty"`
}

InitializeResult represents LSP initialize response

type InlineCompletionCallback

type InlineCompletionCallback func(text string, done bool) error

InlineCompletionCallback receives streamed inline completion text.

type JSONRPCError

type JSONRPCError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

JSONRPCError represents a JSON-RPC error

type JSONRPCMessage

type JSONRPCMessage struct {
	JSONRPC string           `json:"jsonrpc"`
	ID      *json.RawMessage `json:"id,omitempty"`
	Method  string           `json:"method,omitempty"`
	Params  json.RawMessage  `json:"params,omitempty"`
	Result  json.RawMessage  `json:"result,omitempty"`
	Error   *JSONRPCError    `json:"error,omitempty"`
}

JSONRPCMessage represents a JSON-RPC 2.0 message

func ReadMessage

func ReadMessage(reader *bufio.Reader) (*JSONRPCMessage, error)

ReadMessage reads a JSON-RPC message from the reader

type ServerCapabilities

type ServerCapabilities struct {
	TextDocumentSync *TextDocumentSyncOptions `json:"textDocumentSync,omitempty"`
}

ServerCapabilities represents server capabilities

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

ServerInfo holds server information

type StreamCallback

type StreamCallback func(chunk string, done bool) error

StreamCallback is called for each chunk in the stream

type StreamChunkNotification

type StreamChunkNotification struct {
	StreamID string `json:"streamId"`
	Chunk    string `json:"chunk"`
	Done     bool   `json:"done"`
}

StreamChunkNotification represents a streaming chunk notification

type StreamQueryParams

type StreamQueryParams struct {
	Query string `json:"query"`
}

StreamQueryParams represents parameters for buckley/streamQuery method

type StreamQueryResult

type StreamQueryResult struct {
	StreamID string `json:"streamId"`
	AgentID  string `json:"agentId"`
}

StreamQueryResult represents initial result for buckley/streamQuery method

type TextDocumentClientCapabilities

type TextDocumentClientCapabilities struct {
	Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"`
}

TextDocumentClientCapabilities represents text document capabilities

type TextDocumentSyncClientCapabilities

type TextDocumentSyncClientCapabilities struct {
	DynamicRegistration bool `json:"dynamicRegistration,omitempty"`
}

TextDocumentSyncClientCapabilities represents sync capabilities

type TextDocumentSyncKind

type TextDocumentSyncKind int

TextDocumentSyncKind defines text document sync modes

const (
	TextDocumentSyncKindNone        TextDocumentSyncKind = 0
	TextDocumentSyncKindFull        TextDocumentSyncKind = 1
	TextDocumentSyncKindIncremental TextDocumentSyncKind = 2
)

type TextDocumentSyncOptions

type TextDocumentSyncOptions struct {
	OpenClose bool                 `json:"openClose,omitempty"`
	Change    TextDocumentSyncKind `json:"change,omitempty"`
}

TextDocumentSyncOptions represents text document sync options

type TextQueryParams

type TextQueryParams struct {
	Query string `json:"query"`
}

TextQueryParams represents parameters for buckley/textQuery method

type TextQueryResult

type TextQueryResult struct {
	Response string `json:"response"`
	AgentID  string `json:"agentId"`
}

TextQueryResult represents result for buckley/textQuery method

Jump to

Keyboard shortcuts

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