@@ -209,6 +209,70 @@ config_data! {
209209 /// Term search fuel in "units of work" for assists (Defaults to 1800).
210210 assist_termSearch_fuel: usize = 1800 ,
211211
212+
213+ /// Toggles the additional completions that automatically add imports when completed.
214+ /// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
215+ completion_autoimport_enable: bool = true ,
216+ /// Toggles the additional completions that automatically show method calls and field accesses
217+ /// with `self` prefixed to them when inside a method.
218+ completion_autoself_enable: bool = true ,
219+ /// Whether to add parenthesis and argument snippets when completing function.
220+ completion_callable_snippets: CallableCompletionDef = CallableCompletionDef :: FillArguments ,
221+ /// Whether to show full function/method signatures in completion docs.
222+ completion_fullFunctionSignatures_enable: bool = false ,
223+ /// Maximum number of completions to return. If `None`, the limit is infinite.
224+ completion_limit: Option <usize > = None ,
225+ /// Whether to show postfix snippets like `dbg`, `if`, `not`, etc.
226+ completion_postfix_enable: bool = true ,
227+ /// Enables completions of private items and fields that are defined in the current workspace even if they are not visible at the current position.
228+ completion_privateEditable_enable: bool = false ,
229+ /// Custom completion snippets.
230+ completion_snippets_custom: FxHashMap <String , SnippetDef > = serde_json:: from_str( r#"{
231+ "Arc::new": {
232+ "postfix": "arc",
233+ "body": "Arc::new(${receiver})",
234+ "requires": "std::sync::Arc",
235+ "description": "Put the expression into an `Arc`",
236+ "scope": "expr"
237+ },
238+ "Rc::new": {
239+ "postfix": "rc",
240+ "body": "Rc::new(${receiver})",
241+ "requires": "std::rc::Rc",
242+ "description": "Put the expression into an `Rc`",
243+ "scope": "expr"
244+ },
245+ "Box::pin": {
246+ "postfix": "pinbox",
247+ "body": "Box::pin(${receiver})",
248+ "requires": "std::boxed::Box",
249+ "description": "Put the expression into a pinned `Box`",
250+ "scope": "expr"
251+ },
252+ "Ok": {
253+ "postfix": "ok",
254+ "body": "Ok(${receiver})",
255+ "description": "Wrap the expression in a `Result::Ok`",
256+ "scope": "expr"
257+ },
258+ "Err": {
259+ "postfix": "err",
260+ "body": "Err(${receiver})",
261+ "description": "Wrap the expression in a `Result::Err`",
262+ "scope": "expr"
263+ },
264+ "Some": {
265+ "postfix": "some",
266+ "body": "Some(${receiver})",
267+ "description": "Wrap the expression in an `Option::Some`",
268+ "scope": "expr"
269+ }
270+ }"# ) . unwrap( ) ,
271+ /// Whether to enable term search based snippets like `Some(foo.bar().baz())`.
272+ completion_termSearch_enable: bool = false ,
273+ /// Term search fuel in "units of work" for autocompletion (Defaults to 1000).
274+ completion_termSearch_fuel: usize = 1000 ,
275+
212276 /// List of rust-analyzer diagnostics to disable.
213277 diagnostics_disabled: FxHashSet <String > = FxHashSet :: default ( ) ,
214278 /// Whether to show native rust-analyzer diagnostics.
@@ -463,68 +527,6 @@ config_data! {
463527 /// Configs that only make sense when they are set by a client. As such they can only be defined
464528 /// by setting them using client's settings (e.g `settings.json` on VS Code).
465529 client: struct ClientDefaultConfigData <- ClientConfigInput -> {
466- /// Toggles the additional completions that automatically add imports when completed.
467- /// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
468- completion_autoimport_enable: bool = true ,
469- /// Toggles the additional completions that automatically show method calls and field accesses
470- /// with `self` prefixed to them when inside a method.
471- completion_autoself_enable: bool = true ,
472- /// Whether to add parenthesis and argument snippets when completing function.
473- completion_callable_snippets: CallableCompletionDef = CallableCompletionDef :: FillArguments ,
474- /// Whether to show full function/method signatures in completion docs.
475- completion_fullFunctionSignatures_enable: bool = false ,
476- /// Maximum number of completions to return. If `None`, the limit is infinite.
477- completion_limit: Option <usize > = None ,
478- /// Whether to show postfix snippets like `dbg`, `if`, `not`, etc.
479- completion_postfix_enable: bool = true ,
480- /// Enables completions of private items and fields that are defined in the current workspace even if they are not visible at the current position.
481- completion_privateEditable_enable: bool = false ,
482- /// Custom completion snippets.
483- completion_snippets_custom: FxHashMap <String , SnippetDef > = serde_json:: from_str( r#"{
484- "Arc::new": {
485- "postfix": "arc",
486- "body": "Arc::new(${receiver})",
487- "requires": "std::sync::Arc",
488- "description": "Put the expression into an `Arc`",
489- "scope": "expr"
490- },
491- "Rc::new": {
492- "postfix": "rc",
493- "body": "Rc::new(${receiver})",
494- "requires": "std::rc::Rc",
495- "description": "Put the expression into an `Rc`",
496- "scope": "expr"
497- },
498- "Box::pin": {
499- "postfix": "pinbox",
500- "body": "Box::pin(${receiver})",
501- "requires": "std::boxed::Box",
502- "description": "Put the expression into a pinned `Box`",
503- "scope": "expr"
504- },
505- "Ok": {
506- "postfix": "ok",
507- "body": "Ok(${receiver})",
508- "description": "Wrap the expression in a `Result::Ok`",
509- "scope": "expr"
510- },
511- "Err": {
512- "postfix": "err",
513- "body": "Err(${receiver})",
514- "description": "Wrap the expression in a `Result::Err`",
515- "scope": "expr"
516- },
517- "Some": {
518- "postfix": "some",
519- "body": "Some(${receiver})",
520- "description": "Wrap the expression in an `Option::Some`",
521- "scope": "expr"
522- }
523- }"# ) . unwrap( ) ,
524- /// Whether to enable term search based snippets like `Some(foo.bar().baz())`.
525- completion_termSearch_enable: bool = false ,
526- /// Term search fuel in "units of work" for autocompletion (Defaults to 1000).
527- completion_termSearch_fuel: usize = 1000 ,
528530
529531 /// Controls file watching implementation.
530532 files_watcher: FilesWatcherDef = FilesWatcherDef :: Client ,
@@ -879,7 +881,7 @@ impl Config {
879881 // IMPORTANT : This holds as long as ` completion_snippets_custom` is declared `client`.
880882 config. snippets . clear ( ) ;
881883
882- let snips = self . completion_snippets_custom ( ) . to_owned ( ) ;
884+ let snips = self . completion_snippets_custom ( None ) . to_owned ( ) ;
883885
884886 for ( name, def) in snips. iter ( ) {
885887 if def. prefix . is_empty ( ) && def. postfix . is_empty ( ) {
@@ -1417,13 +1419,15 @@ impl Config {
14171419
14181420 pub fn completion ( & self , source_root : Option < SourceRootId > ) -> CompletionConfig {
14191421 CompletionConfig {
1420- enable_postfix_completions : self . completion_postfix_enable ( ) . to_owned ( ) ,
1421- enable_imports_on_the_fly : self . completion_autoimport_enable ( ) . to_owned ( )
1422+ enable_postfix_completions : self . completion_postfix_enable ( source_root ) . to_owned ( ) ,
1423+ enable_imports_on_the_fly : self . completion_autoimport_enable ( source_root ) . to_owned ( )
14221424 && self . caps . completion_item_edit_resolve ( ) ,
1423- enable_self_on_the_fly : self . completion_autoself_enable ( ) . to_owned ( ) ,
1424- enable_private_editable : self . completion_privateEditable_enable ( ) . to_owned ( ) ,
1425- full_function_signatures : self . completion_fullFunctionSignatures_enable ( ) . to_owned ( ) ,
1426- callable : match self . completion_callable_snippets ( ) {
1425+ enable_self_on_the_fly : self . completion_autoself_enable ( source_root) . to_owned ( ) ,
1426+ enable_private_editable : self . completion_privateEditable_enable ( source_root) . to_owned ( ) ,
1427+ full_function_signatures : self
1428+ . completion_fullFunctionSignatures_enable ( source_root)
1429+ . to_owned ( ) ,
1430+ callable : match self . completion_callable_snippets ( source_root) {
14271431 CallableCompletionDef :: FillArguments => Some ( CallableSnippets :: FillArguments ) ,
14281432 CallableCompletionDef :: AddParentheses => Some ( CallableSnippets :: AddParentheses ) ,
14291433 CallableCompletionDef :: None => None ,
@@ -1434,9 +1438,9 @@ impl Config {
14341438 prefer_prelude : self . imports_preferPrelude ( source_root) . to_owned ( ) ,
14351439 prefer_absolute : self . imports_prefixExternPrelude ( source_root) . to_owned ( ) ,
14361440 snippets : self . snippets . clone ( ) . to_vec ( ) ,
1437- limit : self . completion_limit ( ) . to_owned ( ) ,
1438- enable_term_search : self . completion_termSearch_enable ( ) . to_owned ( ) ,
1439- term_search_fuel : self . completion_termSearch_fuel ( ) . to_owned ( ) as u64 ,
1441+ limit : self . completion_limit ( source_root ) . to_owned ( ) ,
1442+ enable_term_search : self . completion_termSearch_enable ( source_root ) . to_owned ( ) ,
1443+ term_search_fuel : self . completion_termSearch_fuel ( source_root ) . to_owned ( ) as u64 ,
14401444 }
14411445 }
14421446
0 commit comments