lsp

package
v0.12.21 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiagnosticSeverityError       = 1
	DiagnosticSeverityWarning     = 2
	DiagnosticSeverityInformation = 3
	DiagnosticSeverityHint        = 4
)

Variables

This section is empty.

Functions

func DiagnosticSeverityName

func DiagnosticSeverityName(severity int) string

func FileURI

func FileURI(path string) string

func FormatDiagnostics

func FormatDiagnostics(diagnostics []Diagnostic, filePath string, workingDir string) string

Types

type CallHierarchyClientCapabilities

type CallHierarchyClientCapabilities struct{}

type CallHierarchyIncomingCall

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

type CallHierarchyIncomingCallsParams

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

type CallHierarchyItem

type CallHierarchyItem struct {
	Name           string          `json:"name"`
	Kind           int             `json:"kind"`
	Detail         string          `json:"detail,omitempty"`
	URI            string          `json:"uri"`
	Range          Range           `json:"range"`
	SelectionRange Range           `json:"selectionRange"`
	Data           json.RawMessage `json:"data,omitempty"`
}

type CallHierarchyOutgoingCall

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

type CallHierarchyOutgoingCallsParams

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

type ClientCapabilities

type ClientCapabilities struct {
	TextDocument TextDocumentClientCapabilities `json:"textDocument"`
	Window       WindowClientCapabilities       `json:"window"`
}

type DefLocation added in v0.9.2

type DefLocation struct {
	Path   string
	Line   int
	Column int
}

type DefinitionClientCapabilities

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

type Diagnostic

type Diagnostic struct {
	Range    Range  `json:"range"`
	Severity int    `json:"severity,omitempty"`
	Code     any    `json:"code,omitempty"`
	Source   string `json:"source,omitempty"`
	Message  string `json:"message"`
}

type DiagnosticClientCapabilities

type DiagnosticClientCapabilities struct{}

type DidChangeTextDocumentParams

type DidChangeTextDocumentParams struct {
	TextDocument   VersionedTextDocumentIdentifier  `json:"textDocument"`
	ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
}

type DidOpenTextDocumentParams

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

type DidSaveTextDocumentParams

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

type DocumentDiagnosticParams

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

type DocumentSymbol

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

type DocumentSymbolClientCapabilities

type DocumentSymbolClientCapabilities struct{}

type DocumentSymbolParams

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

type FullDocumentDiagnosticReport

type FullDocumentDiagnosticReport struct {
	Kind  string       `json:"kind"`
	Items []Diagnostic `json:"items"`
}

type HoverClientCapabilities

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

type HoverContents

type HoverContents struct {
	Value string
}

func (*HoverContents) UnmarshalJSON

func (h *HoverContents) UnmarshalJSON(data []byte) error

type HoverResponse

type HoverResponse struct {
	Contents HoverContents `json:"contents"`
	Range    *Range        `json:"range,omitempty"`
}

type ImplementationClientCapabilities

type ImplementationClientCapabilities struct{}

type InitializeParams

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

type InitializeResult added in v0.12.12

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

type Location

type Location struct {
	URI   string `json:"uri"`
	Range Range  `json:"range"`
}
type LocationLink struct {
	TargetURI            string `json:"targetUri"`
	TargetRange          Range  `json:"targetRange"`
	TargetSelectionRange Range  `json:"targetSelectionRange"`
}

type Manager

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

func NewManager

func NewManager(workingDir string) *Manager

func (*Manager) ActiveSession added in v0.12.7

func (m *Manager) ActiveSession(filePath string) (*Session, bool)

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) CollectAllDiagnostics

func (m *Manager) CollectAllDiagnostics(ctx context.Context) WorkspaceDiagnosticsReport

func (*Manager) DetectServers

func (m *Manager) DetectServers() []Server

func (*Manager) FindServer

func (m *Manager) FindServer(filePath string) *Server

func (*Manager) GetSession

func (m *Manager) GetSession(ctx context.Context, filePath string) (*Session, error)

func (*Manager) PostEditDiagnostics added in v0.12.7

func (m *Manager) PostEditDiagnostics(ctx context.Context, path string) string

PostEditDiagnostics reports current errors in an edited file, for attaching to edit/write tool results. It never cold-starts a server synchronously: if none is running yet it warms one up in the background and returns "".

func (*Manager) WarmUpServers added in v0.12.7

func (m *Manager) WarmUpServers()

func (*Manager) WorkingDir

func (m *Manager) WorkingDir() string

func (*Manager) WorkspaceDiagnostics

func (m *Manager) WorkspaceDiagnostics(ctx context.Context) (string, error)

func (*Manager) WorkspaceSymbols

func (m *Manager) WorkspaceSymbols(ctx context.Context, query string) (string, error)

type Position

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

func PositionFromDisplay added in v0.12.7

func PositionFromDisplay(path string, line, column int) (Position, error)

func PositionOfSymbol added in v0.12.7

func PositionOfSymbol(path string, symbol string) (Position, bool)

func PositionOfSymbolOnLine added in v0.12.7

func PositionOfSymbolOnLine(path string, line int, symbol string) (Position, error)

type ProgressParams added in v0.12.12

type ProgressParams struct {
	Token json.RawMessage `json:"token"`
	Value struct {
		Kind string `json:"kind"`
	} `json:"value"`
}

type PublishDiagnosticsParams

type PublishDiagnosticsParams struct {
	URI         string       `json:"uri"`
	Version     int          `json:"version,omitempty"`
	Diagnostics []Diagnostic `json:"diagnostics"`
}

type Range

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

type ReferenceContext

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

type ReferenceParams

type ReferenceParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	Position     Position               `json:"position"`
	Context      ReferenceContext       `json:"context"`
}

type ReferencesClientCapabilities

type ReferencesClientCapabilities struct{}

type Server

type Server struct {
	Name                string
	Command             string
	Args                []string
	Languages           []string
	LanguageID          string
	MinimumMajorVersion int
}

func (Server) LanguageIDForPath added in v0.12.12

func (s Server) LanguageIDForPath(path string) string

type ServerCapabilities added in v0.12.12

type ServerCapabilities struct {
	DiagnosticProvider json.RawMessage `json:"diagnosticProvider"`
}

type Session

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

func (*Session) Age added in v0.12.12

func (s *Session) Age() time.Duration

func (*Session) Analyzing added in v0.12.12

func (s *Session) Analyzing() bool

Analyzing reports whether the server has announced ongoing background work (indexing, loading packages) via work-done progress.

func (*Session) CallAndAwait

func (s *Session) CallAndAwait(ctx context.Context, method string, params any, result any) error

func (*Session) CallHierarchy

func (s *Session) CallHierarchy(ctx context.Context, uri string, line, column int, incoming bool) (string, error)

func (*Session) Close

func (s *Session) Close()

func (*Session) Definition

func (s *Session) Definition(ctx context.Context, uri string, line, column int) (string, error)

func (*Session) DefinitionLocations added in v0.9.2

func (s *Session) DefinitionLocations(ctx context.Context, uri string, line, column int) ([]DefLocation, error)

func (*Session) Diagnostics

func (s *Session) Diagnostics(ctx context.Context, uri string, filePath string) (string, error)

func (*Session) DiagnosticsState added in v0.12.7

func (s *Session) DiagnosticsState(ctx context.Context, uri string) ([]Diagnostic, bool)

DiagnosticsState reports the diagnostics for uri and whether the server has actually produced a result: known=false means the server neither published nor answered a pull request, so "no diagnostics" cannot be concluded.

func (*Session) DocumentSymbolItems added in v0.12.12

func (s *Session) DocumentSymbolItems(ctx context.Context, uri string) ([]DocumentSymbol, []SymbolInformation, error)

DocumentSymbolItems returns the file's symbols in whichever of the two documentSymbol response shapes the server chose: a DocumentSymbol tree or a flat SymbolInformation list.

func (*Session) DocumentSymbols

func (s *Session) DocumentSymbols(ctx context.Context, uri string, filePath string) (string, error)

func (*Session) Hover

func (s *Session) Hover(ctx context.Context, uri string, line, column int) (string, error)

func (*Session) HoverInformation added in v0.12.12

func (s *Session) HoverInformation(ctx context.Context, uri string, line, column int) (string, error)

func (*Session) Implementation

func (s *Session) Implementation(ctx context.Context, uri string, line, column int) (string, error)

func (*Session) ImplementationLocations added in v0.12.12

func (s *Session) ImplementationLocations(ctx context.Context, uri string, line, column int) ([]DefLocation, error)

func (*Session) IsAlive

func (s *Session) IsAlive() bool

func (*Session) OpenDocument

func (s *Session) OpenDocument(ctx context.Context, filePath string) (string, error)

func (*Session) OpenedDocURIs

func (s *Session) OpenedDocURIs() []string

func (*Session) PushSeen added in v0.12.7

func (s *Session) PushSeen(uri string) bool

func (*Session) ReferenceLocations added in v0.12.12

func (s *Session) ReferenceLocations(ctx context.Context, uri string, line, column int) ([]DefLocation, error)

func (*Session) References

func (s *Session) References(ctx context.Context, uri string, line, column int) (string, error)

func (*Session) SupportsPullDiagnostics added in v0.12.12

func (s *Session) SupportsPullDiagnostics() bool

func (*Session) SymbolPosition added in v0.12.7

func (s *Session) SymbolPosition(ctx context.Context, uri string, name string) (Position, bool)

SymbolPosition locates a named symbol in a file, preferring the language server's own symbol table and falling back to the first textual occurrence of the name's last segment.

func (*Session) SyncDocument added in v0.12.12

func (s *Session) SyncDocument(ctx context.Context, filePath, content string) (string, error)

SyncDocument updates the language server with an editor buffer without claiming that the buffer has been saved to disk.

func (*Session) TypeDefinitionLocations added in v0.12.12

func (s *Session) TypeDefinitionLocations(ctx context.Context, uri string, line, column int) ([]DefLocation, error)

func (*Session) WaitForDiagnostics

func (s *Session) WaitForDiagnostics(ctx context.Context, uri string, timeout time.Duration) ([]Diagnostic, bool)

type SymbolInformation

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

type TextDocumentClientCapabilities

type TextDocumentClientCapabilities struct {
	Synchronization TextDocumentSyncClientCapabilities `json:"synchronization"`
	Hover           HoverClientCapabilities            `json:"hover"`
	Definition      DefinitionClientCapabilities       `json:"definition"`
	TypeDefinition  TypeDefinitionClientCapabilities   `json:"typeDefinition"`
	References      ReferencesClientCapabilities       `json:"references"`
	Implementation  ImplementationClientCapabilities   `json:"implementation"`
	DocumentSymbol  DocumentSymbolClientCapabilities   `json:"documentSymbol"`
	Diagnostic      DiagnosticClientCapabilities       `json:"diagnostic"`
	CallHierarchy   CallHierarchyClientCapabilities    `json:"callHierarchy"`
}

type TextDocumentContentChangeEvent

type TextDocumentContentChangeEvent struct {
	Text string `json:"text"`
}

type TextDocumentIdentifier

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

type TextDocumentItem

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

type TextDocumentPositionParams

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

type TextDocumentSyncClientCapabilities

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

type TypeDefinitionClientCapabilities added in v0.12.12

type TypeDefinitionClientCapabilities struct{}

type VersionedTextDocumentIdentifier

type VersionedTextDocumentIdentifier struct {
	URI     string `json:"uri"`
	Version int    `json:"version"`
}

type WindowClientCapabilities added in v0.12.12

type WindowClientCapabilities struct {
	WorkDoneProgress bool `json:"workDoneProgress,omitempty"`
}

type WorkspaceDiagnosticsReport added in v0.12.12

type WorkspaceDiagnosticsReport struct {
	Diagnostics        map[string][]Diagnostic
	CheckedFiles       int
	DiscoveredFiles    int
	DiscoveryTruncated bool
	UnknownFiles       int
	UnavailableServers []string

	// Analyzing marks results collected while a server was still reporting
	// background work: counts may grow on the next scan.
	Analyzing bool
}

type WorkspaceSymbol

type WorkspaceSymbol struct {
	Name     string `json:"name"`
	Kind     int    `json:"kind"`
	Location struct {
		URI   string `json:"uri"`
		Range *Range `json:"range,omitempty"`
	} `json:"location"`
}

type WorkspaceSymbolParams

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

Jump to

Keyboard shortcuts

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