@@ -4,6 +4,7 @@ import LanguageClient
44import LanguageServerProtocol
55import Preferences
66import XPCShared
7+ import Logger
78
89public protocol CopilotAuthServiceType {
910 func checkStatus( ) async throws -> CopilotStatus
@@ -25,10 +26,12 @@ public protocol CopilotSuggestionServiceType {
2526 ) async throws -> [ CopilotCompletion ]
2627 func notifyAccepted( _ completion: CopilotCompletion ) async
2728 func notifyRejected( _ completions: [ CopilotCompletion ] ) async
29+ func openTextDocument( fileURL: URL , content: String ) async throws
2830}
2931
3032protocol CopilotLSP {
3133 func sendRequest< E: CopilotRequestType > ( _ endpoint: E ) async throws -> E . Response
34+ func sendNotification( _ notif: ClientNotification ) async throws
3235}
3336
3437public class CopilotBaseService {
@@ -57,7 +60,7 @@ public class CopilotBaseService {
5760 }
5861 let executionParams : Process . ExecutionParameters
5962 let runner = UserDefaults . shared. value ( for: \. runNodeWith)
60-
63+
6164 switch runner {
6265 case . bash:
6366 let nodePath = UserDefaults . shared. value ( for: \. nodePath)
@@ -248,6 +251,27 @@ public final class CopilotSuggestionService: CopilotBaseService, CopilotSuggesti
248251 CopilotRequest . NotifyRejected ( completionUUIDs: completions. map ( \. uuid) )
249252 )
250253 }
254+
255+ public func openTextDocument(
256+ fileURL: URL ,
257+ content: String
258+ ) async throws {
259+ let languageId = languageIdentifierFromFileURL ( fileURL)
260+ let uri = " file:// \( fileURL. path) "
261+ Logger . service. debug ( uri)
262+ try await server. sendNotification (
263+ . didOpenTextDocument(
264+ DidOpenTextDocumentParams (
265+ textDocument: . init(
266+ uri: uri,
267+ languageId: languageId. rawValue,
268+ version: 0 ,
269+ text: content
270+ )
271+ )
272+ )
273+ )
274+ }
251275}
252276
253277extension InitializingServer : CopilotLSP {
0 commit comments