@@ -99,6 +99,12 @@ public actor SourceKitLSPServer {
9999 /// Initialization can be awaited using `waitUntilInitialized`.
100100 private var initialized : Bool = false
101101
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+
102108 var options : Options
103109
104110 let toolchainRegistry : ToolchainRegistry
@@ -916,7 +922,7 @@ extension SourceKitLSPServer {
916922 " Created workspace at \( workspaceFolder. uri. forLogging) as \( type ( of: buildSystem) ) with project root \( projectRoot ?? " <nil> " ) "
917923 )
918924
919- return try ? await Workspace (
925+ let workspace = try ? await Workspace (
920926 documentManager: self . documentManager,
921927 rootUri: workspaceFolder. uri,
922928 capabilityRegistry: capabilityRegistry,
@@ -935,6 +941,21 @@ extension SourceKitLSPServer {
935941 self ? . indexProgressManager. indexProgressStatusDidChange ( )
936942 }
937943 )
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
938959 }
939960
940961 func initialize( _ req: InitializeRequest ) async throws -> InitializeResult {
0 commit comments