@@ -21,7 +21,6 @@ pub use client_config::{ClientConfig, get_client_config};
21
21
use codestyle:: load_editorconfig;
22
22
use collect_files:: collect_files;
23
23
use emmylua_code_analysis:: { EmmyLuaAnalysis , Emmyrc , uri_to_file_path} ;
24
- use log:: info;
25
24
use lsp_types:: InitializeParams ;
26
25
use tokio:: sync:: RwLock ;
27
26
@@ -30,21 +29,33 @@ pub async fn initialized_handler(
30
29
params : InitializeParams ,
31
30
cmd_args : CmdArgs ,
32
31
) -> 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 ) ;
35
34
let workspace_folders = get_workspace_folders ( & params) ;
36
35
let main_root: Option < & str > = match workspace_folders. first ( ) {
37
36
Some ( path) => path. to_str ( ) ,
38
37
None => None ,
39
38
} ;
40
- // init locale
41
- locale:: set_ls_locale ( & params) ;
42
39
43
40
// init logger
44
41
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
+
46
57
let params_json = serde_json:: to_string_pretty ( & params) . unwrap ( ) ;
47
- info ! ( "initialization_params: {}" , params_json) ;
58
+ log :: info!( "initialization_params: {}" , params_json) ;
48
59
49
60
// init config
50
61
// todo! support multi config
@@ -59,25 +70,26 @@ pub async fn initialized_handler(
59
70
// init std lib
60
71
init_std_lib ( context. analysis . clone ( ) , & cmd_args, emmyrc. clone ( ) ) . await ;
61
72
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
-
70
73
init_analysis (
71
74
context. analysis . clone ( ) ,
72
75
context. client . clone ( ) ,
73
76
& context. status_bar ,
74
77
workspace_folders,
75
- emmyrc,
78
+ emmyrc. clone ( ) ,
76
79
client_id,
77
80
context. file_diagnostic . clone ( ) ,
78
81
)
79
82
. await ;
80
83
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
+ }
81
93
register_files_watch ( context. clone ( ) , & params. capabilities ) . await ;
82
94
Some ( ( ) )
83
95
}
@@ -97,7 +109,7 @@ pub async fn init_analysis(
97
109
mut_analysis. update_config ( emmyrc. clone ( ) ) ;
98
110
99
111
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) ;
101
113
}
102
114
103
115
status_bar. create_progress_task ( client_id, ProgressTask :: LoadWorkspace ) ;
@@ -110,17 +122,17 @@ pub async fn init_analysis(
110
122
111
123
let mut workspace_folders = workspace_folders;
112
124
for workspace_root in & workspace_folders {
113
- info ! ( "add workspace root: {:?}" , workspace_root) ;
125
+ log :: info!( "add workspace root: {:?}" , workspace_root) ;
114
126
mut_analysis. add_main_workspace ( workspace_root. clone ( ) ) ;
115
127
}
116
128
117
129
for workspace_root in & emmyrc. workspace . workspace_roots {
118
- info ! ( "add workspace root: {:?}" , workspace_root) ;
130
+ log :: info!( "add workspace root: {:?}" , workspace_root) ;
119
131
mut_analysis. add_main_workspace ( PathBuf :: from_str ( workspace_root) . unwrap ( ) ) ;
120
132
}
121
133
122
134
for lib in & emmyrc. workspace . library {
123
- info ! ( "add library: {:?}" , lib) ;
135
+ log :: info!( "add library: {:?}" , lib) ;
124
136
mut_analysis. add_library_workspace ( PathBuf :: from_str ( lib) . unwrap ( ) ) ;
125
137
workspace_folders. push ( PathBuf :: from_str ( lib) . unwrap ( ) ) ;
126
138
}
@@ -190,10 +202,16 @@ pub async fn init_std_lib(
190
202
cmd_args : & CmdArgs ,
191
203
emmyrc : Arc < Emmyrc > ,
192
204
) {
205
+ log:: info!(
206
+ "initializing std lib with resources path: {:?}" ,
207
+ cmd_args. resources_path
208
+ ) ;
193
209
let mut analysis = analysis. write ( ) . await ;
194
210
if cmd_args. load_stdlib . 0 {
195
211
// double update config
196
212
analysis. update_config ( emmyrc) ;
197
213
analysis. init_std_lib ( cmd_args. resources_path . 0 . clone ( ) ) ;
198
214
}
215
+
216
+ log:: info!( "initialized std lib complete" ) ;
199
217
}
0 commit comments