@@ -75,6 +75,8 @@ config_data! {
7575        /// How many worker threads to handle priming caches. The default `0` means to pick automatically. 
7676:  NumThreads  = NumThreads :: Physical , 
7777
78+         /// Custom completion snippets. 
79+ :  FxHashMap <String ,  SnippetDef > = Config :: completion_snippets_default( ) , 
7880
7981
8082        /// These directories will be ignored by rust-analyzer. They are 
@@ -442,48 +444,6 @@ config_data! {
442444:  bool          = true , 
443445        /// Enables completions of private items and fields that are defined in the current workspace even if they are not visible at the current position. 
444446:  bool  = false , 
445-         /// Custom completion snippets. 
446- :  FxHashMap <String ,  SnippetDef > = serde_json:: from_str( r#"{ 
447-             "Arc::new": { 
448-                 "postfix": "arc", 
449-                 "body": "Arc::new(${receiver})", 
450-                 "requires": "std::sync::Arc", 
451-                 "description": "Put the expression into an `Arc`", 
452-                 "scope": "expr" 
453-             }, 
454-             "Rc::new": { 
455-                 "postfix": "rc", 
456-                 "body": "Rc::new(${receiver})", 
457-                 "requires": "std::rc::Rc", 
458-                 "description": "Put the expression into an `Rc`", 
459-                 "scope": "expr" 
460-             }, 
461-             "Box::pin": { 
462-                 "postfix": "pinbox", 
463-                 "body": "Box::pin(${receiver})", 
464-                 "requires": "std::boxed::Box", 
465-                 "description": "Put the expression into a pinned `Box`", 
466-                 "scope": "expr" 
467-             }, 
468-             "Ok": { 
469-                 "postfix": "ok", 
470-                 "body": "Ok(${receiver})", 
471-                 "description": "Wrap the expression in a `Result::Ok`", 
472-                 "scope": "expr" 
473-             }, 
474-             "Err": { 
475-                 "postfix": "err", 
476-                 "body": "Err(${receiver})", 
477-                 "description": "Wrap the expression in a `Result::Err`", 
478-                 "scope": "expr" 
479-             }, 
480-             "Some": { 
481-                 "postfix": "some", 
482-                 "body": "Some(${receiver})", 
483-                 "description": "Wrap the expression in an `Option::Some`", 
484-                 "scope": "expr" 
485-             } 
486-         }"# ) . unwrap( ) , 
487447        /// Whether to enable term search based snippets like `Some(foo.bar().baz())`. 
488448:  bool  = false , 
489449        /// Term search fuel in "units of work" for autocompletion (Defaults to 1000). 
@@ -893,7 +853,7 @@ impl Config {
893853                // IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`. 
894854                config. snippets . clear ( ) ; 
895855
896-                 let  snips = self . completion_snippets_custom ( None ) . to_owned ( ) ; 
856+                 let  snips = self . completion_snippets_custom ( ) . to_owned ( ) ; 
897857
898858                for  ( name,  def)  in  snips. iter ( )  { 
899859                    if  def. prefix . is_empty ( )  && def. postfix . is_empty ( )  { 
@@ -1270,7 +1230,7 @@ pub struct NotificationsConfig {
12701230    pub  cargo_toml_not_found :  bool , 
12711231} 
12721232
1273- #[ derive( Debug ,  Clone ) ]  
1233+ #[ derive( Deserialize ,   Serialize ,   Debug ,  Clone ) ]  
12741234pub  enum  RustfmtConfig  { 
12751235    Rustfmt  {  extra_args :  Vec < String > ,  enable_range_formatting :  bool  } , 
12761236    CustomCommand  {  command :  String ,  args :  Vec < String >  } , 
@@ -1902,6 +1862,53 @@ impl Config {
19021862        } 
19031863    } 
19041864
1865+     pub ( crate )  fn  completion_snippets_default ( )  -> FxHashMap < String ,  SnippetDef >  { 
1866+         serde_json:: from_str ( 
1867+             r#"{ 
1868+             "Arc::new": { 
1869+                 "postfix": "arc", 
1870+                 "body": "Arc::new(${receiver})", 
1871+                 "requires": "std::sync::Arc", 
1872+                 "description": "Put the expression into an `Arc`", 
1873+                 "scope": "expr" 
1874+             }, 
1875+             "Rc::new": { 
1876+                 "postfix": "rc", 
1877+                 "body": "Rc::new(${receiver})", 
1878+                 "requires": "std::rc::Rc", 
1879+                 "description": "Put the expression into an `Rc`", 
1880+                 "scope": "expr" 
1881+             }, 
1882+             "Box::pin": { 
1883+                 "postfix": "pinbox", 
1884+                 "body": "Box::pin(${receiver})", 
1885+                 "requires": "std::boxed::Box", 
1886+                 "description": "Put the expression into a pinned `Box`", 
1887+                 "scope": "expr" 
1888+             }, 
1889+             "Ok": { 
1890+                 "postfix": "ok", 
1891+                 "body": "Ok(${receiver})", 
1892+                 "description": "Wrap the expression in a `Result::Ok`", 
1893+                 "scope": "expr" 
1894+             }, 
1895+             "Err": { 
1896+                 "postfix": "err", 
1897+                 "body": "Err(${receiver})", 
1898+                 "description": "Wrap the expression in a `Result::Err`", 
1899+                 "scope": "expr" 
1900+             }, 
1901+             "Some": { 
1902+                 "postfix": "some", 
1903+                 "body": "Some(${receiver})", 
1904+                 "description": "Wrap the expression in an `Option::Some`", 
1905+                 "scope": "expr" 
1906+             } 
1907+         }"# , 
1908+         ) 
1909+         . unwrap ( ) 
1910+     } 
1911+ 
19051912    pub  fn  rustfmt ( & self ,  source_root_id :  Option < SourceRootId > )  -> RustfmtConfig  { 
19061913        match  & self . rustfmt_overrideCommand ( source_root_id)  { 
19071914            Some ( args)  if  !args. is_empty ( )  => { 
0 commit comments