@@ -21,7 +21,6 @@ pub use client_config::{ClientConfig, get_client_config};
2121use codestyle:: load_editorconfig;
2222use collect_files:: collect_files;
2323use emmylua_code_analysis:: { EmmyLuaAnalysis , Emmyrc , uri_to_file_path} ;
24- use log:: info;
2524use lsp_types:: InitializeParams ;
2625use tokio:: sync:: RwLock ;
2726
@@ -30,21 +29,33 @@ pub async fn initialized_handler(
3029 params : InitializeParams ,
3130 cmd_args : CmdArgs ,
3231) -> Option < ( ) > {
33- let client_id = get_client_id ( & params . client_info ) ;
34- let client_config = get_client_config ( & context , client_id ) . await ;
32+ // init locale
33+ locale :: set_ls_locale ( & params ) ;
3534 let workspace_folders = get_workspace_folders ( & params) ;
3635 let main_root: Option < & str > = match workspace_folders. first ( ) {
3736 Some ( path) => path. to_str ( ) ,
3837 None => None ,
3938 } ;
40- // init locale
41- locale:: set_ls_locale ( & params) ;
4239
4340 // init logger
4441 init_logger ( main_root, & cmd_args) ;
45- info ! ( "client_id: {:?}" , client_id) ;
42+ log:: info!( "main root: {:?}" , main_root) ;
43+
44+ let client_id = get_client_id ( & params. client_info ) ;
45+ log:: info!( "client_id: {:?}" , client_id) ;
46+
47+ {
48+ log:: info!( "set workspace folders: {:?}" , workspace_folders) ;
49+ let mut workspace_manager = context. workspace_manager . write ( ) . await ;
50+ workspace_manager. workspace_folders = workspace_folders. clone ( ) ;
51+ log:: info!( "workspace folders set" ) ;
52+ }
53+
54+ let client_config = get_client_config ( & context, client_id) . await ;
55+ log:: info!( "client_config: {:?}" , client_config) ;
56+
4657 let params_json = serde_json:: to_string_pretty ( & params) . unwrap ( ) ;
47- info ! ( "initialization_params: {}" , params_json) ;
58+ log :: info!( "initialization_params: {}" , params_json) ;
4859
4960 // init config
5061 // todo! support multi config
@@ -59,25 +70,26 @@ pub async fn initialized_handler(
5970 // init std lib
6071 init_std_lib ( context. analysis . clone ( ) , & cmd_args, emmyrc. clone ( ) ) . await ;
6172
62- let mut workspace_manager = context. workspace_manager . write ( ) . await ;
63- workspace_manager. workspace_folders = workspace_folders. clone ( ) ;
64- workspace_manager. client_config = client_config. clone ( ) ;
65- let ( include, exclude, exclude_dir) = calculate_include_and_exclude ( & emmyrc) ;
66- workspace_manager. match_file_pattern = WorkspaceFileMatcher :: new ( include, exclude, exclude_dir) ;
67- drop ( workspace_manager) ;
68- // let file_diagnostic = context.file_diagnostic.clone();
69-
7073 init_analysis (
7174 context. analysis . clone ( ) ,
7275 context. client . clone ( ) ,
7376 & context. status_bar ,
7477 workspace_folders,
75- emmyrc,
78+ emmyrc. clone ( ) ,
7679 client_id,
7780 context. file_diagnostic . clone ( ) ,
7881 )
7982 . await ;
8083
84+ {
85+ let mut workspace_manager = context. workspace_manager . write ( ) . await ;
86+ workspace_manager. client_config = client_config. clone ( ) ;
87+ let ( include, exclude, exclude_dir) = calculate_include_and_exclude ( & emmyrc) ;
88+ workspace_manager. match_file_pattern =
89+ WorkspaceFileMatcher :: new ( include, exclude, exclude_dir) ;
90+ workspace_manager. set_workspace_initialized ( ) ;
91+ log:: info!( "workspace manager initialized" ) ;
92+ }
8193 register_files_watch ( context. clone ( ) , & params. capabilities ) . await ;
8294 Some ( ( ) )
8395}
@@ -97,7 +109,7 @@ pub async fn init_analysis(
97109 mut_analysis. update_config ( emmyrc. clone ( ) ) ;
98110
99111 if let Ok ( emmyrc_json) = serde_json:: to_string_pretty ( emmyrc. as_ref ( ) ) {
100- info ! ( "current config : {}" , emmyrc_json) ;
112+ log :: info!( "current config : {}" , emmyrc_json) ;
101113 }
102114
103115 status_bar. create_progress_task ( client_id, ProgressTask :: LoadWorkspace ) ;
@@ -110,17 +122,17 @@ pub async fn init_analysis(
110122
111123 let mut workspace_folders = workspace_folders;
112124 for workspace_root in & workspace_folders {
113- info ! ( "add workspace root: {:?}" , workspace_root) ;
125+ log :: info!( "add workspace root: {:?}" , workspace_root) ;
114126 mut_analysis. add_main_workspace ( workspace_root. clone ( ) ) ;
115127 }
116128
117129 for workspace_root in & emmyrc. workspace . workspace_roots {
118- info ! ( "add workspace root: {:?}" , workspace_root) ;
130+ log :: info!( "add workspace root: {:?}" , workspace_root) ;
119131 mut_analysis. add_main_workspace ( PathBuf :: from_str ( workspace_root) . unwrap ( ) ) ;
120132 }
121133
122134 for lib in & emmyrc. workspace . library {
123- info ! ( "add library: {:?}" , lib) ;
135+ log :: info!( "add library: {:?}" , lib) ;
124136 mut_analysis. add_library_workspace ( PathBuf :: from_str ( lib) . unwrap ( ) ) ;
125137 workspace_folders. push ( PathBuf :: from_str ( lib) . unwrap ( ) ) ;
126138 }
@@ -190,10 +202,16 @@ pub async fn init_std_lib(
190202 cmd_args : & CmdArgs ,
191203 emmyrc : Arc < Emmyrc > ,
192204) {
205+ log:: info!(
206+ "initializing std lib with resources path: {:?}" ,
207+ cmd_args. resources_path
208+ ) ;
193209 let mut analysis = analysis. write ( ) . await ;
194210 if cmd_args. load_stdlib . 0 {
195211 // double update config
196212 analysis. update_config ( emmyrc) ;
197213 analysis. init_std_lib ( cmd_args. resources_path . 0 . clone ( ) ) ;
198214 }
215+
216+ log:: info!( "initialized std lib complete" ) ;
199217}
0 commit comments