Skip to main content

Capabilities

Struct Capabilities 

Source
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: ClientCapabilities

What we advertised. Stable for the actor’s lifetime.

§server: ServerCapabilities

What the server advertised in its initialize response. Stable for the actor’s lifetime; dynamic registrations ride in Self::dynamic.

§position_encoding: PositionEncodingKind

Final negotiated position encoding. utf-8 if the server honoured our preference; utf-16 otherwise (older servers that ignore general.positionEncodings).

§dynamic: DynamicRegistry

4.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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn supports_definition(&self) -> bool

Server’s definitionProvider presence. Consults the dynamic registry (4.4.n).

Source

pub fn supports_references(&self) -> bool

Server’s referencesProvider presence – gates 4.2.d’s gr dispatch. Consults the dynamic registry (4.4.n).

Source

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).

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn supports_formatting(&self) -> bool

Server’s documentFormattingProvider presence – gates :format (Phase 4.3). Consults the dynamic registry (4.4.n).

Source

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).

Source

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).

Source

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).

Source

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).

Source

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.

Source

pub fn supports_execute_command(&self) -> bool

Server’s executeCommandProvider presence – gates workspace/executeCommand for codeAction items that carry a Command payload.

Source

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).

Source

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).

Source

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).

Source

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).

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn on_type_formatting_trigger_chars(&self) -> Vec<char>

Trigger characters for onTypeFormatting. Empty when the provider isn’t advertised.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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).

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).

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn supports_did_create_files(&self) -> bool

4.4.m: server advertises interest in workspace/didCreateFiles notifications.

Source

pub fn supports_will_rename_files(&self) -> bool

4.4.m: server advertises interest in workspace/willRenameFiles requests.

Source

pub fn supports_did_rename_files(&self) -> bool

4.4.m: server advertises interest in workspace/didRenameFiles notifications.

Source

pub fn supports_will_delete_files(&self) -> bool

4.4.m: server advertises interest in workspace/willDeleteFiles requests.

Source

pub fn supports_did_delete_files(&self) -> bool

4.4.m: server advertises interest in workspace/didDeleteFiles notifications.

Source

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.

Source

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.

Source

pub fn wants_will_save(&self) -> bool

Whether the server wants textDocument/willSave notifications. Reads text_document_sync.will_save (Phase 4.3).

Source

pub fn wants_will_save_wait_until(&self) -> bool

Whether the server wants textDocument/willSaveWaitUntil requests. Used for format-on-save when true.

Source

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”).

Source

pub fn did_save_include_text(&self) -> bool

Whether didSave should include the post-save text. Reads text_document_sync.save.include_text.

Source

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.

Source

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

Source§

fn clone(&self) -> Capabilities

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Capabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more