Skip to content

When running against SourceKit-LSP 6.3, use a dictionary to communicate experimental client capabilities #1715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/sourcekit-lsp/LanguageClientConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import { SourceKitLSPErrorHandler } from "./LanguageClientManager";
/* eslint-disable @typescript-eslint/no-explicit-any */
function initializationOptions(swiftVersion: Version): any {
let options: any = {
"workspace/peekDocuments": true, // workaround for client capability to handle `PeekDocumentsRequest`
"workspace/getReferenceDocument": true, // the client can handle URIs with scheme `sourcekit-lsp:`
"textDocument/codeLens": {
supportedCommands: {
"swift.run": "swift.run",
Expand All @@ -42,6 +40,25 @@ function initializationOptions(swiftVersion: Version): any {
},
};

// Swift 6.3 changed the value to enable experimental client capabilities from `true` to `{ "supported": true }`
// (https://github.com/swiftlang/sourcekit-lsp/pull/2204)
if (swiftVersion.isGreaterThanOrEqual(new Version(6, 3, 0))) {
options = {
"workspace/peekDocuments": {
supported: true, // workaround for client capability to handle `PeekDocumentsRequest`
},
"workspace/getReferenceDocument": {
supported: true, // the client can handle URIs with scheme `sourcekit-lsp:`
},
};
} else {
options = {
...options,
"workspace/peekDocuments": true, // workaround for client capability to handle `PeekDocumentsRequest`
"workspace/getReferenceDocument": true, // the client can handle URIs with scheme `sourcekit-lsp:`
};
}

// Swift 6.0.0 and later supports background indexing.
// In 6.0.0 it is experimental so only "true" enables it.
// In 6.1.0 it is no longer experimental, and so "auto" or "true" enables it.
Expand All @@ -58,7 +75,14 @@ function initializationOptions(swiftVersion: Version): any {
};
}

if (swiftVersion.isGreaterThanOrEqual(new Version(6, 1, 0))) {
if (swiftVersion.isGreaterThanOrEqual(new Version(6, 3, 0))) {
options = {
...options,
"window/didChangeActiveDocument": {
supported: true, // the client can send `window/didChangeActiveDocument` notifications
},
};
} else if (swiftVersion.isGreaterThanOrEqual(new Version(6, 1, 0))) {
options = {
...options,
"window/didChangeActiveDocument": true, // the client can send `window/didChangeActiveDocument` notifications
Expand Down
Loading