@@ -10,7 +10,6 @@ mod rustc_wrapper;
10
10
use std:: { env, fs, path:: Path , process} ;
11
11
12
12
use lsp_server:: Connection ;
13
- use project_model:: ProjectManifest ;
14
13
use rust_analyzer:: { cli:: flags, config:: Config , from_json, Result } ;
15
14
use vfs:: AbsPathBuf ;
16
15
@@ -168,7 +167,18 @@ fn run_server() -> Result<()> {
168
167
}
169
168
} ;
170
169
171
- let mut config = Config :: new ( root_path, initialize_params. capabilities ) ;
170
+ let workspace_roots = initialize_params
171
+ . workspace_folders
172
+ . map ( |workspaces| {
173
+ workspaces
174
+ . into_iter ( )
175
+ . filter_map ( |it| it. uri . to_file_path ( ) . ok ( ) )
176
+ . filter_map ( |it| AbsPathBuf :: try_from ( it) . ok ( ) )
177
+ . collect :: < Vec < _ > > ( )
178
+ } )
179
+ . filter ( |workspaces| !workspaces. is_empty ( ) )
180
+ . unwrap_or_else ( || vec ! [ root_path. clone( ) ] ) ;
181
+ let mut config = Config :: new ( root_path, initialize_params. capabilities , workspace_roots) ;
172
182
if let Some ( json) = initialize_params. initialization_options {
173
183
if let Err ( e) = config. update ( json) {
174
184
use lsp_types:: {
@@ -202,25 +212,8 @@ fn run_server() -> Result<()> {
202
212
tracing:: info!( "Client '{}' {}" , client_info. name, client_info. version. unwrap_or_default( ) ) ;
203
213
}
204
214
205
- if config. linked_projects ( ) . is_empty ( ) && config. detached_files ( ) . is_empty ( ) {
206
- let workspace_roots = initialize_params
207
- . workspace_folders
208
- . map ( |workspaces| {
209
- workspaces
210
- . into_iter ( )
211
- . filter_map ( |it| it. uri . to_file_path ( ) . ok ( ) )
212
- . filter_map ( |it| AbsPathBuf :: try_from ( it) . ok ( ) )
213
- . collect :: < Vec < _ > > ( )
214
- } )
215
- . filter ( |workspaces| !workspaces. is_empty ( ) )
216
- . unwrap_or_else ( || vec ! [ config. root_path( ) . clone( ) ] ) ;
217
-
218
- let discovered = ProjectManifest :: discover_all ( & workspace_roots) ;
219
- tracing:: info!( "discovered projects: {:?}" , discovered) ;
220
- if discovered. is_empty ( ) {
221
- tracing:: error!( "failed to find any projects in {:?}" , workspace_roots) ;
222
- }
223
- config. discovered_projects = Some ( discovered) ;
215
+ if !config. has_linked_projects ( ) && config. detached_files ( ) . is_empty ( ) {
216
+ config. rediscover_workspaces ( ) ;
224
217
}
225
218
226
219
rust_analyzer:: main_loop ( config, connection) ?;
0 commit comments