pub struct ServerHandle { /* private fields */ }Expand description
Editor-facing handle to one running language-server actor.
Cheap to clone (Arc internally); the editor passes one
around per buffer / pane that talks to this server. Dropping
the last clone closes the mailbox – the actor sees the
channel close and runs the LSP shutdown sequence on its way
out, so no leak.
Implementations§
Source§impl ServerHandle
impl ServerHandle
Sourcepub fn capabilities(&self) -> Arc<Capabilities> ⓘ
pub fn capabilities(&self) -> Arc<Capabilities> ⓘ
Snapshot of the current negotiated capabilities. Each
call returns a fresh Arc that includes any dynamic
registrations the server has issued since handshake
(4.4.n). Callers that need the capability set to be
stable for a multi-step decision should bind the
snapshot to a local variable; subsequent
capabilities() calls see whatever the actor has
published in the interim.
Sourcepub fn server_id(&self) -> &str
pub fn server_id(&self) -> &str
Server’s stable id (e.g. "rust"). Useful for logs and
for the supervisor to look up ServerConfig.
Sourcepub fn workspace_root(&self) -> Arc<Path> ⓘ
pub fn workspace_root(&self) -> Arc<Path> ⓘ
Workspace root this actor was spawned against. Pairs with
server_id() as the canonical instance identity (B’.2);
cheap clone (Arc bump).
Sourcepub fn instance(&self) -> InstanceKey
pub fn instance(&self) -> InstanceKey
Build the (server_id, workspace) instance key for use
with LspLogger::log and the per-instance log ring.
Sourcepub fn subscribe_diagnostics(&self) -> Receiver<DiagnosticEvent>
pub fn subscribe_diagnostics(&self) -> Receiver<DiagnosticEvent>
Subscribe to this server’s diagnostics broadcast. Each
subscriber receives every publishDiagnostics event
after the call – prior events are not replayed
(a freshly opened pane re-issues the URIs it cares about
to the server, which republishes diagnostics for those).
The returned Receiver is the standard
tokio::sync::broadcast::Receiver. A lagging consumer
drops oldest first; reconcile by tracking the latest
version per URI and ignoring events older than the
editor’s view of the doc.
Sourcepub fn diagnostics_subscriber_count(&self) -> usize
pub fn diagnostics_subscriber_count(&self) -> usize
True iff at least one subscriber is currently listening. Used by tests; production code doesn’t need this.
Sourcepub fn logger(&self) -> &LspLogger
pub fn logger(&self) -> &LspLogger
Borrow the logger this actor emits through. The App
holds the same LspLogger (cloned) and uses it for
supervisor-side records.
Sourcepub fn request<P, R>(&self, method: &str, params: P) -> Pending<R> ⓘ
pub fn request<P, R>(&self, method: &str, params: P) -> Pending<R> ⓘ
Send a typed JSON-RPC request and return a Pending
resolving to the deserialized response.
R must match the server’s response shape for method;
a mismatch surfaces as LspError::ResponseDecode.
Sourcepub fn request_with_cancel<P, R>(
&self,
method: &str,
params: P,
token: CancellationToken,
) -> Pending<R> ⓘ
pub fn request_with_cancel<P, R>( &self, method: &str, params: P, token: CancellationToken, ) -> Pending<R> ⓘ
Same as Self::request but with cooperative cancellation
driven by a [lattice_protocol::CancellationToken]. While
the relay task is awaiting the response from the actor, it
also polls the token; if the token flips before the response
arrives, the relay resolves with LspError::Cancelled.
Local-only cancellation today. The server may keep
computing – we just drop its result if it arrives stale.
$/cancelRequest over the wire is a Phase 4.2 polish item
(requires plumbing the JSON-RPC id back from the actor for
server-side cancel; not on a hot path).
Used by every Phase 4.2 navigation feature
(Self::hover / Self::goto_definition / …) so
stale popups don’t appear after the user moves on.
Sourcepub fn notify<P: Serialize>(&self, method: &str, params: P) -> LspResult<()>
pub fn notify<P: Serialize>(&self, method: &str, params: P) -> LspResult<()>
Fire a JSON-RPC notification (no response expected).
Sourcepub fn set_trace(&self, value: TraceValue) -> LspResult<()>
pub fn set_trace(&self, value: TraceValue) -> LspResult<()>
4.4.b: send $/setTrace { value } to the server (LSP
§3.18). Off silences trace records; Messages ships
the wire shapes; Verbose ships shapes + parameter
contents. The server replies with $/logTrace
notifications which the host routes into the
*lsp:<server>:trace* ring.
Sourcepub fn cancel_progress(&self, token: &str) -> LspResult<()>
pub fn cancel_progress(&self, token: &str) -> LspResult<()>
Cancel an in-flight server-side $/progress operation
(LSP §3.16 window/workDoneProgress/cancel). The server
is asked to wind down the work tied to token; whether
it complies is server-specific. The host treats the
cancel as best-effort — the modeline keeps the entry
until an end progress notification arrives.
Sourcepub fn cancel(&self, jsonrpc_id: i64) -> LspResult<()>
pub fn cancel(&self, jsonrpc_id: i64) -> LspResult<()>
Cancel a pending request by JSON-RPC numeric id (LSP
$/cancelRequest). The actor sends the cancel
notification and resolves the matching pending oneshot
with LspError::Cancelled.
Note: the JSON-RPC id is server-internal – callers
usually don’t have it. The higher-level cancellation
path uses [lattice_runtime::CancellationToken] which
the editor binds to a request via request_with_cancel
(added in 4.2 alongside the navigation features).
Sourcepub fn open_doc(
&self,
uri: Uri,
language_id: impl Into<String>,
text: impl Into<String>,
) -> LspResult<()>
pub fn open_doc( &self, uri: Uri, language_id: impl Into<String>, text: impl Into<String>, ) -> LspResult<()>
Open a document in the actor’s own DocSync mirror and emit
textDocument/didOpen. Single-writer through the actor:
the supervisor mutex is no longer in this path, so the UI
thread cannot stall behind a flush. FIFO ordering with
subsequent record_edit calls is preserved by the cmd
channel.
Sourcepub fn record_edit(&self, uri: Uri, edit: Edit) -> LspResult<()>
pub fn record_edit(&self, uri: Uri, edit: Edit) -> LspResult<()>
Record an edit against the actor’s mirror. Coalesced with other edits and flushed after the actor’s debounce window. Drop-free: the cmd channel is unbounded, so the publisher (typically the per-server fan-in task) cannot lose work.
Sourcepub fn flush(&self, uri: Uri) -> LspResult<()>
pub fn flush(&self, uri: Uri) -> LspResult<()>
Force a flush of the pending change queue for one URI. Useful before a synchronous request that depends on the server having seen the latest text (hover/definition right after typing).
Source§impl ServerHandle
impl ServerHandle
Sourcepub fn hover(
&self,
params: HoverParams,
token: CancellationToken,
) -> Pending<Option<Hover>> ⓘ
pub fn hover( &self, params: HoverParams, token: CancellationToken, ) -> Pending<Option<Hover>> ⓘ
textDocument/hover (DESIGN.md §5.4 / docs/dev/notes/lsp-features.md).
Returns None when the server has nothing to say at the
cursor position. The body’s contents field is what the
renderer feeds into the hover popup markdown pipeline
(App-side HoverPopup); the optional range highlights the symbol
hovered (renderer integration is Phase 4.2.b polish).
Sourcepub fn goto_definition(
&self,
params: GotoDefinitionParams,
token: CancellationToken,
) -> Pending<Option<GotoDefinitionResponse>> ⓘ
pub fn goto_definition( &self, params: GotoDefinitionParams, token: CancellationToken, ) -> Pending<Option<GotoDefinitionResponse>> ⓘ
textDocument/definition (DESIGN.md §5.4 /
docs/dev/notes/lsp-features.md). Returns the location(s) where the
symbol under the cursor is defined. GotoDefinitionResponse
is an enum: single Location, Vec<Location>, or
Vec<LocationLink> (richer links carrying origin range).
Phase 4.2.c picks one (single → jump, multiple → list).
Sourcepub fn goto_declaration(
&self,
params: GotoDeclarationParams,
token: CancellationToken,
) -> Pending<Option<GotoDeclarationResponse>> ⓘ
pub fn goto_declaration( &self, params: GotoDeclarationParams, token: CancellationToken, ) -> Pending<Option<GotoDeclarationResponse>> ⓘ
textDocument/declaration (DESIGN.md §5.4 /
docs/dev/notes/lsp-features.md). gD family. Same response shape as
goto_definition; servers usually point at the forward
declaration (header file in C / extern statement in Rust)
rather than the implementation. Multi-server merge dedups
by (uri, range.start) like definition.
Sourcepub fn goto_type_definition(
&self,
params: GotoTypeDefinitionParams,
token: CancellationToken,
) -> Pending<Option<GotoTypeDefinitionResponse>> ⓘ
pub fn goto_type_definition( &self, params: GotoTypeDefinitionParams, token: CancellationToken, ) -> Pending<Option<GotoTypeDefinitionResponse>> ⓘ
textDocument/typeDefinition (DESIGN.md §5.4). gy family.
“Where is the type of this expression defined?” Useful
for stepping from a value to its struct / class / interface.
Sourcepub fn goto_implementation(
&self,
params: GotoImplementationParams,
token: CancellationToken,
) -> Pending<Option<GotoImplementationResponse>> ⓘ
pub fn goto_implementation( &self, params: GotoImplementationParams, token: CancellationToken, ) -> Pending<Option<GotoImplementationResponse>> ⓘ
textDocument/implementation (DESIGN.md §5.4). gI family.
“Where are the implementations of this trait / interface?”
Often returns multiple locations (one per impl); we share
definition’s pick-or-list dispatch.
Sourcepub fn references(
&self,
params: ReferenceParams,
token: CancellationToken,
) -> Pending<Option<Vec<Location>>> ⓘ
pub fn references( &self, params: ReferenceParams, token: CancellationToken, ) -> Pending<Option<Vec<Location>>> ⓘ
textDocument/references (DESIGN.md §5.4). Returns every
reference site to the symbol under the cursor. The
include_declaration flag sits on ReferenceContext inside
ReferenceParams; callers usually want it true for gr
(vim convention).
Sourcepub fn document_symbol(
&self,
params: DocumentSymbolParams,
token: CancellationToken,
) -> Pending<Option<DocumentSymbolResponse>> ⓘ
pub fn document_symbol( &self, params: DocumentSymbolParams, token: CancellationToken, ) -> Pending<Option<DocumentSymbolResponse>> ⓘ
textDocument/documentSymbol (DESIGN.md §5.4). Returns the
symbol outline for the buffer. Response is either flat
Vec<SymbolInformation> (legacy) or hierarchical
Vec<DocumentSymbol> (modern). Phase 4.2.e flattens the
hierarchy to a list with depth-indent for the picker.
Sourcepub fn workspace_symbol(
&self,
params: WorkspaceSymbolParams,
token: CancellationToken,
) -> Pending<Option<WorkspaceSymbolResponse>> ⓘ
pub fn workspace_symbol( &self, params: WorkspaceSymbolParams, token: CancellationToken, ) -> Pending<Option<WorkspaceSymbolResponse>> ⓘ
workspace/symbol (DESIGN.md §5.4). Workspace-scoped
symbol search. The query string filters server-side; the
editor sends query="" for an everything-list and
re-queries as the user types in the picker (Phase 4.2.f).
Response shape: WorkspaceSymbolResponse – the
Flat(Vec<SymbolInformation>) variant is the legacy
shape every server emits; the
Nested(Vec<WorkspaceSymbol>) variant (LSP 3.17+) lets
the server defer the location.range and have the
client fire workspaceSymbol/resolve on accept. The
editor handles both shapes – legacy rows jump
immediately; nested rows with a WorkspaceLocation
route through the resolve path before jumping.
Sourcepub fn workspace_symbol_resolve(
&self,
symbol: WorkspaceSymbol,
token: CancellationToken,
) -> Pending<WorkspaceSymbol> ⓘ
pub fn workspace_symbol_resolve( &self, symbol: WorkspaceSymbol, token: CancellationToken, ) -> Pending<WorkspaceSymbol> ⓘ
workspaceSymbol/resolve (LSP 3.17+, Phase 4.2 follow-up).
Sent for WorkspaceSymbol rows whose location came back
as the WorkspaceLocation (URI-only) variant; the server
returns the same symbol with location.range populated.
Wired into the :workspace-symbols picker accept path
when the server advertises
workspaceSymbolProvider.resolveProvider.
Sourcepub fn prepare_call_hierarchy(
&self,
params: CallHierarchyPrepareParams,
token: CancellationToken,
) -> Pending<Option<Vec<CallHierarchyItem>>> ⓘ
pub fn prepare_call_hierarchy( &self, params: CallHierarchyPrepareParams, token: CancellationToken, ) -> Pending<Option<Vec<CallHierarchyItem>>> ⓘ
4.5.a: textDocument/prepareCallHierarchy. Asks the
server which callable(s) live at the cursor; the
response feeds the subsequent
Self::call_hierarchy_incoming_calls /
Self::call_hierarchy_outgoing_calls request.
Servers typically return a single-element vec for a
position inside a function body; macros / overloads
can produce multiple items. None means “no callable
here”, which short-circuits the navigation.
Sourcepub fn call_hierarchy_incoming_calls(
&self,
params: CallHierarchyIncomingCallsParams,
token: CancellationToken,
) -> Pending<Option<Vec<CallHierarchyIncomingCall>>> ⓘ
pub fn call_hierarchy_incoming_calls( &self, params: CallHierarchyIncomingCallsParams, token: CancellationToken, ) -> Pending<Option<Vec<CallHierarchyIncomingCall>>> ⓘ
4.5.a: callHierarchy/incomingCalls. Given a
CallHierarchyItem from prepareCallHierarchy,
returns the call sites that invoke it. Each
CallHierarchyIncomingCall carries the caller item
(from) plus the ranges inside the caller where the
call appears (from_ranges).
Sourcepub fn call_hierarchy_outgoing_calls(
&self,
params: CallHierarchyOutgoingCallsParams,
token: CancellationToken,
) -> Pending<Option<Vec<CallHierarchyOutgoingCall>>> ⓘ
pub fn call_hierarchy_outgoing_calls( &self, params: CallHierarchyOutgoingCallsParams, token: CancellationToken, ) -> Pending<Option<Vec<CallHierarchyOutgoingCall>>> ⓘ
4.5.a: callHierarchy/outgoingCalls. Symmetric peer
of incomingCalls; given a callable, returns the
callables it invokes plus the call sites inside its
own body (from_ranges on the caller’s text).
Sourcepub fn prepare_type_hierarchy(
&self,
params: TypeHierarchyPrepareParams,
token: CancellationToken,
) -> Pending<Option<Vec<TypeHierarchyItem>>> ⓘ
pub fn prepare_type_hierarchy( &self, params: TypeHierarchyPrepareParams, token: CancellationToken, ) -> Pending<Option<Vec<TypeHierarchyItem>>> ⓘ
4.5.b: textDocument/prepareTypeHierarchy. Same
preparation shape as prepareCallHierarchy but
targets type relationships (super/sub-types). Used by
:lsp-supertypes / :lsp-subtypes.
Sourcepub fn type_hierarchy_supertypes(
&self,
params: TypeHierarchySupertypesParams,
token: CancellationToken,
) -> Pending<Option<Vec<TypeHierarchyItem>>> ⓘ
pub fn type_hierarchy_supertypes( &self, params: TypeHierarchySupertypesParams, token: CancellationToken, ) -> Pending<Option<Vec<TypeHierarchyItem>>> ⓘ
4.5.b: typeHierarchy/supertypes. Returns the types
the given item is a subtype of (e.g. trait
supertraits, class superclasses).
Sourcepub fn type_hierarchy_subtypes(
&self,
params: TypeHierarchySubtypesParams,
token: CancellationToken,
) -> Pending<Option<Vec<TypeHierarchyItem>>> ⓘ
pub fn type_hierarchy_subtypes( &self, params: TypeHierarchySubtypesParams, token: CancellationToken, ) -> Pending<Option<Vec<TypeHierarchyItem>>> ⓘ
4.5.b: typeHierarchy/subtypes. Returns the types that
subtype the given item (e.g. trait implementors,
class subclasses).
Sourcepub fn moniker(
&self,
params: MonikerParams,
token: CancellationToken,
) -> Pending<Option<Vec<Moniker>>> ⓘ
pub fn moniker( &self, params: MonikerParams, token: CancellationToken, ) -> Pending<Option<Vec<Moniker>>> ⓘ
4.5.g: textDocument/moniker. Returns the stable
cross-project identifier(s) for the symbol at the
cursor – e.g. SCIP / LSIF emit monikers so a build
indexer can join symbols across repos. The response
is Option<Vec<Moniker>>; each moniker has a scheme,
identifier, optional kind, and unique level.
:lsp-moniker ex-command surfaces the list as an echo.
Sourcepub fn document_link(
&self,
params: DocumentLinkParams,
token: CancellationToken,
) -> Pending<Option<Vec<DocumentLink>>> ⓘ
pub fn document_link( &self, params: DocumentLinkParams, token: CancellationToken, ) -> Pending<Option<Vec<DocumentLink>>> ⓘ
4.5.c: textDocument/documentLink. Returns the
hyperlink ranges inside the document (URLs, imports,
file:// references emitted by certain LSPs). The
host caches the response per (BufferId, doc_version)
and consults the cache when gx is pressed in Normal
mode – the first link whose range covers the cursor
wins.
Sourcepub fn document_link_resolve(
&self,
link: DocumentLink,
token: CancellationToken,
) -> Pending<DocumentLink> ⓘ
pub fn document_link_resolve( &self, link: DocumentLink, token: CancellationToken, ) -> Pending<DocumentLink> ⓘ
4.5.c: documentLink/resolve. Lazy-resolves a link
that arrived without a target – the server fills it
in on demand. gx triggers this when the cached link
at the cursor lacks target AND the server advertises
documentLinkProvider.resolveProvider. The resolved
link is then followed in the same gesture.
Sourcepub fn code_lens(
&self,
params: CodeLensParams,
token: CancellationToken,
) -> Pending<Option<Vec<CodeLens>>> ⓘ
pub fn code_lens( &self, params: CodeLensParams, token: CancellationToken, ) -> Pending<Option<Vec<CodeLens>>> ⓘ
4.5.d: textDocument/codeLens. Returns above-line
clickable annotations (run / debug / references etc.).
The host caches per (BufferId, doc_version) and renders
title-only items inline; clicking (:lsp-code-lens)
fires the lens’s command via executeCommand.
Sourcepub fn code_lens_resolve(
&self,
lens: CodeLens,
token: CancellationToken,
) -> Pending<CodeLens> ⓘ
pub fn code_lens_resolve( &self, lens: CodeLens, token: CancellationToken, ) -> Pending<CodeLens> ⓘ
4.5.d: codeLens/resolve. Lazy-resolves a code lens
whose command is missing – some servers return only
the range + minimal title in the batched response and
fill in the actual command on demand. Triggered when
the user accepts a lens whose command is None.
Sourcepub fn document_color(
&self,
params: DocumentColorParams,
token: CancellationToken,
) -> Pending<Vec<ColorInformation>> ⓘ
pub fn document_color( &self, params: DocumentColorParams, token: CancellationToken, ) -> Pending<Vec<ColorInformation>> ⓘ
4.5.e: textDocument/documentColor. Returns the color
literals (hex / named) the server detected in the
document, each with its range and resolved color
(red/green/blue/alpha in [0.0, 1.0]). The host caches
per (BufferId, doc_version) and feeds the cache to a
future renderer swatch overlay; :lsp-color-presentation
reads the cached entry at the cursor to drive the
alternative-format picker.
Sourcepub fn color_presentation(
&self,
params: ColorPresentationParams,
token: CancellationToken,
) -> Pending<Vec<ColorPresentation>> ⓘ
pub fn color_presentation( &self, params: ColorPresentationParams, token: CancellationToken, ) -> Pending<Vec<ColorPresentation>> ⓘ
4.5.e: textDocument/colorPresentation. Given a color +
the range it covers, the server returns alternative
presentations the user can replace the literal with
(e.g. "#ff0000" -> "rgb(255, 0, 0)", "red").
:lsp-color-presentation opens these as a picker;
accept splices the chosen text_edit (or label as
a simple replace) at the literal’s range.
Sourcepub fn linked_editing_range(
&self,
params: LinkedEditingRangeParams,
token: CancellationToken,
) -> Pending<Option<LinkedEditingRanges>> ⓘ
pub fn linked_editing_range( &self, params: LinkedEditingRangeParams, token: CancellationToken, ) -> Pending<Option<LinkedEditingRanges>> ⓘ
4.5.f: textDocument/linkedEditingRange. Returns the
ranges that should be edited in lockstep when the user
types inside one of them (e.g. matching HTML/JSX tag
pairs). Wire wrapper only – the multi-cursor
shadow-edit machinery the feature needs is its own
slice; see the matrix row’s strong-reason defer.
Sourcepub fn inline_value(
&self,
params: InlineValueParams,
token: CancellationToken,
) -> Pending<Option<Vec<InlineValue>>> ⓘ
pub fn inline_value( &self, params: InlineValueParams, token: CancellationToken, ) -> Pending<Option<Vec<InlineValue>>> ⓘ
4.5.h: textDocument/inlineValue. Returns the live
values to render at each line during a debug session
(e.g. n = 5, result = "ok"). Wire wrapper only –
without a debug-adapter integration (DAP) the trigger
surface that would render these is absent; see the
matrix row’s strong-reason defer.
Sourcepub fn completion(
&self,
params: CompletionParams,
token: CancellationToken,
) -> Pending<Option<CompletionResponse>> ⓘ
pub fn completion( &self, params: CompletionParams, token: CancellationToken, ) -> Pending<Option<CompletionResponse>> ⓘ
textDocument/completion (DESIGN.md §5.4 / Phase 4.2.g).
Returns either an array of items or an isIncomplete list
the editor must re-query as the user types more. The
completion pipeline (lattice-completion) registers a
gen:lsp-completion source backed by this call.
Sourcepub fn formatting(
&self,
params: DocumentFormattingParams,
token: CancellationToken,
) -> Pending<Option<Vec<TextEdit>>> ⓘ
pub fn formatting( &self, params: DocumentFormattingParams, token: CancellationToken, ) -> Pending<Option<Vec<TextEdit>>> ⓘ
textDocument/formatting (DESIGN.md §5.4 / Phase 4.3).
Whole-buffer formatter; the response is a Vec<TextEdit>
the editor applies as a single undo unit. Single-server
strategy per the architecture doc – highest-priority
server with documentFormattingProvider advertised wins.
Sourcepub fn range_formatting(
&self,
params: DocumentRangeFormattingParams,
token: CancellationToken,
) -> Pending<Option<Vec<TextEdit>>> ⓘ
pub fn range_formatting( &self, params: DocumentRangeFormattingParams, token: CancellationToken, ) -> Pending<Option<Vec<TextEdit>>> ⓘ
textDocument/rangeFormatting (Phase 4.3). Same shape as
formatting but bounded to the supplied range – bound to
the = operator on motions / objects / Visual selection.
Sourcepub fn signature_help(
&self,
params: SignatureHelpParams,
token: CancellationToken,
) -> Pending<Option<SignatureHelp>> ⓘ
pub fn signature_help( &self, params: SignatureHelpParams, token: CancellationToken, ) -> Pending<Option<SignatureHelp>> ⓘ
textDocument/signatureHelp (Phase 4.3). Trigger-character
driven (,, () when the server advertises the trigger.
Response carries the active signature + parameter; renderer
integration overlays a popup similar to hover.
Sourcepub fn prepare_rename(
&self,
params: TextDocumentPositionParams,
token: CancellationToken,
) -> Pending<Option<PrepareRenameResponse>> ⓘ
pub fn prepare_rename( &self, params: TextDocumentPositionParams, token: CancellationToken, ) -> Pending<Option<PrepareRenameResponse>> ⓘ
textDocument/prepareRename (Phase 4.3). Validates the
cursor is on a renameable identifier and returns the
placeholder + range. None means “the symbol can’t be
renamed here” – the editor echoes and bails. Optional
in the spec (servers may skip prepareRename and accept
rename directly), so callers should treat None from
prepare_rename as “fall through to rename”.
Sourcepub fn rename(
&self,
params: RenameParams,
token: CancellationToken,
) -> Pending<Option<WorkspaceEdit>> ⓘ
pub fn rename( &self, params: RenameParams, token: CancellationToken, ) -> Pending<Option<WorkspaceEdit>> ⓘ
textDocument/rename (Phase 4.3). Renames the symbol
under cursor across the workspace. Response is a
WorkspaceEdit with per-file Vec<TextEdit>s; the
editor applies all edits as a single undoable unit.
Sourcepub fn will_save(&self, params: WillSaveTextDocumentParams) -> LspResult<()>
pub fn will_save(&self, params: WillSaveTextDocumentParams) -> LspResult<()>
textDocument/willSave (Phase 4.3 – notification).
Fired before the editor commits the buffer to disk.
Servers use this to clean up state, finalise indexing,
or prepare didSave-driven validation.
Sourcepub fn will_save_wait_until(
&self,
params: WillSaveTextDocumentParams,
token: CancellationToken,
) -> Pending<Option<Vec<TextEdit>>> ⓘ
pub fn will_save_wait_until( &self, params: WillSaveTextDocumentParams, token: CancellationToken, ) -> Pending<Option<Vec<TextEdit>>> ⓘ
textDocument/willSaveWaitUntil (Phase 4.3). Same
trigger as will_save but request-shaped: server
returns a Vec<TextEdit> to apply pre-save.
format-on-save flows through here when the server
advertises will_save_wait_until on its
TextDocumentSyncOptions.save.
Sourcepub fn did_save(&self, params: DidSaveTextDocumentParams) -> LspResult<()>
pub fn did_save(&self, params: DidSaveTextDocumentParams) -> LspResult<()>
textDocument/didSave (Phase 4.3 – notification).
Fired after a successful disk write. Carries the
post-save text iff the server’s
TextDocumentSaveRegistrationOptions.include_text is
true.
Sourcepub fn did_change_configuration(
&self,
params: DidChangeConfigurationParams,
) -> LspResult<()>
pub fn did_change_configuration( &self, params: DidChangeConfigurationParams, ) -> LspResult<()>
4.4.k: workspace/didChangeConfiguration (notification).
Fan-out fires when any lsp.* typed option changes
(via OptionChanged cascade). The notification’s
settings carries the full lsp subtree from the
merged config TOML; most servers ignore the inline
payload and pull fresh values via
workspace/configuration (the host’s drain serves
from the same tree), but servers that read inline get
the values too. Notification-only – no response, no
cancellation token.
Sourcepub fn did_change_watched_files(
&self,
params: DidChangeWatchedFilesParams,
) -> LspResult<()>
pub fn did_change_watched_files( &self, params: DidChangeWatchedFilesParams, ) -> LspResult<()>
4.4.l: workspace/didChangeWatchedFiles (notification).
Fan-out fires when the host’s file-watcher observes an
fs event whose path matches a glob from this server’s
client/registerCapability-issued
DidChangeWatchedFilesRegistrationOptions. The host
batches per-tick into one notification per server (the
LSP spec allows multiple FileEvents in one payload);
servers receive the events in arrival order.
Notification-only – no response, no cancellation.
Sourcepub fn will_create_files(
&self,
params: CreateFilesParams,
cancel: CancellationToken,
) -> Pending<Option<WorkspaceEdit>> ⓘ
pub fn will_create_files( &self, params: CreateFilesParams, cancel: CancellationToken, ) -> Pending<Option<WorkspaceEdit>> ⓘ
4.4.m: workspace/willCreateFiles (request).
Pre-create hook – server MAY return a WorkspaceEdit
the client applies BEFORE the actual file is created on
disk (e.g. add an import to a sibling module). Callers
must gate on Capabilities::supports_will_create_files +
filter the URIs against the registration’s
FileOperationFilters before issuing. The host pump
(when wired) blocks the create path on the response;
timeouts skip the edits and proceed.
Sourcepub fn did_create_files(&self, params: CreateFilesParams) -> LspResult<()>
pub fn did_create_files(&self, params: CreateFilesParams) -> LspResult<()>
4.4.m: workspace/didCreateFiles (notification).
Post-create fan-out. The wire wrapper is straight-line;
trigger discipline (when to fire) lives in the host
save / create paths.
Sourcepub fn will_rename_files(
&self,
params: RenameFilesParams,
cancel: CancellationToken,
) -> Pending<Option<WorkspaceEdit>> ⓘ
pub fn will_rename_files( &self, params: RenameFilesParams, cancel: CancellationToken, ) -> Pending<Option<WorkspaceEdit>> ⓘ
4.4.m: workspace/willRenameFiles (request). Same
response shape as willCreateFiles. Triggered when the
user renames a file in-place (:saveas follow-up that
removes the original); server returns edits to keep
imports / references in sync with the new path.
Sourcepub fn did_rename_files(&self, params: RenameFilesParams) -> LspResult<()>
pub fn did_rename_files(&self, params: RenameFilesParams) -> LspResult<()>
4.4.m: workspace/didRenameFiles (notification).
Sourcepub fn will_delete_files(
&self,
params: DeleteFilesParams,
cancel: CancellationToken,
) -> Pending<Option<WorkspaceEdit>> ⓘ
pub fn will_delete_files( &self, params: DeleteFilesParams, cancel: CancellationToken, ) -> Pending<Option<WorkspaceEdit>> ⓘ
4.4.m: workspace/willDeleteFiles (request). Server
returns edits to clean up references before the delete.
Sourcepub fn did_delete_files(&self, params: DeleteFilesParams) -> LspResult<()>
pub fn did_delete_files(&self, params: DeleteFilesParams) -> LspResult<()>
4.4.m: workspace/didDeleteFiles (notification).
Sourcepub fn code_action(
&self,
params: CodeActionParams,
token: CancellationToken,
) -> Pending<Option<CodeActionResponse>> ⓘ
pub fn code_action( &self, params: CodeActionParams, token: CancellationToken, ) -> Pending<Option<CodeActionResponse>> ⓘ
textDocument/codeAction (Phase 4.3). Returns the list
of quick fixes / refactors / source actions available
for the supplied range. Each item carries either an
inline edit (apply directly), a command (route
through executeCommand), or both. Items with neither
need codeAction/resolve to fill in the missing
edit.
Sourcepub fn code_action_resolve(
&self,
action: CodeAction,
token: CancellationToken,
) -> Pending<CodeAction> ⓘ
pub fn code_action_resolve( &self, action: CodeAction, token: CancellationToken, ) -> Pending<CodeAction> ⓘ
codeAction/resolve (Phase 4.3). Lazy-resolve a
codeAction that arrived without edit. Servers that
advertise codeActionProvider.resolveProvider may
return action stubs (label + kind only) and fill in
edit here, on demand. Cheaper than computing every
edit upfront.
Sourcepub fn execute_command(
&self,
params: ExecuteCommandParams,
token: CancellationToken,
) -> Pending<Option<Value>> ⓘ
pub fn execute_command( &self, params: ExecuteCommandParams, token: CancellationToken, ) -> Pending<Option<Value>> ⓘ
workspace/executeCommand (Phase 4.3). Run a server-
registered command identified by string id. Used by
codeAction items that carry a command rather than an
inline edit. Response shape varies per command –
servers usually return null + side-effect via
workspace/applyEdit.
Sourcepub fn on_type_formatting(
&self,
params: DocumentOnTypeFormattingParams,
token: CancellationToken,
) -> Pending<Option<Vec<TextEdit>>> ⓘ
pub fn on_type_formatting( &self, params: DocumentOnTypeFormattingParams, token: CancellationToken, ) -> Pending<Option<Vec<TextEdit>>> ⓘ
textDocument/onTypeFormatting (Phase 4.3). Trigger-
character driven formatting that adjusts surrounding
whitespace / indentation as the user types (commonly
fires on ;, }, \n for C-family). Returns the same
Vec<TextEdit> shape as the other formatting flavours.
Sourcepub fn document_highlight(
&self,
params: DocumentHighlightParams,
token: CancellationToken,
) -> Pending<Option<Vec<DocumentHighlight>>> ⓘ
pub fn document_highlight( &self, params: DocumentHighlightParams, token: CancellationToken, ) -> Pending<Option<Vec<DocumentHighlight>>> ⓘ
4.4.e: textDocument/documentHighlight. Returns the
references to the symbol at the cursor inside the
current document; each entry carries an optional kind
(Text / Read / Write) so the overlay can paint
reads / writes differently. Response is Vec<DocumentHighlight>
or null when the cursor isn’t on a known symbol.
Sourcepub fn selection_range(
&self,
params: SelectionRangeParams,
token: CancellationToken,
) -> Pending<Option<Vec<SelectionRange>>> ⓘ
pub fn selection_range( &self, params: SelectionRangeParams, token: CancellationToken, ) -> Pending<Option<Vec<SelectionRange>>> ⓘ
4.4.e: textDocument/selectionRange. Given a slice of
positions (almost always one cursor position), the server
returns the structural ranges that surround each
position, walking outward (token → expression → statement
→ block → function → module). The operator-side
expand-region / shrink-region consumes the linked list.
Sourcepub fn folding_range(
&self,
params: FoldingRangeParams,
token: CancellationToken,
) -> Pending<Option<Vec<FoldingRange>>> ⓘ
pub fn folding_range( &self, params: FoldingRangeParams, token: CancellationToken, ) -> Pending<Option<Vec<FoldingRange>>> ⓘ
4.4.f: textDocument/foldingRange. Returns line-based
fold extents (with optional character columns + kind tag
like comment / imports / region). The host’s
per-tick pump refreshes the cache when the document
version bumps; :set foldmethod=lsp reads from the
cache.
Sourcepub fn inlay_hint(
&self,
params: InlayHintParams,
token: CancellationToken,
) -> Pending<Option<Vec<InlayHint>>> ⓘ
pub fn inlay_hint( &self, params: InlayHintParams, token: CancellationToken, ) -> Pending<Option<Vec<InlayHint>>> ⓘ
4.4.g: textDocument/inlayHint. Returns inline
virtual-text annotations (type hints, parameter
names, etc.) over the requested range. Each hint
carries its position, a label (single string or
composite Vec<InlayHintLabelPart>), and optional
kind / padding / tooltip fields. The host caches the
response per buffer-version and the renderer splices
each hint into the line span list.
Sourcepub fn inlay_hint_resolve(
&self,
hint: InlayHint,
token: CancellationToken,
) -> Pending<InlayHint> ⓘ
pub fn inlay_hint_resolve( &self, hint: InlayHint, token: CancellationToken, ) -> Pending<InlayHint> ⓘ
4.4.g follow-up: inlayHint/resolve. Lazy-resolves a
single inlay hint – the server populates the
tooltip and text_edits fields it skipped on the
initial batched response. Servers gate this behind
the InlayHintOptions.resolve_provider capability;
callers must check crate::Capabilities::supports_inlay_hint_resolve
before issuing. The wrapper ships ahead of the
interaction UX (no gesture is wired to fire it today
– see lsp-features.md for the deferral rationale);
this lets future work plug a trigger into a stable
surface.
Sourcepub fn semantic_tokens_full(
&self,
params: SemanticTokensParams,
token: CancellationToken,
) -> Pending<Option<SemanticTokensResult>> ⓘ
pub fn semantic_tokens_full( &self, params: SemanticTokensParams, token: CancellationToken, ) -> Pending<Option<SemanticTokensResult>> ⓘ
4.4.h: textDocument/semanticTokens/full. Returns the
whole-buffer semantic token list in the LSP
relative-position varint encoding (5 u32s per token:
deltaLine, deltaStart, length, tokenType, modifiers
bitfield). The host decodes against the server’s
SemanticTokensLegend (cached at attach time via
crate::Capabilities::semantic_token_types /
semantic_token_modifiers). Wrapped response variant
Tokens carries data: Vec<u32> plus an optional
result_id for the 4.4.i delta path.
Sourcepub fn semantic_tokens_full_delta(
&self,
params: SemanticTokensDeltaParams,
token: CancellationToken,
) -> Pending<Option<SemanticTokensFullDeltaResult>> ⓘ
pub fn semantic_tokens_full_delta( &self, params: SemanticTokensDeltaParams, token: CancellationToken, ) -> Pending<Option<SemanticTokensFullDeltaResult>> ⓘ
4.4.i: textDocument/semanticTokens/full/delta. Sends
the previous response’s result_id; server either
returns a new full token list (Tokens variant) when
it can’t compute a delta cheaply, or a list of edit
operations (TokensDelta) the host applies to the
cached raw token vec. Edit shape:
SemanticTokensEdit { start, delete_count, data }
where start is the index into the previous flat
token vec, delete_count is how many SemanticToken
entries to remove, and data is what to splice in.
The host re-decodes the spliced vec into absolute
positions.
Sourcepub fn semantic_tokens_range(
&self,
params: SemanticTokensRangeParams,
token: CancellationToken,
) -> Pending<Option<SemanticTokensRangeResult>> ⓘ
pub fn semantic_tokens_range( &self, params: SemanticTokensRangeParams, token: CancellationToken, ) -> Pending<Option<SemanticTokensRangeResult>> ⓘ
4.4.i: textDocument/semanticTokens/range. Viewport-
bounded request – the host can issue this for very
large files to skip decoding tokens outside the
visible window. Returns a plain SemanticTokens
(no Delta variant for the range flavour).
Exposed as a typed wrapper today; the v1 pump uses
full/delta. Viewport-aware fetching can switch over
in a follow-up without re-touching the wire path.
Sourcepub fn document_diagnostic(
&self,
params: DocumentDiagnosticParams,
token: CancellationToken,
) -> Pending<DocumentDiagnosticReportResult> ⓘ
pub fn document_diagnostic( &self, params: DocumentDiagnosticParams, token: CancellationToken, ) -> Pending<DocumentDiagnosticReportResult> ⓘ
4.4.j: textDocument/diagnostic. Pull-based
diagnostics (LSP 3.17). The server returns either a
Full report (entire diagnostics list for the URI,
plus optional result_id for the next delta) or an
Unchanged report (“no diagnostics moved since the
previous result_id”). The host caches the
result_id per buffer-version and threads it back in
DocumentDiagnosticParams.previous_result_id so the
server can answer Unchanged cheaply. Used when a
server prefers pull over push, or alongside push for
servers that support both.
Sourcepub fn workspace_diagnostic(
&self,
params: WorkspaceDiagnosticParams,
token: CancellationToken,
) -> Pending<WorkspaceDiagnosticReportResult> ⓘ
pub fn workspace_diagnostic( &self, params: WorkspaceDiagnosticParams, token: CancellationToken, ) -> Pending<WorkspaceDiagnosticReportResult> ⓘ
4.4.j: workspace/diagnostic. Workspace-wide pull –
returns reports for every URI the server tracks
diagnostics for, even ones the client hasn’t opened.
Wrapper ships ahead of the host pump (strong-reason
deferred; the per-document pump already covers every
open buffer’s diagnostics, and the closed-file
workspace pull is niche – see lsp-features.md). The
callable exists so future workspace-view rework has a
stable surface.
Trait Implementations§
Source§impl Clone for ServerHandle
impl Clone for ServerHandle
Source§fn clone(&self) -> ServerHandle
fn clone(&self) -> ServerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ServerHandle
impl RefUnwindSafe for ServerHandle
impl Send for ServerHandle
impl Sync for ServerHandle
impl Unpin for ServerHandle
impl UnsafeUnpin for ServerHandle
impl UnwindSafe for ServerHandle
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