Skip to content

Commit b090f28

Browse files
committed
Report workspace/triggerReindex server capability
If the server is configured to support background indexing then report to clients that it supports the `workspace/triggerReindex` request. This lets clients expose this functionality only if SourceKit-LSP is configured to support it.
1 parent 331ae2b commit b090f28

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,14 @@ extension SourceKitLSPServer {
10791079
? nil
10801080
: ExecuteCommandOptions(commands: builtinSwiftCommands)
10811081

1082+
var experimentalCapabilties: [String: LSPAny] = [
1083+
"workspace/tests": .dictionary(["version": .int(2)]),
1084+
"textDocument/tests": .dictionary(["version": .int(2)]),
1085+
]
1086+
if self.options.backgroundIndexingOrDefault {
1087+
experimentalCapabilties["workspace/triggerReindex"] = .dictionary(["version": .int(1)])
1088+
}
1089+
10821090
return ServerCapabilities(
10831091
textDocumentSync: .options(
10841092
TextDocumentSyncOptions(
@@ -1117,10 +1125,7 @@ extension SourceKitLSPServer {
11171125
typeHierarchyProvider: .bool(true),
11181126
semanticTokensProvider: semanticTokensOptions,
11191127
inlayHintProvider: inlayHintOptions,
1120-
experimental: .dictionary([
1121-
"workspace/tests": .dictionary(["version": .int(2)]),
1122-
"textDocument/tests": .dictionary(["version": .int(2)]),
1123-
])
1128+
experimental: .dictionary(experimentalCapabilties)
11241129
)
11251130
}
11261131

0 commit comments

Comments
 (0)