@@ -18,7 +18,6 @@ export class Config {
1818 "cargo" ,
1919 "procMacro" ,
2020 "files" ,
21- "highlighting" ,
2221 "lens" , // works as lens.*
2322 ]
2423 . map ( opt => `${ this . rootSection } .${ opt } ` ) ;
@@ -79,7 +78,7 @@ export class Config {
7978 * const nullableNum = vscode
8079 * .workspace
8180 * .getConfiguration
82- * .getConfiguration("rust-analyer ")
81+ * .getConfiguration("rust-analyzer ")
8382 * .get<number | null>(path)!;
8483 *
8584 * // What happens is that type of `nullableNum` is `number` but not `null | number`:
@@ -124,15 +123,89 @@ export class Config {
124123 get hoverActions ( ) {
125124 return {
126125 enable : this . get < boolean > ( "hoverActions.enable" ) ,
127- implementations : this . get < boolean > ( "hoverActions.implementations" ) ,
128- references : this . get < boolean > ( "hoverActions.references" ) ,
129- run : this . get < boolean > ( "hoverActions.run" ) ,
130- debug : this . get < boolean > ( "hoverActions.debug" ) ,
131- gotoTypeDef : this . get < boolean > ( "hoverActions.gotoTypeDef" ) ,
126+ implementations : this . get < boolean > ( "hoverActions.implementations.enable " ) ,
127+ references : this . get < boolean > ( "hoverActions.references.enable " ) ,
128+ run : this . get < boolean > ( "hoverActions.run.enable " ) ,
129+ debug : this . get < boolean > ( "hoverActions.debug.enable " ) ,
130+ gotoTypeDef : this . get < boolean > ( "hoverActions.gotoTypeDef.enable " ) ,
132131 } ;
133132 }
134133
135134 get currentExtensionIsNightly ( ) {
136135 return this . package . releaseTag === NIGHTLY_TAG ;
137136 }
138137}
138+
139+ export function updateConfig ( config : vscode . WorkspaceConfiguration ) {
140+ const renames = [
141+ [ "assist.allowMergingIntoGlobImports" , "imports.merge.glob" , ] ,
142+ [ "assist.exprFillDefault" , "assist.expressionFillDefault" , ] ,
143+ [ "assist.importEnforceGranularity" , "imports.granularity.enforce" , ] ,
144+ [ "assist.importGranularity" , "imports.granularity.group" , ] ,
145+ [ "assist.importMergeBehavior" , "imports.granularity.group" , ] ,
146+ [ "assist.importMergeBehaviour" , "imports.granularity.group" , ] ,
147+ [ "assist.importGroup" , "imports.group.enable" , ] ,
148+ [ "assist.importPrefix" , "imports.prefix" , ] ,
149+ [ "cache.warmup" , "primeCaches.enable" , ] ,
150+ [ "cargo.loadOutDirsFromCheck" , "cargo.buildScripts.enable" , ] ,
151+ [ "cargo.runBuildScripts" , "cargo.runBuildScripts.overrideCommand" , ] ,
152+ [ "cargo.runBuildScriptsCommand" , "cargo.runBuildScripts.overrideCommand" , ] ,
153+ [ "cargo.useRustcWrapperForBuildScripts" , "cargo.runBuildScripts.useRustcWrapper" , ] ,
154+ [ "completion.snippets" , "completion.snippets.custom" , ] ,
155+ [ "diagnostics.enableExperimental" , "diagnostics.experimental.enable" , ] ,
156+ [ "experimental.procAttrMacros" , "procMacro.attributes.enable" , ] ,
157+ [ "highlighting.strings" , "semanticHighlighting.strings.enable" , ] ,
158+ [ "highlightRelated.breakPoints" , "highlightRelated.breakPoints.enable" , ] ,
159+ [ "highlightRelated.exitPoints" , "highlightRelated.exitPoints.enable" , ] ,
160+ [ "highlightRelated.yieldPoints" , "highlightRelated.yieldPoints.enable" , ] ,
161+ [ "highlightRelated.references" , "highlightRelated.references.enable" , ] ,
162+ [ "hover.documentation" , "hover.documentation.enable" , ] ,
163+ [ "hover.linksInHover" , "hover.links.enable" , ] ,
164+ [ "hoverActions.linksInHover" , "hover.links.enable" , ] ,
165+ [ "hoverActions.debug" , "hoverActions.debug.enable" , ] ,
166+ [ "hoverActions.enable" , "hoverActions.enable.enable" , ] ,
167+ [ "hoverActions.gotoTypeDef" , "hoverActions.gotoTypeDef.enable" , ] ,
168+ [ "hoverActions.implementations" , "hoverActions.implementations.enable" , ] ,
169+ [ "hoverActions.references" , "hoverActions.references.enable" , ] ,
170+ [ "hoverActions.run" , "hoverActions.run.enable" , ] ,
171+ [ "inlayHints.chainingHints" , "inlayHints.chainingHints.enable" , ] ,
172+ [ "inlayHints.closureReturnTypeHints" , "inlayHints.closureReturnTypeHints.enable" , ] ,
173+ [ "inlayHints.hideNamedConstructorHints" , "inlayHints.typeHints.hideNamedConstructorHints" , ] ,
174+ [ "inlayHints.parameterHints" , "inlayHints.parameterHints.enable" , ] ,
175+ [ "inlayHints.reborrowHints" , "inlayHints.reborrowHints.enable" , ] ,
176+ [ "inlayHints.typeHints" , "inlayHints.typeHints.enable" , ] ,
177+ [ "lruCapacity" , "lru.capacity" , ] ,
178+ [ "runnables.cargoExtraArgs" , "runnables.extraArgs" , ] ,
179+ [ "runnables.overrideCargo" , "runnables.command" , ] ,
180+ [ "rustcSource" , "rustc.source" , ] ,
181+ [ "rustfmt.enableRangeFormatting" , "rustfmt.rangeFormatting.enable" ]
182+ ] ;
183+
184+ for ( const [ oldKey , newKey ] of renames ) {
185+ const inspect = config . inspect ( oldKey ) ;
186+ if ( inspect !== undefined ) {
187+ const valMatrix = [
188+ { val : inspect . globalValue , langVal : inspect . globalLanguageValue , target : vscode . ConfigurationTarget . Global } ,
189+ { val : inspect . workspaceFolderValue , langVal : inspect . workspaceFolderLanguageValue , target : vscode . ConfigurationTarget . WorkspaceFolder } ,
190+ { val : inspect . workspaceValue , langVal : inspect . workspaceLanguageValue , target : vscode . ConfigurationTarget . Workspace }
191+ ] ;
192+ for ( const { val, langVal, target } of valMatrix ) {
193+ let pred = ( val : unknown ) => {
194+ // some of the updates we do only append "enable" or "custom"
195+ // that means on the next run we would find these again, but as objects with
196+ // these properties causing us to destroy the config
197+ // so filter those already updated ones out
198+ return val !== undefined && ! ( typeof val === "object" && val !== null && ( val . hasOwnProperty ( "enable" ) || val . hasOwnProperty ( "custom" ) ) ) ;
199+ } ;
200+ if ( pred ( val ) ) {
201+ config . update ( newKey , val , target , false ) ;
202+ config . update ( oldKey , undefined , target , false ) ;
203+ }
204+ if ( pred ( langVal ) ) {
205+ config . update ( newKey , langVal , target , true ) ;
206+ config . update ( oldKey , undefined , target , true ) ;
207+ }
208+ }
209+ }
210+ }
211+ }
0 commit comments