Skip to content

lspeasy / core/src / serverSupportsNotification

Function: serverSupportsNotification()

ts
function serverSupportsNotification<M, T>(method, capabilities): capabilities is T & ConditionalSimplifyDeep<UnionToIntersection<{ [P in "textDocumentSync" | "textDocumentSync.openClose" | "textDocumentSync.willSave" | "textDocumentSync.save" | "workspace.workspaceFolders.changeNotifications" | "workspace.fileOperations.didCreate" | "workspace.fileOperations.didRename" | "workspace.fileOperations.didDelete"]: { [KeyType in string | number | symbol]: PickDeepObject<ServerCapabilities<any>, P>[KeyType] } }[ServerCapabilityForNotification<M>]>, NonRecursiveType | ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey>, object>;

Defined in: packages/core/src/protocol/capabilities.ts:97

Type-guarding predicate that narrows capabilities to include the specific server capability key required for the given client-to-server notification method.

Type Parameters

Type Parameter
M extends | "initialized" | "exit" | "textDocument/didOpen" | "textDocument/didChange" | "textDocument/didClose" | "textDocument/didSave" | "textDocument/willSave" | "window/workDoneProgress/cancel" | "workspace/didChangeWorkspaceFolders" | "workspace/didCreateFiles" | "workspace/didRenameFiles" | "workspace/didDeleteFiles" | "workspace/didChangeConfiguration" | "workspace/didChangeWatchedFiles" | "$/cancelRequest" | "$/progress" | "$/setTrace" | "notebookDocument/didOpen" | "notebookDocument/didChange" | "notebookDocument/didSave" | "notebookDocument/didClose"
T extends Partial<ServerCapabilities<any>>

Parameters

ParameterTypeDescription
methodMThe LSP notification method string (e.g. 'textDocument/didOpen').
capabilitiesTThe ServerCapabilities object to test.

Returns

capabilities is T & ConditionalSimplifyDeep<UnionToIntersection<{ [P in "textDocumentSync" | "textDocumentSync.openClose" | "textDocumentSync.willSave" | "textDocumentSync.save" | "workspace.workspaceFolders.changeNotifications" | "workspace.fileOperations.didCreate" | "workspace.fileOperations.didRename" | "workspace.fileOperations.didDelete"]: { [KeyType in string | number | symbol]: PickDeepObject<ServerCapabilities<any>, P>[KeyType] } }[ServerCapabilityForNotification<M>]>, NonRecursiveType | ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey>, object>

true when the server has declared support for the method.

Released under the MIT License.