@@ -99,6 +99,12 @@ public actor SourceKitLSPServer {
99
99
/// Initialization can be awaited using `waitUntilInitialized`.
100
100
private var initialized : Bool = false
101
101
102
+ /// Set to `true` after the user has opened a project that doesn't support background indexing while having background
103
+ /// indexing enabled.
104
+ ///
105
+ /// This ensures that we only inform the user about background indexing not being supported for these projects once.
106
+ private var didSendBackgroundIndexingNotSupportedNotification = false
107
+
102
108
var options : Options
103
109
104
110
let toolchainRegistry : ToolchainRegistry
@@ -916,7 +922,7 @@ extension SourceKitLSPServer {
916
922
" Created workspace at \( workspaceFolder. uri. forLogging) as \( type ( of: buildSystem) ) with project root \( projectRoot ?? " <nil> " ) "
917
923
)
918
924
919
- return try ? await Workspace (
925
+ let workspace = try ? await Workspace (
920
926
documentManager: self . documentManager,
921
927
rootUri: workspaceFolder. uri,
922
928
capabilityRegistry: capabilityRegistry,
@@ -935,6 +941,21 @@ extension SourceKitLSPServer {
935
941
self ? . indexProgressManager. indexProgressStatusDidChange ( )
936
942
}
937
943
)
944
+ if let workspace, options. indexOptions. enableBackgroundIndexing, workspace. semanticIndexManager == nil ,
945
+ !self . didSendBackgroundIndexingNotSupportedNotification
946
+ {
947
+ self . sendNotificationToClient (
948
+ ShowMessageNotification (
949
+ type: . info,
950
+ message: """
951
+ Background indexing is currently only supported for SwiftPM projects. \
952
+ For all other project types, please run a build to update the index.
953
+ """
954
+ )
955
+ )
956
+ self . didSendBackgroundIndexingNotSupportedNotification = true
957
+ }
958
+ return workspace
938
959
}
939
960
940
961
func initialize( _ req: InitializeRequest ) async throws -> InitializeResult {
0 commit comments