lsp

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectLanguageID

func DetectLanguageID(uri string) protocol.LanguageKind

func HandleApplyEdit

func HandleApplyEdit(_ context.Context, _ string, params json.RawMessage) (any, error)

HandleApplyEdit handles workspace edit requests

func HandleDiagnostics

func HandleDiagnostics(client *Client, params json.RawMessage)

HandleDiagnostics handles diagnostic notifications from the LSP server

func HandleRegisterCapability

func HandleRegisterCapability(_ context.Context, _ string, params json.RawMessage) (any, error)

HandleRegisterCapability handles capability registration requests

func HandleServerMessage

func HandleServerMessage(_ context.Context, method string, params json.RawMessage)

HandleServerMessage handles server messages

func HandleWorkspaceConfiguration

func HandleWorkspaceConfiguration(_ context.Context, _ string, params json.RawMessage) (any, error)

HandleWorkspaceConfiguration handles workspace configuration requests

func HasRootMarkers

func HasRootMarkers(dir string, rootMarkers []string) bool

HasRootMarkers checks if any of the specified root marker patterns exist in the given directory. Uses glob patterns to match files, allowing for more flexible matching.

func RegisterFileWatchHandler

func RegisterFileWatchHandler(handler FileWatchRegistrationHandler)

RegisterFileWatchHandler sets the handler for file watch registrations

Types

type Client

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

func New

func New(ctx context.Context, name string, config config.LSPConfig, resolver config.VariableResolver) (*Client, error)

New creates a new LSP client using the powernap implementation.

func (*Client) ClearDiagnosticsForURI

func (c *Client) ClearDiagnosticsForURI(uri protocol.DocumentURI)

ClearDiagnosticsForURI removes diagnostics for a specific URI from the cache.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close closes the LSP client.

func (*Client) CloseAllFiles

func (c *Client) CloseAllFiles(ctx context.Context)

CloseAllFiles closes all currently open files.

func (*Client) DidChangeWatchedFiles

func (c *Client) DidChangeWatchedFiles(ctx context.Context, params protocol.DidChangeWatchedFilesParams) error

DidChangeWatchedFiles sends a workspace/didChangeWatchedFiles notification to the server.

func (*Client) FindReferences

func (c *Client) FindReferences(ctx context.Context, filepath string, line, character int, includeDeclaration bool) ([]protocol.Location, error)

FindReferences finds all references to the symbol at the given position.

func (*Client) GetDiagnostics

func (c *Client) GetDiagnostics() map[protocol.DocumentURI][]protocol.Diagnostic

GetDiagnostics returns all diagnostics for all files.

func (*Client) GetDiagnosticsForFile

func (c *Client) GetDiagnosticsForFile(ctx context.Context, filepath string) ([]protocol.Diagnostic, error)

GetDiagnosticsForFile ensures a file is open and returns its diagnostics.

func (*Client) GetFileDiagnostics

func (c *Client) GetFileDiagnostics(uri protocol.DocumentURI) []protocol.Diagnostic

GetFileDiagnostics returns diagnostics for a specific file.

func (*Client) GetName

func (c *Client) GetName() string

GetName returns the name of the LSP client

func (*Client) GetServerState

func (c *Client) GetServerState() ServerState

GetServerState returns the current state of the LSP server

func (*Client) HandlesFile

func (c *Client) HandlesFile(path string) bool

HandlesFile checks if this LSP client handles the given file based on its extension.

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context, workspaceDir string) (*protocol.InitializeResult, error)

Initialize initializes the LSP client and returns the server capabilities.

func (*Client) IsFileOpen

func (c *Client) IsFileOpen(filepath string) bool

IsFileOpen checks if a file is currently open.

func (*Client) NotifyChange

func (c *Client) NotifyChange(ctx context.Context, filepath string) error

NotifyChange notifies the server about a file change.

func (*Client) OpenFile

func (c *Client) OpenFile(ctx context.Context, filepath string) error

OpenFile opens a file in the LSP server.

func (*Client) OpenFileOnDemand

func (c *Client) OpenFileOnDemand(ctx context.Context, filepath string) error

OpenFileOnDemand opens a file only if it's not already open.

func (*Client) RegisterNotificationHandler

func (c *Client) RegisterNotificationHandler(method string, handler transport.NotificationHandler)

RegisterNotificationHandler registers a notification handler.

func (*Client) RegisterServerRequestHandler

func (c *Client) RegisterServerRequestHandler(method string, handler transport.Handler)

RegisterServerRequestHandler handles server requests.

func (*Client) SetDiagnosticsCallback

func (c *Client) SetDiagnosticsCallback(callback func(name string, count int))

SetDiagnosticsCallback sets the callback function for diagnostic changes

func (*Client) SetServerState

func (c *Client) SetServerState(state ServerState)

SetServerState sets the current state of the LSP server

func (*Client) WaitForDiagnostics

func (c *Client) WaitForDiagnostics(ctx context.Context, d time.Duration)

WaitForDiagnostics waits until diagnostics change or the timeout is reached.

func (*Client) WaitForServerReady

func (c *Client) WaitForServerReady(ctx context.Context) error

WaitForServerReady waits for the server to be ready

type FileWatchRegistrationHandler

type FileWatchRegistrationHandler func(id string, watchers []protocol.FileSystemWatcher)

FileWatchRegistrationHandler is a function that will be called when file watch registrations are received

type OpenFileInfo

type OpenFileInfo struct {
	Version int32
	URI     protocol.DocumentURI
}

OpenFileInfo contains information about an open file

type ServerState

type ServerState int

ServerState represents the state of an LSP server

const (
	StateStarting ServerState = iota
	StateReady
	StateError
	StateDisabled
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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