@@ -20,6 +20,7 @@ import { isPathInsidePath, swiftRuntimeEnv } from "../utilities/utilities";
2020import { Version } from "../utilities/version" ;
2121import { FolderEvent , WorkspaceContext } from "../WorkspaceContext" ;
2222import { activateLegacyInlayHints } from "./inlayHints" ;
23+ import { activatePeekDocuments } from "./peekDocuments" ;
2324import { FolderContext } from "../FolderContext" ;
2425import { LanguageClient } from "vscode-languageclient/node" ;
2526import { ArgumentFilter , BuildFlags } from "../toolchain/BuildFlags" ;
@@ -108,6 +109,7 @@ export class LanguageClientManager {
108109 private languageClient : langclient . LanguageClient | null | undefined ;
109110 private cancellationToken ?: vscode . CancellationTokenSource ;
110111 private legacyInlayHints ?: vscode . Disposable ;
112+ private peekDocuments ?: vscode . Disposable ;
111113 private restartedPromise ?: Promise < void > ;
112114 private currentWorkspaceFolder ?: vscode . Uri ;
113115 private waitingOnRestartCount : number ;
@@ -244,6 +246,7 @@ export class LanguageClientManager {
244246 this . cancellationToken ?. cancel ( ) ;
245247 this . cancellationToken ?. dispose ( ) ;
246248 this . legacyInlayHints ?. dispose ( ) ;
249+ this . peekDocuments ?. dispose ( ) ;
247250 this . subscriptions . forEach ( item => item . dispose ( ) ) ;
248251 this . languageClient ?. stop ( ) ;
249252 this . namedOutputChannels . forEach ( channel => channel . dispose ( ) ) ;
@@ -392,6 +395,8 @@ export class LanguageClientManager {
392395 this . currentWorkspaceFolder = workspaceFolder ?. uri ;
393396 this . legacyInlayHints ?. dispose ( ) ;
394397 this . legacyInlayHints = undefined ;
398+ this . peekDocuments ?. dispose ( ) ;
399+ this . peekDocuments = undefined ;
395400 if ( client ) {
396401 this . cancellationToken ?. cancel ( ) ;
397402 this . cancellationToken ?. dispose ( ) ;
@@ -559,6 +564,9 @@ export class LanguageClientManager {
559564 } ) ( ) ,
560565 } ,
561566 errorHandler : new SourceKitLSPErrorHandler ( 5 ) ,
567+ initializationOptions : {
568+ "workspace/peekDocuments" : true , // workaround for client capability to handle `PeekDocumentsRequest`
569+ } ,
562570 } ;
563571
564572 return new langclient . LanguageClient (
@@ -604,6 +612,8 @@ export class LanguageClientManager {
604612 if ( this . workspaceContext . swiftVersion . isLessThan ( new Version ( 5 , 7 , 0 ) ) ) {
605613 this . legacyInlayHints = activateLegacyInlayHints ( client ) ;
606614 }
615+
616+ this . peekDocuments = activatePeekDocuments ( client ) ;
607617 } )
608618 . catch ( reason => {
609619 this . workspaceContext . outputChannel . log ( `${ reason } ` ) ;
0 commit comments