pub struct Capabilities {
pub client: ClientCapabilities,
pub server: ServerCapabilities,
pub position_encoding: PositionEncodingKind,
pub dynamic: DynamicRegistry,
}Expand description
Snapshot of the negotiated capabilities. The actor publishes
one of these through an arc_swap::ArcSwap cell on the
ServerHandle (4.4.n); per-feature
dispatch loads a fresh snapshot before issuing a request.
Before 4.4.n this lived in a plain Arc<Capabilities>
captured at handshake; the dynamic registry was tracked
nowhere. The ArcSwap layer makes register / unregister
observable without changing the read-side ergonomics:
caps.supports_completion() still works the same way, it
just now consults the dynamic side too.
Fields§
§client: ClientCapabilitiesWhat we advertised. Stable for the actor’s lifetime.
server: ServerCapabilitiesWhat the server advertised in its initialize response.
Stable for the actor’s lifetime; dynamic registrations
ride in Self::dynamic.
position_encoding: PositionEncodingKindFinal negotiated position encoding. utf-8 if the server
honoured our preference; utf-16 otherwise (older servers
that ignore general.positionEncodings).
dynamic: DynamicRegistry4.4.n: registrations the server added via
client/registerCapability after handshake. Empty on a
freshly-attached server; each register / unregister
notification produces a new snapshot the actor publishes
through the ArcSwap cell. Probes (supports_* and
friends) that care about dynamic-only registrations OR
in dynamic.has(method); consumers that need the
register_options blob (file watchers, etc.) walk
crate::DynamicRegistry::registrations_for.
Implementations§
Source§impl Capabilities
impl Capabilities
Sourcepub fn from_initialize(
client: ClientCapabilities,
server: ServerCapabilities,
) -> Arc<Self> ⓘ
pub fn from_initialize( client: ClientCapabilities, server: ServerCapabilities, ) -> Arc<Self> ⓘ
Construct from server’s initialize response. Picks the
position encoding the server advertised (if any) or
defaults to utf-16 – the LSP 3.17 fallback when the
server doesn’t honour negotiation. Starts with an empty
dynamic registry; the actor adds entries as
client/registerCapability notifications arrive.
Sourcepub fn with_dynamic_mut(
self: &Arc<Self>,
f: impl FnOnce(&mut DynamicRegistry),
) -> Arc<Self> ⓘ
pub fn with_dynamic_mut( self: &Arc<Self>, f: impl FnOnce(&mut DynamicRegistry), ) -> Arc<Self> ⓘ
4.4.n: clone this capabilities snapshot with the
dynamic registry mutated by f. Returns the new
Arc<Capabilities> the caller stores in the ArcSwap
cell. Pure – the old Arc stays valid for any reader
that already loaded it; the new Arc carries the
updated registry. Used by the actor on register /
unregister to publish without locking.
Sourcepub fn is_utf8(&self) -> bool
pub fn is_utf8(&self) -> bool
True iff the negotiated encoding is utf-8. Used by the position-conversion shim to bypass utf-16 conversion when the server agrees.
Sourcepub fn supports_hover(&self) -> bool
pub fn supports_hover(&self) -> bool
Server’s hoverProvider presence – gates 4.2’s hover
dispatch. Returns false until 4.2 supplements the helper.
Consults the dynamic registry (4.4.n) so servers that
register hover lazily via client/registerCapability
still gate-in.
Sourcepub fn supports_definition(&self) -> bool
pub fn supports_definition(&self) -> bool
Server’s definitionProvider presence. Consults the
dynamic registry (4.4.n).
Sourcepub fn supports_references(&self) -> bool
pub fn supports_references(&self) -> bool
Server’s referencesProvider presence – gates 4.2.d’s
gr dispatch. Consults the dynamic registry (4.4.n).
Sourcepub fn supports_document_symbol(&self) -> bool
pub fn supports_document_symbol(&self) -> bool
Server’s documentSymbolProvider presence – gates the
:document-symbols outline view (Phase 4.2.e). Consults
the dynamic registry (4.4.n).
Sourcepub fn supports_workspace_symbol(&self) -> bool
pub fn supports_workspace_symbol(&self) -> bool
Server’s workspaceSymbolProvider presence – gates the
:workspace-symbols picker (Phase 4.2.f). Consults the
dynamic registry (4.4.n).
Sourcepub fn workspace_symbol_resolve_provider(&self) -> bool
pub fn workspace_symbol_resolve_provider(&self) -> bool
Whether the server advertises resolveProvider on its
workspaceSymbolProvider options. When true, the server
MAY return WorkspaceSymbol entries whose location is
the WorkspaceLocation (URI only) variant; the client
fires workspaceSymbol/resolve on accept to fill in the
range before jumping. Phase 4.2 follow-up.
Sourcepub fn supports_completion(&self) -> bool
pub fn supports_completion(&self) -> bool
Server’s completionProvider presence – gates 4.2.g’s
gen:lsp-completion source. Consults the dynamic
registry (4.4.n).
Sourcepub fn completion_resolve_provider(&self) -> bool
pub fn completion_resolve_provider(&self) -> bool
Whether the server advertises resolveProvider on its
completionProvider options. When true, completion items
may arrive with documentation / additionalTextEdits
missing and need completionItem/resolve before the
docs popup or accept paths read those fields.
Sourcepub fn completion_trigger_chars(&self) -> Vec<char>
pub fn completion_trigger_chars(&self) -> Vec<char>
Trigger characters the server wants completion to fire on (auto-trigger mode). Empty when none advertised or the provider is absent.
Sourcepub fn supports_formatting(&self) -> bool
pub fn supports_formatting(&self) -> bool
Server’s documentFormattingProvider presence – gates
:format (Phase 4.3). Consults the dynamic registry
(4.4.n).
Sourcepub fn supports_range_formatting(&self) -> bool
pub fn supports_range_formatting(&self) -> bool
Server’s documentRangeFormattingProvider presence –
gates :format-range / = operator on motions / objects.
Consults the dynamic registry (4.4.n).
Sourcepub fn supports_signature_help(&self) -> bool
pub fn supports_signature_help(&self) -> bool
Server’s signatureHelpProvider presence – gates the
trigger-character signature popup (Phase 4.3). Consults
the dynamic registry (4.4.n).
Sourcepub fn supports_rename(&self) -> bool
pub fn supports_rename(&self) -> bool
Server’s renameProvider presence – gates :rename
(Phase 4.3). Returns true for both bool and options
shapes the LSP spec allows. Consults the dynamic
registry (4.4.n).
Sourcepub fn supports_code_action(&self) -> bool
pub fn supports_code_action(&self) -> bool
Server’s codeActionProvider presence – gates
:code-actions (Phase 4.3). Returns true for both
bool and options shapes the LSP spec allows. Consults
the dynamic registry (4.4.n).
Sourcepub fn code_action_resolve_provider(&self) -> bool
pub fn code_action_resolve_provider(&self) -> bool
Whether the server advertises resolveProvider on its
codeActionProvider options. When true, codeAction
items may arrive without edit and need
codeAction/resolve before apply.
Sourcepub fn supports_execute_command(&self) -> bool
pub fn supports_execute_command(&self) -> bool
Server’s executeCommandProvider presence – gates
workspace/executeCommand for codeAction items that
carry a Command payload.
Sourcepub fn supports_document_highlight(&self) -> bool
pub fn supports_document_highlight(&self) -> bool
4.4.e: documentHighlightProvider – references in the
current document at the cursor; used to paint same-symbol
occurrences as a soft overlay. Consults the dynamic
registry (4.4.n).
Sourcepub fn supports_selection_range(&self) -> bool
pub fn supports_selection_range(&self) -> bool
4.4.e: selectionRangeProvider – structural smart-
expansion ranges around a position (token → expression →
statement → block → function …). Consults the dynamic
registry (4.4.n).
Sourcepub fn supports_folding_range(&self) -> bool
pub fn supports_folding_range(&self) -> bool
4.4.f: foldingRangeProvider – feeds the LSP
foldmethod. The host’s per-tick pump fires
textDocument/foldingRange when the buffer’s document
version changes; the response seats into a per-buffer
cache the recompute_folds dispatcher reads. Consults
the dynamic registry (4.4.n).
Sourcepub fn supports_inlay_hint(&self) -> bool
pub fn supports_inlay_hint(&self) -> bool
4.4.g: inlayHintProvider – type / parameter
annotations rendered as virtual text inline with the
buffer’s actual characters. The host’s per-tick pump
fires textDocument/inlayHint over the visible range
when the buffer’s document version changes; the
renderer overlay splices each hint’s label at its
position. Consults the dynamic registry (4.4.n).
Sourcepub fn supports_inlay_hint_resolve(&self) -> bool
pub fn supports_inlay_hint_resolve(&self) -> bool
4.4.g follow-up: InlayHintOptions.resolve_provider.
When set, the server populates tooltip and
text_edits lazily – callers issue inlayHint/resolve
for individual hints rather than getting the full
payload in the batched response. The host doesn’t wire
a trigger today (interaction UX is strong-reason
deferred – see lsp-features.md); the probe ships
alongside the wrapper so the future trigger has a
stable check to gate on.
Sourcepub fn supports_semantic_tokens(&self) -> bool
pub fn supports_semantic_tokens(&self) -> bool
4.4.h: semanticTokensProvider – LSP-side highlight
layer that augments tree-sitter. The provider’s legend
(declared at handshake) names the token types
(e.g. "keyword", "function") and modifiers
(e.g. "static", "readonly") the server’s
textDocument/semanticTokens/full response references
by index. The host caches the legend at attach time so
decoding doesn’t re-read capability state per request.
Sourcepub fn semantic_token_types(&self) -> Vec<SemanticTokenType>
pub fn semantic_token_types(&self) -> Vec<SemanticTokenType>
4.4.h: token-type legend declared by the server. Used
by the host’s decoder to map the integer token-type
index in SemanticTokens.data back to a semantic name
("keyword", "function", etc.) for the renderer’s
per-kind styling. Returns an empty vec when the server
doesn’t advertise semantic tokens (the decoder then
skips every token as unrecognized).
Sourcepub fn semantic_token_modifiers(&self) -> Vec<SemanticTokenModifier>
pub fn semantic_token_modifiers(&self) -> Vec<SemanticTokenModifier>
4.4.h: token-modifier legend declared by the server.
Same shape as Self::semantic_token_types but for
the bit-flag modifiers each token can carry.
Sourcepub fn supports_semantic_tokens_delta(&self) -> bool
pub fn supports_semantic_tokens_delta(&self) -> bool
4.4.i: server advertises semanticTokens/full/delta?
When true, the host issues delta requests with the
previous result_id after the first full response;
the server returns a small edit script the host
splices into the cached token vec. Falls back to full
when false.
Sourcepub fn supports_semantic_tokens_range(&self) -> bool
pub fn supports_semantic_tokens_range(&self) -> bool
4.4.i: server advertises semanticTokens/range?
Viewport-bounded request – the host can issue this
for very large files to skip decoding tokens outside
the visible window. Not used by the v1 whole-buffer
pump but exposed for future viewport-aware fetching.
Sourcepub fn supports_on_type_formatting(&self) -> bool
pub fn supports_on_type_formatting(&self) -> bool
Server’s documentOnTypeFormattingProvider presence
(Phase 4.3). Trigger-character driven formatting in
Insert mode – returns the first character that fires
the request, plus more in more_trigger_character.
Sourcepub fn on_type_formatting_trigger_chars(&self) -> Vec<char>
pub fn on_type_formatting_trigger_chars(&self) -> Vec<char>
Trigger characters for onTypeFormatting. Empty when the provider isn’t advertised.
Sourcepub fn supports_prepare_rename(&self) -> bool
pub fn supports_prepare_rename(&self) -> bool
Whether the server advertises prepareProvider on its
rename options – if so, prepareRename should run
before rename to validate the cursor and pick up the
placeholder. Most modern servers (rust-analyzer,
pyright, gopls) advertise this.
Sourcepub fn supports_pull_diagnostics(&self) -> bool
pub fn supports_pull_diagnostics(&self) -> bool
4.4.j: whether the server advertises pull-based
diagnostics (textDocument/diagnostic). Servers can
support pull alongside push or pull-only; in both
cases the host’s pull pump fires on document-version
change and threads the cached result_id so the
server can answer Unchanged when nothing moved.
Sourcepub fn supports_workspace_diagnostic_pull(&self) -> bool
pub fn supports_workspace_diagnostic_pull(&self) -> bool
4.4.j: whether the server’s diagnostic provider also
supports the workspace-wide workspace/diagnostic
pull. Reads DiagnosticOptions.workspace_diagnostics
from either flavour of DiagnosticServerCapabilities.
Returned true even when the host doesn’t issue
workspace pulls today (strong-reason deferred – see
lsp-features.md); future workspace-view rework
branches off this probe.
Sourcepub fn supports_call_hierarchy(&self) -> bool
pub fn supports_call_hierarchy(&self) -> bool
4.5.a: server’s callHierarchyProvider presence –
gates :lsp-incoming-calls / :lsp-outgoing-calls.
Returns true for either the bool-only or options-shape
the LSP spec allows. Consults the dynamic registry
(4.4.n).
Sourcepub fn supports_type_hierarchy(&self) -> bool
pub fn supports_type_hierarchy(&self) -> bool
4.5.b: server’s type-hierarchy support. lsp-types 0.97
doesn’t model a static type_hierarchy_provider field on
ServerCapabilities (newer LSP versions add one); the
probe consults the dynamic registry only. Most servers
that support type hierarchy register it dynamically anyway
(rust-analyzer, pyright). If a server advertises static
type-hierarchy support via a serverInfo-embedded blob
we don’t parse it; the dynamic path is the standard way
to negotiate.
Sourcepub fn supports_moniker(&self) -> bool
pub fn supports_moniker(&self) -> bool
4.5.g: server’s monikerProvider presence. The probe
returns true for either the bool-only or options-shape;
also consults the dynamic registry (4.4.n).
Sourcepub fn supports_document_link(&self) -> bool
pub fn supports_document_link(&self) -> bool
4.5.c: server’s documentLinkProvider presence –
gates the per-tick pump that caches link ranges + the
gx keystroke that consults the cache. Consults the
dynamic registry (4.4.n).
Sourcepub fn document_link_resolve_provider(&self) -> bool
pub fn document_link_resolve_provider(&self) -> bool
4.5.c: whether documentLinkProvider.resolveProvider
is advertised. When true, links may arrive without a
target and need documentLink/resolve before they
can be followed. gx fires the resolve only when the
matched link lacks a target.
Sourcepub fn supports_code_lens(&self) -> bool
pub fn supports_code_lens(&self) -> bool
4.5.d: server’s codeLensProvider presence – gates
the per-tick textDocument/codeLens pump + the
:lsp-code-lens picker. Consults the dynamic
registry (4.4.n).
Sourcepub fn code_lens_resolve_provider(&self) -> bool
pub fn code_lens_resolve_provider(&self) -> bool
4.5.d: whether codeLensProvider.resolveProvider is
advertised. When true, lenses may arrive without a
command and need codeLens/resolve before the
accept-action can route through executeCommand.
Sourcepub fn supports_color(&self) -> bool
pub fn supports_color(&self) -> bool
4.5.e: server’s colorProvider presence – gates the
per-tick documentColor pump + the
:lsp-color-presentation picker. Consults the dynamic
registry (4.4.n). lsp-types models the cap as
Option<ColorProviderCapability> which is a OneOf<bool, ...Options>; both shapes count.
Sourcepub fn supports_linked_editing_range(&self) -> bool
pub fn supports_linked_editing_range(&self) -> bool
4.5.f: server’s linkedEditingRangeProvider presence.
Returns true for the bool-only, options, or
registration-options shapes; also consults the
dynamic registry.
Sourcepub fn supports_inline_value(&self) -> bool
pub fn supports_inline_value(&self) -> bool
4.5.h: server’s inlineValueProvider presence.
Returns true for either the bool-only or options
shape; consults the dynamic registry.
Sourcepub fn supports_will_create_files(&self) -> bool
pub fn supports_will_create_files(&self) -> bool
4.4.m: server advertises interest in
workspace/willCreateFiles requests (server returns
WorkspaceEdit BEFORE the file is created on disk; the
host applies the edits in the same save txn).
Sourcepub fn supports_did_create_files(&self) -> bool
pub fn supports_did_create_files(&self) -> bool
4.4.m: server advertises interest in
workspace/didCreateFiles notifications.
Sourcepub fn supports_will_rename_files(&self) -> bool
pub fn supports_will_rename_files(&self) -> bool
4.4.m: server advertises interest in
workspace/willRenameFiles requests.
Sourcepub fn supports_did_rename_files(&self) -> bool
pub fn supports_did_rename_files(&self) -> bool
4.4.m: server advertises interest in
workspace/didRenameFiles notifications.
Sourcepub fn supports_will_delete_files(&self) -> bool
pub fn supports_will_delete_files(&self) -> bool
4.4.m: server advertises interest in
workspace/willDeleteFiles requests.
Sourcepub fn supports_did_delete_files(&self) -> bool
pub fn supports_did_delete_files(&self) -> bool
4.4.m: server advertises interest in
workspace/didDeleteFiles notifications.
Sourcepub fn file_operations_options(
&self,
kind: FileOpKind,
) -> Option<&FileOperationRegistrationOptions>
pub fn file_operations_options( &self, kind: FileOpKind, ) -> Option<&FileOperationRegistrationOptions>
4.4.m: borrow the server-supplied
FileOperationRegistrationOptions for the requested
file-operation kind. The filters drive the host’s
will/did fan-out – a server only receives events whose
URIs match at least one filter’s
FileOperationPattern.glob. None when the server
didn’t advertise the kind.
Sourcepub fn diagnostic_identifier(&self) -> Option<String>
pub fn diagnostic_identifier(&self) -> Option<String>
4.4.j: diagnostic provider’s optional identifier –
the namespace under which the server groups its
diagnostics. Passed back in DocumentDiagnosticParams
so a server that hosts multiple diagnostic streams
(e.g. lint + typecheck on the same wire) can route the
request to the right computation.
Sourcepub fn wants_will_save(&self) -> bool
pub fn wants_will_save(&self) -> bool
Whether the server wants textDocument/willSave
notifications. Reads text_document_sync.will_save
(Phase 4.3).
Sourcepub fn wants_will_save_wait_until(&self) -> bool
pub fn wants_will_save_wait_until(&self) -> bool
Whether the server wants textDocument/willSaveWaitUntil
requests. Used for format-on-save when true.
Sourcepub fn wants_did_save(&self) -> bool
pub fn wants_did_save(&self) -> bool
Whether the server wants textDocument/didSave
notifications. True when the server advertises any
save options (LSP spec: “if save is set, send didSave”).
Sourcepub fn did_save_include_text(&self) -> bool
pub fn did_save_include_text(&self) -> bool
Whether didSave should include the post-save text.
Reads text_document_sync.save.include_text.
Sourcepub fn signature_help_trigger_chars(&self) -> Vec<char>
pub fn signature_help_trigger_chars(&self) -> Vec<char>
Trigger characters that should fire textDocument/signatureHelp
in Insert mode. Empty when the server doesn’t advertise the
provider or doesn’t list any.
Sourcepub fn text_document_sync_kind(&self) -> Option<TextDocumentSyncKind>
pub fn text_document_sync_kind(&self) -> Option<TextDocumentSyncKind>
Server’s text-document sync mode – determines whether we
send incremental or full content on didChange. None is
the LSP signal that the server doesn’t want sync at all.
Trait Implementations§
Source§impl Clone for Capabilities
impl Clone for Capabilities
Source§fn clone(&self) -> Capabilities
fn clone(&self) -> Capabilities
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 Capabilities
impl RefUnwindSafe for Capabilities
impl Send for Capabilities
impl Sync for Capabilities
impl Unpin for Capabilities
impl UnsafeUnpin for Capabilities
impl UnwindSafe for Capabilities
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