@@ -18,7 +18,6 @@ export class Config {
18
18
"cargo" ,
19
19
"procMacro" ,
20
20
"files" ,
21
- "highlighting" ,
22
21
"lens" , // works as lens.*
23
22
]
24
23
. map ( opt => `${ this . rootSection } .${ opt } ` ) ;
@@ -79,7 +78,7 @@ export class Config {
79
78
* const nullableNum = vscode
80
79
* .workspace
81
80
* .getConfiguration
82
- * .getConfiguration("rust-analyer ")
81
+ * .getConfiguration("rust-analyzer ")
83
82
* .get<number | null>(path)!;
84
83
*
85
84
* // What happens is that type of `nullableNum` is `number` but not `null | number`:
@@ -124,15 +123,89 @@ export class Config {
124
123
get hoverActions ( ) {
125
124
return {
126
125
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 " ) ,
132
131
} ;
133
132
}
134
133
135
134
get currentExtensionIsNightly ( ) {
136
135
return this . package . releaseTag === NIGHTLY_TAG ;
137
136
}
138
137
}
138
+
139
+ export async 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
+ const 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
+ await config . update ( newKey , val , target , false ) ;
202
+ await config . update ( oldKey , undefined , target , false ) ;
203
+ }
204
+ if ( pred ( langVal ) ) {
205
+ await config . update ( newKey , langVal , target , true ) ;
206
+ await config . update ( oldKey , undefined , target , true ) ;
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
0 commit comments