@@ -19,6 +19,7 @@ use tower_lsp::lsp_types::{
1919 DocumentHighlight , DocumentHighlightKind , Location , Position , Range , SymbolInformation ,
2020 SymbolKind , TextDocumentPositionParams , TextEdit , Url , WorkspaceEdit ,
2121} ;
22+ use serde_json:: json;
2223
2324static USAGE_TYPE_RESTRICTIONS : phf:: Map < & ' static str , & [ & str ] > = phf_map ! {
2425 "Alias" => & [
@@ -309,8 +310,11 @@ impl Persistence {
309310
310311 self . workspace_path = uri. path ( ) . to_string ( ) ;
311312
312- let user_config = & params. initialization_options . as_ref ( ) . unwrap ( ) . as_object ( ) . unwrap ( ) ;
313- let allocation_type = user_config. get ( "allocationType" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
313+ let default_user_config = json ! ( { } ) ;
314+ let default_allocation_type = json ! ( "ram" ) ;
315+
316+ let user_config = & params. initialization_options . as_ref ( ) . unwrap_or ( & default_user_config) . as_object ( ) . unwrap ( ) ;
317+ let allocation_type = user_config. get ( "allocationType" ) . unwrap_or ( & default_allocation_type) . as_str ( ) . unwrap ( ) ;
314318
315319 self . index = match allocation_type {
316320 "ram" => {
@@ -354,12 +358,14 @@ impl Persistence {
354358 } ;
355359 }
356360
357- let skip_indexing_gems = !user_config. get ( "indexGems" ) . unwrap ( ) . as_bool ( ) . unwrap ( ) ;
361+ let default_index_gems = json ! ( true ) ;
362+ let skip_indexing_gems = !user_config. get ( "indexGems" ) . unwrap_or ( & default_index_gems) . as_bool ( ) . unwrap ( ) ;
358363 if skip_indexing_gems {
359364 self . gems_indexed = true ;
360365 }
361366
362- let report_diagnostics = user_config. get ( "reportDiagnostics" ) . unwrap ( ) . as_bool ( ) . unwrap ( ) ;
367+ let default_report_diagnostics = json ! ( true ) ;
368+ let report_diagnostics = user_config. get ( "reportDiagnostics" ) . unwrap_or ( & default_report_diagnostics) . as_bool ( ) . unwrap ( ) ;
363369 if !report_diagnostics {
364370 self . report_diagnostics = false ;
365371 }
0 commit comments