Skip to main content

LspProvider

Trait LspProvider 

Source
pub trait LspProvider:
    Send
    + Sync
    + Debug {
    // Required methods
    fn ensure_started_background<'a>(
        &'a self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
    fn ensure_ready<'a>(
        &'a self,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>>;
    fn drain_diagnostics<'a>(
        &'a self,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Option<DiagnosticsSummary>> + Send + 'a>>;
    fn read_diagnostics<'a>(
        &'a self,
        paths: &'a [PathBuf],
    ) -> Pin<Box<dyn Future<Output = Vec<FileDiagnosticEntry>> + Send + 'a>>;
    fn execute_action<'a>(
        &'a self,
        action: &'a LspAction,
    ) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'a>>;

    // Provided method
    fn notify_file_changed<'a>(
        &'a self,
        _path: &'a Path,
        _content: &'a str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> { ... }
}
Expand description

LSP access capability. Implemented by an oxicode-lsp crate (feature-gated) or stubbed with None when LSP is disabled.

Required Methods§

Source

fn ensure_started_background<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>

Kick off background initialisation (servers start but ensure_ready isn’t awaited). Idempotent.

Source

fn ensure_ready<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'a>>

Block until at least the configured LSP servers have finished their initialize handshake (or the operation times out per the provider’s internal budget).

Source

fn drain_diagnostics<'a>( &'a self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Option<DiagnosticsSummary>> + Send + 'a>>

Drain the most recent batch of diagnostics that arrived via textDocument/publishDiagnostics. Returns None when nothing fresh has arrived within timeout.

Source

fn read_diagnostics<'a>( &'a self, paths: &'a [PathBuf], ) -> Pin<Box<dyn Future<Output = Vec<FileDiagnosticEntry>> + Send + 'a>>

Read the most recent cached diagnostics for the given file paths (zero-copy snapshot — no waiting). Paths that have no fresh diagnostics are omitted from the returned vec.

Source

fn execute_action<'a>( &'a self, action: &'a LspAction, ) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'a>>

Execute an LSP action and return formatted text output.

Provided Methods§

Source

fn notify_file_changed<'a>( &'a self, _path: &'a Path, _content: &'a str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>

Notify the LSP manager that the contents of path changed. The manager is responsible for forwarding a workspace/didChange to every server that owns the file. Default implementation is a no-op so lightweight providers (e.g. test stubs) don’t have to wire it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§