protocol

package
v0.2.9-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package protocol holds hand-written LSP protocol types covering the subset of the LSP 3.17 spec needed by evva's Phase 1 operations (definition, references, hover, document symbols) plus the lifecycle handshake.

Index

Constants

View Source
const (
	MethodInitialize           = "initialize"
	MethodInitialized          = "initialized"
	MethodShutdown             = "shutdown"
	MethodExit                 = "exit"
	MethodDefinition           = "textDocument/definition"
	MethodReferences           = "textDocument/references"
	MethodHover                = "textDocument/hover"
	MethodDocumentSymbol       = "textDocument/documentSymbol"
	MethodDidOpen              = "textDocument/didOpen"
	MethodDidChange            = "textDocument/didChange"
	MethodDidClose             = "textDocument/didClose"
	MethodPublishDiagnostics   = "textDocument/publishDiagnostics"
	MethodCancelRequest        = "$/cancelRequest"
	MethodImplementation       = "textDocument/implementation"
	MethodPrepareCallHierarchy = "textDocument/prepareCallHierarchy"
	MethodIncomingCalls        = "callHierarchy/incomingCalls"
	MethodOutgoingCalls        = "callHierarchy/outgoingCalls"
	MethodWorkspaceSymbol      = "workspace/symbol"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CallHierarchyIncomingCall

type CallHierarchyIncomingCall struct {
	From       CallHierarchyItem `json:"from"`
	FromRanges []Range           `json:"fromRanges"`
}

CallHierarchyIncomingCall represents an incoming call to a function.

type CallHierarchyIncomingCallsParams

type CallHierarchyIncomingCallsParams struct {
	Item CallHierarchyItem `json:"item"`
}

CallHierarchyIncomingCallsParams for callHierarchy/incomingCalls.

type CallHierarchyItem

type CallHierarchyItem struct {
	Name           string     `json:"name"`
	Kind           SymbolKind `json:"kind"`
	URI            string     `json:"uri"`
	Range          Range      `json:"range"`
	SelectionRange Range      `json:"selectionRange"`
}

CallHierarchyItem represents a node in the call graph.

type CallHierarchyOutgoingCall

type CallHierarchyOutgoingCall struct {
	To         CallHierarchyItem `json:"to"`
	FromRanges []Range           `json:"fromRanges"`
}

CallHierarchyOutgoingCall represents an outgoing call from a function.

type CallHierarchyOutgoingCallsParams

type CallHierarchyOutgoingCallsParams struct {
	Item CallHierarchyItem `json:"item"`
}

CallHierarchyOutgoingCallsParams for callHierarchy/outgoingCalls.

type CancelParams

type CancelParams struct {
	ID int64 `json:"id"`
}

CancelParams for $/cancelRequest.

type ClientCapabilities

type ClientCapabilities struct {
	Workspace    *WorkspaceClientCapabilities    `json:"workspace,omitempty"`
	TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"`
	General      *GeneralClientCapabilities      `json:"general,omitempty"`
}

ClientCapabilities declares what the client supports.

func DefaultClientCapabilities

func DefaultClientCapabilities() ClientCapabilities

DefaultClientCapabilities builds the capabilities evva declares for every LSP server. Positions are always UTF-16 because that's what most servers expect; the formatter converts Go offsets to UTF-16 code units.

type DefinitionCapabilities

type DefinitionCapabilities struct {
	LinkSupport bool `json:"linkSupport,omitempty"`
}

type Diagnostic

type Diagnostic struct {
	Range              Range                          `json:"range"`
	Severity           DiagnosticSeverity             `json:"severity,omitempty"`
	Code               string                         `json:"code,omitempty"`
	Source             string                         `json:"source,omitempty"`
	Message            string                         `json:"message"`
	RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
}

Diagnostic represents a compiler/linter error or warning.

type DiagnosticRelatedInformation

type DiagnosticRelatedInformation struct {
	Location Location `json:"location"`
	Message  string   `json:"message"`
}

DiagnosticRelatedInformation is a related location and message.

type DiagnosticSeverity

type DiagnosticSeverity uint32

DiagnosticSeverity is the severity of a diagnostic.

const (
	SeverityError       DiagnosticSeverity = 1
	SeverityWarning     DiagnosticSeverity = 2
	SeverityInformation DiagnosticSeverity = 3
	SeverityHint        DiagnosticSeverity = 4
)

func (DiagnosticSeverity) String

func (s DiagnosticSeverity) String() string

type DidCloseTextDocumentParams

type DidCloseTextDocumentParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
}

DidCloseTextDocumentParams for textDocument/didClose.

type DidOpenTextDocumentParams

type DidOpenTextDocumentParams struct {
	TextDocument TextDocumentItem `json:"textDocument"`
}

DidOpenTextDocumentParams for textDocument/didOpen.

type DocumentSymbol

type DocumentSymbol struct {
	Name           string            `json:"name"`
	Detail         string            `json:"detail,omitempty"`
	Kind           SymbolKind        `json:"kind"`
	Range          Range             `json:"range"`
	SelectionRange Range             `json:"selectionRange"`
	Children       []*DocumentSymbol `json:"children,omitempty"`
}

DocumentSymbol is a hierarchical symbol in a document.

type DocumentSymbolCapabilities

type DocumentSymbolCapabilities struct {
	HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport,omitempty"`
}

type DocumentSymbolParams

type DocumentSymbolParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
}

DocumentSymbolParams for textDocument/documentSymbol.

type GeneralClientCapabilities

type GeneralClientCapabilities struct {
	PositionEncodings []string `json:"positionEncodings,omitempty"`
}

type Hover

type Hover struct {
	Contents MarkupContent `json:"contents"`
	Range    *Range        `json:"range,omitempty"`
}

Hover holds the result of a hover request.

type HoverCapabilities

type HoverCapabilities struct {
	ContentFormat []string `json:"contentFormat,omitempty"`
}

type InitializeParams

type InitializeParams struct {
	ProcessID    int32              `json:"processId"`
	RootURI      string             `json:"rootUri"`
	Capabilities ClientCapabilities `json:"capabilities"`
}

InitializeParams is sent during the initialize handshake.

type InitializeResult

type InitializeResult struct {
	Capabilities ServerCapabilities `json:"capabilities"`
}

InitializeResult is the server's response to initialize.

type Location

type Location struct {
	URI   string `json:"uri"`
	Range Range  `json:"range"`
}

Location is a source location — a URI plus a range.

type MarkupContent

type MarkupContent struct {
	Kind  string `json:"kind"` // "markdown" or "plaintext"
	Value string `json:"value"`
}

MarkupContent is marked-up text (markdown or plaintext).

type Position

type Position struct {
	Line      uint32 `json:"line"`
	Character uint32 `json:"character"`
}

Position is a zero-based line and character offset in UTF-16 code units.

type PublishDiagnosticsCapabilities

type PublishDiagnosticsCapabilities struct {
	RelatedInformation bool `json:"relatedInformation,omitempty"`
}

type PublishDiagnosticsParams

type PublishDiagnosticsParams struct {
	URI         string       `json:"uri"`
	Diagnostics []Diagnostic `json:"diagnostics"`
}

PublishDiagnosticsParams is the payload for textDocument/publishDiagnostics.

type Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

Range is a span in a text document.

type ReferenceContext

type ReferenceContext struct {
	IncludeDeclaration bool `json:"includeDeclaration"`
}

ReferenceContext controls reference search behaviour.

type ReferenceParams

type ReferenceParams struct {
	TextDocumentPositionParams
	Context ReferenceContext `json:"context"`
}

ReferenceParams extends TextDocumentPositionParams with context.

type ReferencesCapabilities

type ReferencesCapabilities struct{}

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *ResponseError  `json:"error,omitempty"`
}

Response is the envelope every JSON-RPC response carries.

type ResponseError

type ResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

ResponseError is the JSON-RPC error payload.

type ServerCapabilities

type ServerCapabilities struct {
	TextDocumentSync       *TextDocumentSyncOptions `json:"textDocumentSync,omitempty"`
	DefinitionProvider     bool                     `json:"definitionProvider,omitempty"`
	ReferencesProvider     bool                     `json:"referencesProvider,omitempty"`
	HoverProvider          bool                     `json:"hoverProvider,omitempty"`
	DocumentSymbolProvider bool                     `json:"documentSymbolProvider,omitempty"`
}

ServerCapabilities is what the LSP server advertises in its initialize response. Only the fields relevant to Phase 1 operations are declared; unknown fields in the JSON are silently ignored by the decoder.

type SymbolInformation

type SymbolInformation struct {
	Name     string     `json:"name"`
	Kind     SymbolKind `json:"kind"`
	Location Location   `json:"location"`
}

SymbolInformation is the older flat symbol representation — some servers (or older versions) may return this shape instead of DocumentSymbol. textDocument/documentSymbol results are typed json.RawMessage and the formatter inspects the JSON to pick the right decoder.

type SymbolKind

type SymbolKind uint32

SymbolKind is an LSP symbol kind integer.

const (
	SKFile          SymbolKind = 1
	SKModule        SymbolKind = 2
	SKNamespace     SymbolKind = 3
	SKPackage       SymbolKind = 4
	SKClass         SymbolKind = 5
	SKMethod        SymbolKind = 6
	SKProperty      SymbolKind = 7
	SKField         SymbolKind = 8
	SKConstructor   SymbolKind = 9
	SKEnum          SymbolKind = 10
	SKInterface     SymbolKind = 11
	SKFunction      SymbolKind = 12
	SKVariable      SymbolKind = 13
	SKConstant      SymbolKind = 14
	SKString        SymbolKind = 15
	SKNumber        SymbolKind = 16
	SKBoolean       SymbolKind = 17
	SKArray         SymbolKind = 18
	SKObject        SymbolKind = 19
	SKKey           SymbolKind = 20
	SKNull          SymbolKind = 21
	SKEnumMember    SymbolKind = 22
	SKStruct        SymbolKind = 23
	SKEvent         SymbolKind = 24
	SKOperator      SymbolKind = 25
	SKTypeParameter SymbolKind = 26
)

func (SymbolKind) String

func (k SymbolKind) String() string

String returns the human-readable name for a SymbolKind, or "Unknown" for unrecognised values.

type SynchronizationCapabilities

type SynchronizationCapabilities struct {
	DidSave bool `json:"didSave,omitempty"`
}

type TextDocumentClientCapabilities

type TextDocumentClientCapabilities struct {
	Synchronization    *SynchronizationCapabilities    `json:"synchronization,omitempty"`
	PublishDiagnostics *PublishDiagnosticsCapabilities `json:"publishDiagnostics,omitempty"`
	Hover              *HoverCapabilities              `json:"hover,omitempty"`
	Definition         *DefinitionCapabilities         `json:"definition,omitempty"`
	References         *ReferencesCapabilities         `json:"references,omitempty"`
	DocumentSymbol     *DocumentSymbolCapabilities     `json:"documentSymbol,omitempty"`
}

TextDocumentClientCapabilities scopes document-related features.

type TextDocumentIdentifier

type TextDocumentIdentifier struct {
	URI string `json:"uri"`
}

TextDocumentIdentifier identifies a text document by URI.

type TextDocumentItem

type TextDocumentItem struct {
	URI        string `json:"uri"`
	LanguageID string `json:"languageId"`
	Version    int32  `json:"version"`
	Text       string `json:"text"`
}

TextDocumentItem represents a document that is open in the editor.

type TextDocumentPositionParams

type TextDocumentPositionParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	Position     Position               `json:"position"`
}

TextDocumentPositionParams combines a document identifier with a position.

type TextDocumentSyncOptions

type TextDocumentSyncOptions struct {
	OpenClose bool `json:"openClose,omitempty"`
	Change    int  `json:"change,omitempty"` // 0=none, 1=full, 2=incremental
}

TextDocumentSyncOptions describes how the server wants documents synced.

type WorkspaceClientCapabilities

type WorkspaceClientCapabilities struct{}

WorkspaceClientCapabilities is empty for Phase 1 — no workspace/configuration support is claimed, so servers won't send workspace/configuration requests.

type WorkspaceSymbolParams

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

WorkspaceSymbolParams for workspace/symbol.

Jump to

Keyboard shortcuts

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