client

package
v1.209.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountBySeverity

func CountBySeverity(diagnostics []lsp.Diagnostic) map[lsp.DiagnosticSeverity]int

CountByeSeverity counts diagnostics by severity.

func HasErrors

func HasErrors(diagnostics []lsp.Diagnostic) bool

HasErrors returns true if there are any error-level diagnostics.

func HasWarnings

func HasWarnings(diagnostics []lsp.Diagnostic) bool

HasWarnings returns true if there are any warning-level diagnostics.

Types

type Client

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

Client represents an LSP client that communicates with an LSP server.

func NewClient

func NewClient(ctx context.Context, name string, config *schema.LSPServer, rootURI string) (*Client, error)

NewClient creates a new LSP client for the specified server configuration.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the LSP client and server.

func (*Client) CloseDocument

func (c *Client) CloseDocument(uri string) error

CloseDocument notifies the server that a document was closed.

func (*Client) GetAllDiagnostics

func (c *Client) GetAllDiagnostics() map[string][]lsp.Diagnostic

GetAllDiagnostics returns all diagnostics from all documents.

func (*Client) GetDiagnostics

func (c *Client) GetDiagnostics(uri string) []lsp.Diagnostic

GetDiagnostics returns diagnostics for the specified URI.

func (*Client) Initialize

func (c *Client) Initialize() error

Initialize sends the initialize request to the LSP server.

func (*Client) OpenDocument

func (c *Client) OpenDocument(uri, languageID, text string) error

OpenDocument notifies the server that a document was opened.

type DiagnosticFormatter

type DiagnosticFormatter struct {
	ShowRelated bool // Show related information.
	ShowSource  bool // Show diagnostic source.
}

DiagnosticFormatter formats LSP diagnostics for display.

func NewDiagnosticFormatter

func NewDiagnosticFormatter() *DiagnosticFormatter

NewDiagnosticFormatter creates a new diagnostic formatter.

func (*DiagnosticFormatter) FormatAllDiagnostics

func (f *DiagnosticFormatter) FormatAllDiagnostics(diagnosticsByURI map[string][]lsp.Diagnostic) string

FormatAllDiagnostics formats diagnostics from multiple files.

func (*DiagnosticFormatter) FormatCompact

func (f *DiagnosticFormatter) FormatCompact(uri string, diagnostics []lsp.Diagnostic) string

FormatCompact formats diagnostics in a compact, one-line-per-issue format.

func (*DiagnosticFormatter) FormatDiagnostics

func (f *DiagnosticFormatter) FormatDiagnostics(uri string, diagnostics []lsp.Diagnostic) string

FormatDiagnostics formats a list of diagnostics into a human-readable string.

func (*DiagnosticFormatter) FormatForAI

func (f *DiagnosticFormatter) FormatForAI(uri string, diagnostics []lsp.Diagnostic) string

FormatForAI formats diagnostics in a format optimized for AI consumption.

func (*DiagnosticFormatter) GetDiagnosticSummary

func (f *DiagnosticFormatter) GetDiagnosticSummary(diagnosticsByURI map[string][]lsp.Diagnostic) DiagnosticSummary

GetDiagnosticSummary returns a summary of diagnostics.

type DiagnosticSummary

type DiagnosticSummary struct {
	FilesWithIssues int                              `json:"files_with_issues"`
	TotalErrors     int                              `json:"total_errors"`
	TotalWarnings   int                              `json:"total_warnings"`
	TotalInfos      int                              `json:"total_infos"`
	TotalHints      int                              `json:"total_hints"`
	Files           map[string]FileDiagnosticSummary `json:"files"`
}

DiagnosticSummary contains summary information about diagnostics.

type FileDiagnosticSummary

type FileDiagnosticSummary struct {
	Errors   int `json:"errors"`
	Warnings int `json:"warnings"`
	Infos    int `json:"infos"`
	Hints    int `json:"hints"`
}

FileDiagnosticSummary contains summary for a single file.

type Manager

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

Manager manages multiple LSP server clients.

func NewManager

func NewManager(ctx context.Context, config *schema.LSPSettings, rootPath string) (*Manager, error)

NewManager creates a new LSP manager.

func (*Manager) AnalyzeFile

func (m *Manager) AnalyzeFile(filePath, content string) ([]lsp.Diagnostic, error)

AnalyzeFile opens a file in the appropriate LSP server and returns diagnostics. It waits up to 500ms for diagnostics to be published by the LSP server to handle asynchronous diagnostic publication.

func (*Manager) Close

func (m *Manager) Close() error

Close shuts down all LSP clients.

func (*Manager) GetAllDiagnostics

func (m *Manager) GetAllDiagnostics() map[string]map[string][]lsp.Diagnostic

GetAllDiagnostics returns all diagnostics from all LSP servers.

func (*Manager) GetClient

func (m *Manager) GetClient(name string) (*Client, bool)

GetClient returns the LSP client for the specified server name.

func (*Manager) GetClientForFile

func (m *Manager) GetClientForFile(filePath string) (*Client, bool)

GetClientForFile returns the LSP client that handles the given file.

func (*Manager) GetDiagnosticsForFile

func (m *Manager) GetDiagnosticsForFile(filePath string) []lsp.Diagnostic

GetDiagnosticsForFile returns diagnostics for a specific file from all servers.

func (*Manager) GetServerNames

func (m *Manager) GetServerNames() []string

GetServerNames returns list of configured server names.

func (*Manager) IsEnabled

func (m *Manager) IsEnabled() bool

IsEnabled returns whether LSP is enabled.

type ManagerInterface

type ManagerInterface interface {
	GetClient(name string) (*Client, bool)
	GetClientForFile(filePath string) (*Client, bool)
	AnalyzeFile(filePath, content string) ([]lsp.Diagnostic, error)
	GetAllDiagnostics() map[string]map[string][]lsp.Diagnostic
	GetDiagnosticsForFile(filePath string) []lsp.Diagnostic
	Close() error
	IsEnabled() bool
	GetServerNames() []string
}

ManagerInterface defines the interface for LSP manager operations.

Jump to

Keyboard shortcuts

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