@@ -94,10 +94,34 @@ actor ExternalBuildSystemAdapter {
94
94
private var lastRestart : Date ?
95
95
96
96
static package func projectRoot( for workspaceFolder: AbsolutePath , options: SourceKitLSPOptions ) -> AbsolutePath ? {
97
- guard localFileSystem. isFile ( workspaceFolder. appending ( component: " buildServer.json " ) ) else {
98
- return nil
97
+ var buildServerConfigLocations = [ String] ( )
98
+
99
+ #if os(Windows)
100
+ let workspacePath = workspaceFolder. pathString + " \\ .bsp "
101
+ let localAppDataPath = ProcessInfo . processInfo. environment [ " LOCALAPPDATA " ] ?? " C: \\ Users \\ Default \\ AppData \\ Local \\ bsp "
102
+ let programDataPath = ProcessInfo . processInfo. environment [ " PROGRAMDATA " ] ?? " C: \\ ProgramData \\ bsp "
103
+
104
+ buildServerConfigLocations. append ( contentsOf: [ workspacePath, localAppDataPath, programDataPath] )
105
+ #elseif os(Linux)
106
+ let workspacePath = workspaceFolder. pathString + " /bsp "
107
+ let xdgDataHomePath = ProcessInfo . processInfo. environment [ " XDG_DATA_HOME " ] ?? FileManager . default. homeDirectoryForCurrentUser. appendingPathComponent ( " .local/share/bsp " )
108
+ let xdgDataDirsPath = ProcessInfo . processInfo. environment [ " XDG_DATA_DIRS " ] ?? " /usr/local/share:/usr/share "
109
+
110
+ buildServerConfigLocations. append ( contentsOf: [ workspacePath, xdgDataHomePath, xdgDataDirsPath] )
111
+ #else
112
+ let workspacePath = workspaceFolder. pathString + " /bsp "
113
+ let libraryPath = FileManager . default. homeDirectoryForCurrentUser. appending ( components: " Library " , " Application Support " , " bsp " ) . absoluteString
114
+
115
+ buildServerConfigLocations. append ( contentsOf: [ workspacePath, libraryPath] )
116
+ #endif
117
+
118
+ for buildServerConfigLocation in buildServerConfigLocations {
119
+ guard let buildServerConfigLocation = try ? AbsolutePath ( validating: buildServerConfigLocation) else { continue }
120
+ if localFileSystem. isFile ( buildServerConfigLocation) {
121
+ return workspaceFolder
122
+ }
99
123
}
100
- return workspaceFolder
124
+ return nil
101
125
}
102
126
103
127
init (
0 commit comments