Skip to content

Commit 398ace0

Browse files
committed
When running against SourceKit-LSP 6.3, use a dictionary to communicate experimental client capabilities
Companion of swiftlang/sourcekit-lsp#2204
1 parent f4396f5 commit 398ace0

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/sourcekit-lsp/LanguageClientConfiguration.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import { SourceKitLSPErrorHandler } from "./LanguageClientManager";
3232
/* eslint-disable @typescript-eslint/no-explicit-any */
3333
function initializationOptions(swiftVersion: Version): any {
3434
let options: any = {
35-
"workspace/peekDocuments": true, // workaround for client capability to handle `PeekDocumentsRequest`
36-
"workspace/getReferenceDocument": true, // the client can handle URIs with scheme `sourcekit-lsp:`
3735
"textDocument/codeLens": {
3836
supportedCommands: {
3937
"swift.run": "swift.run",
@@ -42,6 +40,25 @@ function initializationOptions(swiftVersion: Version): any {
4240
},
4341
};
4442

43+
// Swift 6.3 changed the value to enable experimental client capabilities from `true` to `{ "supported": true }`
44+
// (https://github.com/swiftlang/sourcekit-lsp/pull/2204)
45+
if (swiftVersion.isGreaterThanOrEqual(new Version(6, 3, 0))) {
46+
options = {
47+
"workspace/peekDocuments": {
48+
supported: true, // workaround for client capability to handle `PeekDocumentsRequest`
49+
},
50+
"workspace/getReferenceDocument": {
51+
supported: true, // the client can handle URIs with scheme `sourcekit-lsp:`
52+
},
53+
};
54+
} else {
55+
options = {
56+
...options,
57+
"workspace/peekDocuments": true, // workaround for client capability to handle `PeekDocumentsRequest`
58+
"workspace/getReferenceDocument": true, // the client can handle URIs with scheme `sourcekit-lsp:`
59+
};
60+
}
61+
4562
// Swift 6.0.0 and later supports background indexing.
4663
// In 6.0.0 it is experimental so only "true" enables it.
4764
// In 6.1.0 it is no longer experimental, and so "auto" or "true" enables it.
@@ -58,7 +75,14 @@ function initializationOptions(swiftVersion: Version): any {
5875
};
5976
}
6077

61-
if (swiftVersion.isGreaterThanOrEqual(new Version(6, 1, 0))) {
78+
if (swiftVersion.isGreaterThanOrEqual(new Version(6, 3, 0))) {
79+
options = {
80+
...options,
81+
"window/didChangeActiveDocument": {
82+
supported: true, // the client can send `window/didChangeActiveDocument` notifications
83+
},
84+
};
85+
} else if (swiftVersion.isGreaterThanOrEqual(new Version(6, 1, 0))) {
6286
options = {
6387
...options,
6488
"window/didChangeActiveDocument": true, // the client can send `window/didChangeActiveDocument` notifications

0 commit comments

Comments
 (0)