@@ -210,65 +210,6 @@ config_data! {
210210 /// Aliased as `"checkOnSave.targets"`.
211211 check_targets | checkOnSave_targets | checkOnSave_target: Option <CheckOnSaveTargets > = "null" ,
212212
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 = "\" fill_arguments\" " ,
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 > = "null" ,
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- // NOTE: Keep this list in sync with the feature docs of user snippets.
231- completion_snippets_custom: FxHashMap <String , SnippetDef > = r#"{
232- "Arc::new": {
233- "postfix": "arc",
234- "body": "Arc::new(${receiver})",
235- "requires": "std::sync::Arc",
236- "description": "Put the expression into an `Arc`",
237- "scope": "expr"
238- },
239- "Rc::new": {
240- "postfix": "rc",
241- "body": "Rc::new(${receiver})",
242- "requires": "std::rc::Rc",
243- "description": "Put the expression into an `Rc`",
244- "scope": "expr"
245- },
246- "Box::pin": {
247- "postfix": "pinbox",
248- "body": "Box::pin(${receiver})",
249- "requires": "std::boxed::Box",
250- "description": "Put the expression into a pinned `Box`",
251- "scope": "expr"
252- },
253- "Ok": {
254- "postfix": "ok",
255- "body": "Ok(${receiver})",
256- "description": "Wrap the expression in a `Result::Ok`",
257- "scope": "expr"
258- },
259- "Err": {
260- "postfix": "err",
261- "body": "Err(${receiver})",
262- "description": "Wrap the expression in a `Result::Err`",
263- "scope": "expr"
264- },
265- "Some": {
266- "postfix": "some",
267- "body": "Some(${receiver})",
268- "description": "Wrap the expression in an `Option::Some`",
269- "scope": "expr"
270- }
271- }"# ,
272213
273214 /// List of rust-analyzer diagnostics to disable.
274215 diagnostics_disabled: FxHashSet <String > = "[]" ,
@@ -460,6 +401,66 @@ config_data! {
460401
461402config_data ! {
462403 struct LocalConfigData {
404+ /// Toggles the additional completions that automatically add imports when completed.
405+ /// Note that your client must specify the `additionalTextEdits` LSP client capability to truly have this feature enabled.
406+ completion_autoimport_enable: bool = "true" ,
407+ /// Toggles the additional completions that automatically show method calls and field accesses
408+ /// with `self` prefixed to them when inside a method.
409+ completion_autoself_enable: bool = "true" ,
410+ /// Whether to add parenthesis and argument snippets when completing function.
411+ completion_callable_snippets: CallableCompletionDef = "\" fill_arguments\" " ,
412+ /// Whether to show full function/method signatures in completion docs.
413+ completion_fullFunctionSignatures_enable: bool = "false" ,
414+ /// Maximum number of completions to return. If `None`, the limit is infinite.
415+ completion_limit: Option <usize > = "null" ,
416+ /// Whether to show postfix snippets like `dbg`, `if`, `not`, etc.
417+ completion_postfix_enable: bool = "true" ,
418+ /// Enables completions of private items and fields that are defined in the current workspace even if they are not visible at the current position.
419+ completion_privateEditable_enable: bool = "false" ,
420+ /// Custom completion snippets.
421+ // NOTE: Keep this list in sync with the feature docs of user snippets.
422+ completion_snippets_custom: FxHashMap <String , SnippetDef > = r#"{
423+ "Arc::new": {
424+ "postfix": "arc",
425+ "body": "Arc::new(${receiver})",
426+ "requires": "std::sync::Arc",
427+ "description": "Put the expression into an `Arc`",
428+ "scope": "expr"
429+ },
430+ "Rc::new": {
431+ "postfix": "rc",
432+ "body": "Rc::new(${receiver})",
433+ "requires": "std::rc::Rc",
434+ "description": "Put the expression into an `Rc`",
435+ "scope": "expr"
436+ },
437+ "Box::pin": {
438+ "postfix": "pinbox",
439+ "body": "Box::pin(${receiver})",
440+ "requires": "std::boxed::Box",
441+ "description": "Put the expression into a pinned `Box`",
442+ "scope": "expr"
443+ },
444+ "Ok": {
445+ "postfix": "ok",
446+ "body": "Ok(${receiver})",
447+ "description": "Wrap the expression in a `Result::Ok`",
448+ "scope": "expr"
449+ },
450+ "Err": {
451+ "postfix": "err",
452+ "body": "Err(${receiver})",
453+ "description": "Wrap the expression in a `Result::Err`",
454+ "scope": "expr"
455+ },
456+ "Some": {
457+ "postfix": "some",
458+ "body": "Some(${receiver})",
459+ "description": "Wrap the expression in an `Option::Some`",
460+ "scope": "expr"
461+ }
462+ }"# ,
463+
463464 /// Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.
464465 highlightRelated_breakPoints_enable: bool = "true" ,
465466 /// Enables highlighting of all captures of a closure while the cursor is on the `|` or move keyword of a closure.
@@ -682,13 +683,13 @@ impl<'a> LocalConfigView<'a> {
682683
683684 pub fn completion ( & self ) -> CompletionConfig {
684685 CompletionConfig {
685- enable_postfix_completions : self . global . 0 . completion_postfix_enable ,
686- enable_imports_on_the_fly : self . global . 0 . completion_autoimport_enable
686+ enable_postfix_completions : self . local . completion_postfix_enable ,
687+ enable_imports_on_the_fly : self . local . completion_autoimport_enable
687688 && completion_item_edit_resolve ( & self . caps ) ,
688- enable_self_on_the_fly : self . global . 0 . completion_autoself_enable ,
689- enable_private_editable : self . global . 0 . completion_privateEditable_enable ,
690- full_function_signatures : self . global . 0 . completion_fullFunctionSignatures_enable ,
691- callable : match self . global . 0 . completion_callable_snippets {
689+ enable_self_on_the_fly : self . local . completion_autoself_enable ,
690+ enable_private_editable : self . local . completion_privateEditable_enable ,
691+ full_function_signatures : self . local . completion_fullFunctionSignatures_enable ,
692+ callable : match self . local . completion_callable_snippets {
692693 CallableCompletionDef :: FillArguments => Some ( CallableSnippets :: FillArguments ) ,
693694 CallableCompletionDef :: AddParentheses => Some ( CallableSnippets :: AddParentheses ) ,
694695 CallableCompletionDef :: None => None ,
@@ -706,7 +707,7 @@ impl<'a> LocalConfigView<'a> {
706707 . snippet_support?
707708 ) ) ,
708709 snippets : self . snippets . clone ( ) . to_vec ( ) ,
709- limit : self . global . 0 . completion_limit ,
710+ limit : self . local . completion_limit ,
710711 }
711712 }
712713
@@ -1182,7 +1183,7 @@ impl Config {
11821183 RootGlobalConfigData ( GlobalConfigData :: from_json ( json, & mut errors) ) ;
11831184 tracing:: debug!( "deserialized config data: {:#?}" , self . root_config. global) ;
11841185 self . snippets . clear ( ) ;
1185- for ( name, def) in self . root_config . global . 0 . completion_snippets_custom . iter ( ) {
1186+ for ( name, def) in self . root_config . local . 0 . completion_snippets_custom . iter ( ) {
11861187 if def. prefix . is_empty ( ) && def. postfix . is_empty ( ) {
11871188 continue ;
11881189 }
0 commit comments