pub struct LspSupervisorHandle { /* private fields */ }Expand description
Editor-facing handle to the LSP subsystem. Cheap to clone
(every field is Arc-shaped internally); the App holds one
instance and shares it with helpers that need to read or
mutate supervisor state.
Reads are wait-free. Self::servers_for,
Self::running_actors, Self::configs, and the count
helpers all go through ArcSwap::load. The UI thread can
call them on the keystroke / render path without ever
blocking.
Writes are mailbox-routed. Self::open_buffer,
Self::attach_handle, Self::shutdown, and
Self::flush_all are async (await processing); the
fire-and-forget variants (Self::close_buffer,
Self::flush, Self::record_edit) send the cmd and
return immediately, with the effect observable on the next
snapshot publish.
Implementations§
Source§impl LspSupervisorHandle
impl LspSupervisorHandle
Sourcepub fn snapshot(&self) -> Arc<SupervisorSnapshot> ⓘ
pub fn snapshot(&self) -> Arc<SupervisorSnapshot> ⓘ
One wait-free ArcSwap::load_full returning the current
snapshot. Callers that need many fields project from the
returned Arc; one-off readers should prefer the
projection helpers below to avoid retaining the snapshot
across awaits.
Sourcepub fn servers_for(&self, uri: &Uri) -> Vec<ServerHandle>
pub fn servers_for(&self, uri: &Uri) -> Vec<ServerHandle>
Every server attached to uri. Empty when the URI is not
open or no config matched its path. Cheap clone.
Sourcepub fn running_actors(&self) -> Vec<(ActorKey, ServerHandle)>
pub fn running_actors(&self) -> Vec<(ActorKey, ServerHandle)>
Snapshot of every running actor’s (key, handle) pair.
Sourcepub fn all_running_handles(&self) -> Vec<ServerHandle>
pub fn all_running_handles(&self) -> Vec<ServerHandle>
Snapshot of every running actor’s ServerHandle. Used by
workspace-scoped LSP requests (e.g. workspace/symbol)
that fan out across every server, not just servers
attached to one buffer.
Sourcepub fn buffer_count_for(&self, key: &ActorKey) -> usize
pub fn buffer_count_for(&self, key: &ActorKey) -> usize
Number of buffers currently attached to the actor at key.
Used by :lsp-server-log for the picker margin.
Sourcepub fn configs(&self) -> Vec<Arc<ServerConfig>>
pub fn configs(&self) -> Vec<Arc<ServerConfig>>
Curated config registry (preference-ordered). Cheap clone.
Sourcepub fn has_server_for_path(&self, path: &Path) -> bool
pub fn has_server_for_path(&self, path: &Path) -> bool
True iff at least one configured server’s file_patterns
matches path. M.5.2 uses this from the App’s
MajorEntered hook to decide whether to auto-activate
lsp-mode on the buffer.
Sourcepub fn attached_buffer_count(&self) -> usize
pub fn attached_buffer_count(&self) -> usize
Number of currently-attached buffers.
Sourcepub fn running_actor_count(&self) -> usize
pub fn running_actor_count(&self) -> usize
Number of currently-running actors.
Sourcepub fn logger(&self) -> &LspLogger
pub fn logger(&self) -> &LspLogger
Borrow the shared logger. Cloning is cheap (LspLogger
wraps an Arc internally) but most callers just want a
borrow to call .log(...).
Sourcepub fn diagnostics(&self) -> &DiagnosticsLayer
pub fn diagnostics(&self) -> &DiagnosticsLayer
Borrow the shared diagnostics layer.
Sourcepub async fn open_buffer(
&self,
path: PathBuf,
text: String,
) -> LspResult<Vec<ServerHandle>>
pub async fn open_buffer( &self, path: PathBuf, text: String, ) -> LspResult<Vec<ServerHandle>>
Open a buffer. Returns the list of attached
ServerHandles; empty if no config matched the path.
May spawn new actors (each one pays the LSP initialize
handshake cost). The supervisor task runs the open;
awaiting here parks the caller while it does, but does
NOT block any other read of the supervisor.
Sourcepub async fn attach_handle(
&self,
uri: Uri,
workspace_root: PathBuf,
server_id: String,
language_id: String,
text: String,
handle: ServerHandle,
) -> LspResult<()>
pub async fn attach_handle( &self, uri: Uri, workspace_root: PathBuf, server_id: String, language_id: String, text: String, handle: ServerHandle, ) -> LspResult<()>
Attach a buffer to a pre-built handle (tests + custom transports).
Sourcepub fn close_buffer(&self, uri: Uri)
pub fn close_buffer(&self, uri: Uri)
Close a buffer. Fire-and-forget: the supervisor task
processes the cmd asynchronously, fires didClose per
attached server, and publishes a fresh snapshot. Tests
that need to assert post-close state should call
Self::close_buffer_ack.
Sourcepub async fn close_buffer_ack(&self, uri: Uri) -> LspResult<()>
pub async fn close_buffer_ack(&self, uri: Uri) -> LspResult<()>
Close a buffer + await acknowledgement. Used by tests + shutdown paths that need to observe the next snapshot.
Sourcepub async fn flush_all(&self) -> LspResult<()>
pub async fn flush_all(&self) -> LspResult<()>
Force-flush every URI; awaits the supervisor task’s ack.
Sourcepub fn record_edit(&self, uri: Uri, edit: Edit)
pub fn record_edit(&self, uri: Uri, edit: Edit)
Drive an edit through the supervisor (test / admin path; production edits ride the event-bus fan-in).
Sourcepub async fn restart_server(
&self,
server_id: String,
) -> LspResult<RestartReport>
pub async fn restart_server( &self, server_id: String, ) -> LspResult<RestartReport>
4.4.d: force-restart every actor with id server_id.
Subject to the per-server-id restart-history backoff:
more than MAX_RESTARTS inside RESTART_WINDOW
returns an error; the caller surfaces the cooldown
message via set_message.
Trait Implementations§
Source§impl Clone for LspSupervisorHandle
impl Clone for LspSupervisorHandle
Source§fn clone(&self) -> LspSupervisorHandle
fn clone(&self) -> LspSupervisorHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LspSupervisorHandle
impl Debug for LspSupervisorHandle
Source§impl Default for LspSupervisorHandle
Placeholder handle for Editor::default() / headless
test scaffolding. The receiver is dropped immediately, so
any cmd sent through this handle silently no-ops (the
caller’s reply oneshot drops without being completed,
which LspSupervisor::send_with_reply reports as a
“supervisor gone” error). Real construction goes through
LspSupervisor::spawn. Production code overwrites this
in boot.rs before any cmd flows.
impl Default for LspSupervisorHandle
Placeholder handle for Editor::default() / headless
test scaffolding. The receiver is dropped immediately, so
any cmd sent through this handle silently no-ops (the
caller’s reply oneshot drops without being completed,
which LspSupervisor::send_with_reply reports as a
“supervisor gone” error). Real construction goes through
LspSupervisor::spawn. Production code overwrites this
in boot.rs before any cmd flows.
Auto Trait Implementations§
impl !RefUnwindSafe for LspSupervisorHandle
impl !UnwindSafe for LspSupervisorHandle
impl Freeze for LspSupervisorHandle
impl Send for LspSupervisorHandle
impl Sync for LspSupervisorHandle
impl Unpin for LspSupervisorHandle
impl UnsafeUnpin for LspSupervisorHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more