@@ -207,25 +207,15 @@ fn run_server() -> anyhow::Result<()> {
207207
208208 tracing:: info!( "InitializeParams: {}" , initialize_params) ;
209209 let lsp_types:: InitializeParams {
210+ #[ expect( deprecated, reason = "compatibility with old clients" ) ]
210211 root_uri,
211- mut capabilities,
212- workspace_folders ,
212+ capabilities,
213+ workspace_folders_initialize_params ,
213214 initialization_options,
214215 client_info,
215216 ..
216217 } = from_json :: < lsp_types:: InitializeParams > ( "InitializeParams" , & initialize_params) ?;
217218
218- // lsp-types has a typo in the `/capabilities/workspace/diagnostics` field, its typoed as `diagnostic`
219- if let Some ( val) = initialize_params. pointer ( "/capabilities/workspace/diagnostics" )
220- && let Ok ( diag_caps) = from_json :: < lsp_types:: DiagnosticWorkspaceClientCapabilities > (
221- "DiagnosticWorkspaceClientCapabilities" ,
222- val,
223- )
224- {
225- tracing:: info!( "Patching lsp-types workspace diagnostics capabilities: {diag_caps:#?}" ) ;
226- capabilities. workspace . get_or_insert_default ( ) . diagnostic . get_or_insert ( diag_caps) ;
227- }
228-
229219 let root_path = match root_uri
230220 . and_then ( |it| it. to_file_path ( ) . ok ( ) )
231221 . map ( patch_path_prefix)
@@ -247,7 +237,14 @@ fn run_server() -> anyhow::Result<()> {
247237 ) ;
248238 }
249239
250- let workspace_roots = workspace_folders
240+ let workspace_roots = workspace_folders_initialize_params
241+ . workspace_folders
242+ . and_then ( |workspaces| match workspaces {
243+ lsp_types:: WorkspaceFolders :: WorkspaceFolderList ( workspace_folders) => {
244+ Some ( workspace_folders)
245+ }
246+ lsp_types:: WorkspaceFolders :: Null => None ,
247+ } )
251248 . map ( |workspaces| {
252249 workspaces
253250 . into_iter ( )
@@ -269,12 +266,11 @@ fn run_server() -> anyhow::Result<()> {
269266
270267 if !error_sink. is_empty ( ) {
271268 use lsp_types:: {
272- MessageType , ShowMessageParams ,
273- notification:: { Notification , ShowMessage } ,
269+ MessageType , Notification as _, ShowMessageNotification , ShowMessageParams ,
274270 } ;
275271 let not = lsp_server:: Notification :: new (
276- ShowMessage :: METHOD . to_owned ( ) ,
277- ShowMessageParams { typ : MessageType :: WARNING , message : error_sink. to_string ( ) } ,
272+ ShowMessageNotification :: METHOD . into ( ) ,
273+ ShowMessageParams { kind : MessageType :: Warning , message : error_sink. to_string ( ) } ,
278274 ) ;
279275 connection. sender . send ( lsp_server:: Message :: Notification ( not) ) . unwrap ( ) ;
280276 }
@@ -288,7 +284,6 @@ fn run_server() -> anyhow::Result<()> {
288284 name : String :: from ( "rust-analyzer" ) ,
289285 version : Some ( rust_analyzer:: version ( ) . to_string ( ) ) ,
290286 } ) ,
291- offset_encoding : None ,
292287 } ;
293288
294289 let initialize_result = serde_json:: to_value ( initialize_result) . unwrap ( ) ;
0 commit comments