diff --git a/src/constants/lsp.ts b/src/constants/lsp.ts index 9ddb2de..d5b4371 100644 --- a/src/constants/lsp.ts +++ b/src/constants/lsp.ts @@ -1,40 +1,57 @@ import { SemanticTokensDeltaRequest, SemanticTokensRangeRequest } from 'vscode-languageserver' import { + CallHierarchyIncomingCallsRequest, + CallHierarchyOutgoingCallsRequest, CodeActionRequest, CodeActionResolveRequest, CodeLensRequest, CodeLensResolveRequest, CompletionRequest, CompletionResolveRequest, DefinitionRequest, DocumentColorRequest, DocumentDiagnosticRequest, DocumentFormattingRequest, DocumentHighlightRequest, DocumentLinkRequest, - DocumentLinkResolveRequest, DocumentOnTypeFormattingRequest, DocumentRangeFormattingRequest, ExecuteCommandRequest, - FoldingRangeRequest, HoverRequest, PrepareRenameRequest, ReferencesRequest, RenameRequest, RequestType, SemanticTokensRequest, - SignatureHelpRequest, WorkspaceDiagnosticRequest, WorkspaceSymbolRequest, WorkspaceSymbolResolveRequest + DocumentLinkResolveRequest, DocumentOnTypeFormattingRequest, DocumentRangeFormattingRequest, DocumentSymbolRequest, ExecuteCommandRequest, + FoldingRangeRequest, HoverRequest, ImplementationRequest, InlayHintRequest, InlayHintResolveRequest, InlineValueRequest, LinkedEditingRangeRequest, MonikerRequest, PrepareRenameRequest, ReferencesRequest, RenameRequest, RequestType, SelectionRangeRequest, SemanticTokensRequest, + SignatureHelpRequest, TypeDefinitionRequest, TypeHierarchyPrepareRequest, TypeHierarchySubtypesRequest, TypeHierarchySupertypesRequest, WorkspaceDiagnosticRequest, WorkspaceSymbolRequest, WorkspaceSymbolResolveRequest } from 'vscode-languageserver-protocol' export const forwardedClientRequests: RequestType[] = [ - HoverRequest.type, - ReferencesRequest.type, - SignatureHelpRequest.type, - SemanticTokensRequest.type, - SemanticTokensDeltaRequest.type, - SemanticTokensRangeRequest.type, - DefinitionRequest.type, - ReferencesRequest.type, - DocumentHighlightRequest.type, - WorkspaceSymbolRequest.type, - DocumentFormattingRequest.type, - DocumentRangeFormattingRequest.type, - DocumentOnTypeFormattingRequest.type, - RenameRequest.type, - PrepareRenameRequest.type, - ExecuteCommandRequest.type, - CompletionRequest.type, - CompletionResolveRequest.type, + CallHierarchyIncomingCallsRequest.type, + CallHierarchyOutgoingCallsRequest.type, CodeActionRequest.type, CodeActionResolveRequest.type, CodeLensRequest.type, CodeLensResolveRequest.type, + CompletionRequest.type, + CompletionResolveRequest.type, + DefinitionRequest.type, + DocumentColorRequest.type, + DocumentDiagnosticRequest.type, + DocumentFormattingRequest.type, + DocumentHighlightRequest.type, DocumentLinkRequest.type, DocumentLinkResolveRequest.type, + DocumentOnTypeFormattingRequest.type, + DocumentRangeFormattingRequest.type, + DocumentSymbolRequest.type, + ExecuteCommandRequest.type, FoldingRangeRequest.type, - DocumentColorRequest.type, + HoverRequest.type, + ImplementationRequest.type, + InlayHintRequest.type, + InlayHintResolveRequest.type, + InlineValueRequest.type, + LinkedEditingRangeRequest.type, + MonikerRequest.type, + PrepareRenameRequest.type, + ReferencesRequest.type, + ReferencesRequest.type, + RenameRequest.type, + SelectionRangeRequest.type, + SemanticTokensDeltaRequest.type, + SemanticTokensDeltaRequest.type, + SemanticTokensRangeRequest.type, + SemanticTokensRequest.type, + SignatureHelpRequest.type, + TypeDefinitionRequest.type, + TypeHierarchyPrepareRequest.type, + TypeHierarchySubtypesRequest.type, + TypeHierarchySupertypesRequest.type, WorkspaceDiagnosticRequest.type, - DocumentDiagnosticRequest.type, + WorkspaceSymbolRequest.type, WorkspaceSymbolResolveRequest.type ] diff --git a/src/language-client-mutualization.ts b/src/language-client-mutualization.ts index 7582206..b3161de 100644 --- a/src/language-client-mutualization.ts +++ b/src/language-client-mutualization.ts @@ -6,8 +6,11 @@ import { DidChangeConfigurationNotification, InitializedNotification, InitializedParams, + InlayHintRefreshRequest, + InlineValueRefreshRequest, PublishDiagnosticsNotification, SemanticTokensRefreshRequest, + ShowDocumentRequest, TextDocumentSyncOptions, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest @@ -201,34 +204,36 @@ function bindClientToServer ( } }))) - const codelensRefreshSupport = clientCapabilities.workspace?.codeLens?.refreshSupport ?? false - const sendCodeLensRefresh = bindContext(() => { - if (codelensRefreshSupport) { - clientConnection.sendRequest(CodeLensRefreshRequest.type).catch(error => { - options.logger?.error('Unable to send Codelens token refresh to client', { error }) - }) - } - }) + disposableCollection.push(languageClient.onCodeLensRefresh(bindContext(() => { + clientConnection.sendRequest(CodeLensRefreshRequest.type).catch(error => { + options.logger?.error('Unable to send Codelens token refresh to client', { error }) + }) + }))) + disposableCollection.push(languageClient.onSemanticTokensRefresh(bindContext(() => { + clientConnection.sendRequest(SemanticTokensRefreshRequest.type).catch(error => { + options.logger?.error('Unable to send semantic token refresh to client', { error }) + }) + }))) + disposableCollection.push(languageClient.onDiagnosticRefresh(bindContext(() => { + clientConnection.sendRequest(DiagnosticRefreshRequest.type).catch(error => { + options.logger?.error('Unable to send Diagnostics refresh to client', { error }) + }) + }))) + disposableCollection.push(languageClient.onInlayHintRefresh(bindContext(() => { + clientConnection.sendRequest(InlayHintRefreshRequest.type).catch(error => { + options.logger?.error('Unable to send Inlay Hint refresh to client', { error }) + }) + }))) + disposableCollection.push(languageClient.onInlineValueRefresh(bindContext(() => { + clientConnection.sendRequest(InlineValueRefreshRequest.type).catch(error => { + options.logger?.error('Unable to send Inline Value refresh to client', { error }) + }) + }))) - const semanticTokenRefreshSupport = clientCapabilities.workspace?.semanticTokens?.refreshSupport ?? false - const sendSemanticTokensRefresh = bindContext(() => { - if (semanticTokenRefreshSupport) { - clientConnection.sendRequest(SemanticTokensRefreshRequest.type).catch(error => { - options.logger?.error('Unable to send semantic token refresh to client', { error }) - }) - } - }) - const sendDiagnosticsRefresh = bindContext(() => { - if (semanticTokenRefreshSupport) { - clientConnection.sendRequest(DiagnosticRefreshRequest.type).catch(error => { - options.logger?.error('Unable to send Diagnostics refresh to client', { error }) - }) - } - }) + disposableCollection.push(languageClient.onShowDocument(bindContext(params => { + return clientConnection.sendRequest(ShowDocumentRequest.type, params) + }))) - disposableCollection.push(languageClient.onCodeLensRefresh(sendCodeLensRefresh)) - disposableCollection.push(languageClient.onSemanticTokensRefresh(sendSemanticTokensRefresh)) - disposableCollection.push(languageClient.onSemanticTokensRefresh(sendDiagnosticsRefresh)) disposableCollection.push(languageClient.onWorkspaceApplyEdit(bindContext(params => { return clientConnection.sendRequest(ApplyWorkspaceEditRequest.type, { label: params.label, diff --git a/src/language-client.ts b/src/language-client.ts index dae1943..2ad95e5 100644 --- a/src/language-client.ts +++ b/src/language-client.ts @@ -5,7 +5,7 @@ import { LogMessageNotification, WorkspaceFoldersRequest, WorkDoneProgressCreateRequest, ShutdownRequest, ShowMessageNotification, ShowMessageRequest, DidOpenTextDocumentNotification, DidCloseTextDocumentNotification, TextDocumentSyncKind, DidChangeTextDocumentNotification, ExecuteCommandRequest, - LogMessageParams, ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse, Diagnostic, TextDocumentItem, DidSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, TextDocumentIdentifier, TextEdit, TextDocumentRegistrationOptions, DidChangeWatchedFilesNotification, FileSystemWatcher, FileEvent, DiagnosticRefreshRequest + LogMessageParams, ApplyWorkspaceEditParams, Diagnostic, TextDocumentItem, DidSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, TextDocumentIdentifier, TextEdit, TextDocumentRegistrationOptions, DidChangeWatchedFilesNotification, FileSystemWatcher, FileEvent, DiagnosticRefreshRequest, InlayHintRefreshRequest, InlineValueRefreshRequest, ApplyWorkspaceEditResult, ShowDocumentRequest, ShowDocumentParams, ShowDocumentResult } from 'vscode-languageserver-protocol' import { ApplyWorkspaceEditRequest, @@ -69,7 +69,15 @@ export class LanguageClient implements Disposable { private _onDiagnostics = new Emitter() private _onCodeLensRefresh = new MultiRequestHandler(CodeLensRefreshRequest.type, allVoidMerger) private _onSemanticTokensRefresh = new MultiRequestHandler(SemanticTokensRefreshRequest.type, allVoidMerger) - private _onDiagnosticsRefresh = new MultiRequestHandler(DiagnosticRefreshRequest.type, allVoidMerger) + private _onDiagnosticRefresh = new MultiRequestHandler(DiagnosticRefreshRequest.type, allVoidMerger) + private _onInlayHintRefresh = new MultiRequestHandler(InlayHintRefreshRequest.type, allVoidMerger) + private _onInlineValueRefresh = new MultiRequestHandler(InlineValueRefreshRequest.type, allVoidMerger) + private _onShowDocument = new MultiRequestHandler(ShowDocumentRequest.type, results => { + return { + success: results.every(result => (!(result instanceof Error) && result?.success) ?? false) + } + }) + private _workspaceApplyEditRequestHandler = new MultiRequestHandler(ApplyWorkspaceEditRequest.type, singleHandlerMerger({ applied: false })) @@ -113,7 +121,7 @@ export class LanguageClient implements Disposable { return this._onDidWatchedFileChanged.event } - public get onWorkspaceApplyEdit (): RequestHandlerRegistration { + public get onWorkspaceApplyEdit (): RequestHandlerRegistration { return this._workspaceApplyEditRequestHandler.onRequest } @@ -125,8 +133,20 @@ export class LanguageClient implements Disposable { return this._onSemanticTokensRefresh.onRequest } - get onDiagnosticsRefresh (): RequestHandlerRegistration { - return this._onDiagnosticsRefresh.onRequest + get onDiagnosticRefresh (): RequestHandlerRegistration { + return this._onDiagnosticRefresh.onRequest + } + + get onInlayHintRefresh (): RequestHandlerRegistration { + return this._onInlayHintRefresh.onRequest + } + + get onInlineValueRefresh (): RequestHandlerRegistration { + return this._onInlineValueRefresh.onRequest + } + + get onShowDocument (): RequestHandlerRegistration { + return this._onShowDocument.onRequest } private async startConnection (initializeParams: InitializeParams): Promise { @@ -149,7 +169,16 @@ export class LanguageClient implements Disposable { return this._onSemanticTokensRefresh.sendRequest(undefined, token) }) connection.onRequest(DiagnosticRefreshRequest.type, (token) => { - return this._onDiagnosticsRefresh.sendRequest(undefined, token) + return this._onDiagnosticRefresh.sendRequest(undefined, token) + }) + connection.onRequest(InlayHintRefreshRequest.type, (token) => { + return this._onInlayHintRefresh.sendRequest(undefined, token) + }) + connection.onRequest(InlineValueRefreshRequest.type, (token) => { + return this._onInlineValueRefresh.sendRequest(undefined, token) + }) + connection.onRequest(ShowDocumentRequest.type, (params, token) => { + return this._onShowDocument.sendRequest(params, token) }) connection.onRequest(ExecuteCommandRequest.type, (params) => { this.options.logger?.debug(`Ignored Execute command from server ${params.command}(${JSON.stringify(params.arguments)})`)