@@ -27,6 +27,7 @@ import { DiagnosticsManager } from "../DiagnosticsManager";
27
27
import { LSPLogger , LSPOutputChannel } from "./LSPOutputChannel" ;
28
28
import { SwiftOutputChannel } from "../ui/SwiftOutputChannel" ;
29
29
import { promptForDiagnostics } from "../commands/captureDiagnostics" ;
30
+ import { PeekDocumentsParams , PeekDocumentsRequest } from "./lspExtensions" ;
30
31
31
32
interface SourceKitLogMessageParams extends langclient . LogMessageParams {
32
33
logName ?: string ;
@@ -559,6 +560,9 @@ export class LanguageClientManager {
559
560
} ) ( ) ,
560
561
} ,
561
562
errorHandler : new SourceKitLSPErrorHandler ( 5 ) ,
563
+ initializationOptions : {
564
+ "workspace/peekDocuments" : true , // workaround for client capability to handle `PeekDocumentsRequest`
565
+ } ,
562
566
} ;
563
567
564
568
return new langclient . LanguageClient (
@@ -616,6 +620,36 @@ export class LanguageClientManager {
616
620
this . languageClient = client ;
617
621
this . cancellationToken = new vscode . CancellationTokenSource ( ) ;
618
622
623
+ this . languageClient . onRequest (
624
+ PeekDocumentsRequest . method ,
625
+ async ( params : PeekDocumentsParams ) => {
626
+ const locations = params . locations . map ( uri => {
627
+ const location = new vscode . Location (
628
+ vscode . Uri . from ( {
629
+ scheme : "file" ,
630
+ path : new URL ( uri ) . pathname ,
631
+ } ) ,
632
+ new vscode . Position ( 0 , 0 )
633
+ ) ;
634
+
635
+ return location ;
636
+ } ) ;
637
+
638
+ await vscode . commands . executeCommand (
639
+ "editor.action.peekLocations" ,
640
+ vscode . Uri . from ( {
641
+ scheme : "file" ,
642
+ path : new URL ( params . uri ) . pathname ,
643
+ } ) ,
644
+ new vscode . Position ( params . position . line , params . position . character ) ,
645
+ locations ,
646
+ "peek"
647
+ ) ;
648
+
649
+ return { success : true } ;
650
+ }
651
+ ) ;
652
+
619
653
return this . clientReadyPromise ;
620
654
}
621
655
0 commit comments