Documentation
¶
Index ¶
- func DetectLanguageID(uri string) protocol.LanguageKind
- func HandleApplyEdit(_ context.Context, _ string, params json.RawMessage) (any, error)
- func HandleDiagnostics(client *Client, params json.RawMessage)
- func HandleRegisterCapability(_ context.Context, _ string, params json.RawMessage) (any, error)
- func HandleServerMessage(_ context.Context, method string, params json.RawMessage)
- func HandleWorkspaceConfiguration(_ context.Context, _ string, params json.RawMessage) (any, error)
- func HasRootMarkers(dir string, rootMarkers []string) bool
- func RegisterFileWatchHandler(handler FileWatchRegistrationHandler)
- type Client
- func (c *Client) ClearDiagnosticsForURI(uri protocol.DocumentURI)
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) CloseAllFiles(ctx context.Context)
- func (c *Client) DidChangeWatchedFiles(ctx context.Context, params protocol.DidChangeWatchedFilesParams) error
- func (c *Client) FindReferences(ctx context.Context, filepath string, line, character int, ...) ([]protocol.Location, error)
- func (c *Client) GetDiagnostics() map[protocol.DocumentURI][]protocol.Diagnostic
- func (c *Client) GetDiagnosticsForFile(ctx context.Context, filepath string) ([]protocol.Diagnostic, error)
- func (c *Client) GetFileDiagnostics(uri protocol.DocumentURI) []protocol.Diagnostic
- func (c *Client) GetName() string
- func (c *Client) GetServerState() ServerState
- func (c *Client) HandlesFile(path string) bool
- func (c *Client) Initialize(ctx context.Context, workspaceDir string) (*protocol.InitializeResult, error)
- func (c *Client) IsFileOpen(filepath string) bool
- func (c *Client) NotifyChange(ctx context.Context, filepath string) error
- func (c *Client) OpenFile(ctx context.Context, filepath string) error
- func (c *Client) OpenFileOnDemand(ctx context.Context, filepath string) error
- func (c *Client) RegisterNotificationHandler(method string, handler transport.NotificationHandler)
- func (c *Client) RegisterServerRequestHandler(method string, handler transport.Handler)
- func (c *Client) SetDiagnosticsCallback(callback func(name string, count int))
- func (c *Client) SetServerState(state ServerState)
- func (c *Client) WaitForDiagnostics(ctx context.Context, d time.Duration)
- func (c *Client) WaitForServerReady(ctx context.Context) error
- type FileWatchRegistrationHandler
- type OpenFileInfo
- type ServerState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectLanguageID ¶
func DetectLanguageID(uri string) protocol.LanguageKind
func HandleApplyEdit ¶
HandleApplyEdit handles workspace edit requests
func HandleDiagnostics ¶
func HandleDiagnostics(client *Client, params json.RawMessage)
HandleDiagnostics handles diagnostic notifications from the LSP server
func HandleRegisterCapability ¶
HandleRegisterCapability handles capability registration requests
func HandleServerMessage ¶
func HandleServerMessage(_ context.Context, method string, params json.RawMessage)
HandleServerMessage handles server messages
func HandleWorkspaceConfiguration ¶
HandleWorkspaceConfiguration handles workspace configuration requests
func HasRootMarkers ¶
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) CloseAllFiles ¶
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) GetServerState ¶
func (c *Client) GetServerState() ServerState
GetServerState returns the current state of the LSP server
func (*Client) HandlesFile ¶
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 ¶
IsFileOpen checks if a file is currently open.
func (*Client) NotifyChange ¶
NotifyChange notifies the server about a file change.
func (*Client) OpenFileOnDemand ¶
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 ¶
RegisterServerRequestHandler handles server requests.
func (*Client) SetDiagnosticsCallback ¶
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 ¶
WaitForDiagnostics waits until diagnostics change or the timeout is reached.
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 )