Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts87
1 files changed, 80 insertions, 7 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 183521c10c..5b650e1420 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -18,7 +18,6 @@ export class Config {
"cargo",
"procMacro",
"files",
- "highlighting",
"lens", // works as lens.*
]
.map(opt => `${this.rootSection}.${opt}`);
@@ -79,7 +78,7 @@ export class Config {
* const nullableNum = vscode
* .workspace
* .getConfiguration
- * .getConfiguration("rust-analyer")
+ * .getConfiguration("rust-analyzer")
* .get<number | null>(path)!;
*
* // What happens is that type of `nullableNum` is `number` but not `null | number`:
@@ -124,11 +123,11 @@ export class Config {
get hoverActions() {
return {
enable: this.get<boolean>("hoverActions.enable"),
- implementations: this.get<boolean>("hoverActions.implementations"),
- references: this.get<boolean>("hoverActions.references"),
- run: this.get<boolean>("hoverActions.run"),
- debug: this.get<boolean>("hoverActions.debug"),
- gotoTypeDef: this.get<boolean>("hoverActions.gotoTypeDef"),
+ implementations: this.get<boolean>("hoverActions.implementations.enable"),
+ references: this.get<boolean>("hoverActions.references.enable"),
+ run: this.get<boolean>("hoverActions.run.enable"),
+ debug: this.get<boolean>("hoverActions.debug.enable"),
+ gotoTypeDef: this.get<boolean>("hoverActions.gotoTypeDef.enable"),
};
}
@@ -136,3 +135,77 @@ export class Config {
return this.package.releaseTag === NIGHTLY_TAG;
}
}
+
+export async function updateConfig(config: vscode.WorkspaceConfiguration) {
+ const renames = [
+ ["assist.allowMergingIntoGlobImports", "imports.merge.glob",],
+ ["assist.exprFillDefault", "assist.expressionFillDefault",],
+ ["assist.importEnforceGranularity", "imports.granularity.enforce",],
+ ["assist.importGranularity", "imports.granularity.group",],
+ ["assist.importMergeBehavior", "imports.granularity.group",],
+ ["assist.importMergeBehaviour", "imports.granularity.group",],
+ ["assist.importGroup", "imports.group.enable",],
+ ["assist.importPrefix", "imports.prefix",],
+ ["cache.warmup", "primeCaches.enable",],
+ ["cargo.loadOutDirsFromCheck", "cargo.buildScripts.enable",],
+ ["cargo.runBuildScripts", "cargo.runBuildScripts.overrideCommand",],
+ ["cargo.runBuildScriptsCommand", "cargo.runBuildScripts.overrideCommand",],
+ ["cargo.useRustcWrapperForBuildScripts", "cargo.runBuildScripts.useRustcWrapper",],
+ ["completion.snippets", "completion.snippets.custom",],
+ ["diagnostics.enableExperimental", "diagnostics.experimental.enable",],
+ ["experimental.procAttrMacros", "procMacro.attributes.enable",],
+ ["highlighting.strings", "semanticHighlighting.strings.enable",],
+ ["highlightRelated.breakPoints", "highlightRelated.breakPoints.enable",],
+ ["highlightRelated.exitPoints", "highlightRelated.exitPoints.enable",],
+ ["highlightRelated.yieldPoints", "highlightRelated.yieldPoints.enable",],
+ ["highlightRelated.references", "highlightRelated.references.enable",],
+ ["hover.documentation", "hover.documentation.enable",],
+ ["hover.linksInHover", "hover.links.enable",],
+ ["hoverActions.linksInHover", "hover.links.enable",],
+ ["hoverActions.debug", "hoverActions.debug.enable",],
+ ["hoverActions.enable", "hoverActions.enable.enable",],
+ ["hoverActions.gotoTypeDef", "hoverActions.gotoTypeDef.enable",],
+ ["hoverActions.implementations", "hoverActions.implementations.enable",],
+ ["hoverActions.references", "hoverActions.references.enable",],
+ ["hoverActions.run", "hoverActions.run.enable",],
+ ["inlayHints.chainingHints", "inlayHints.chainingHints.enable",],
+ ["inlayHints.closureReturnTypeHints", "inlayHints.closureReturnTypeHints.enable",],
+ ["inlayHints.hideNamedConstructorHints", "inlayHints.typeHints.hideNamedConstructorHints",],
+ ["inlayHints.parameterHints", "inlayHints.parameterHints.enable",],
+ ["inlayHints.reborrowHints", "inlayHints.reborrowHints.enable",],
+ ["inlayHints.typeHints", "inlayHints.typeHints.enable",],
+ ["lruCapacity", "lru.capacity",],
+ ["runnables.cargoExtraArgs", "runnables.extraArgs",],
+ ["runnables.overrideCargo", "runnables.command",],
+ ["rustcSource", "rustc.source",],
+ ["rustfmt.enableRangeFormatting", "rustfmt.rangeFormatting.enable"]
+ ];
+
+ for (const [oldKey, newKey] of renames) {
+ const inspect = config.inspect(oldKey);
+ if (inspect !== undefined) {
+ const valMatrix = [
+ { val: inspect.globalValue, langVal: inspect.globalLanguageValue, target: vscode.ConfigurationTarget.Global },
+ { val: inspect.workspaceFolderValue, langVal: inspect.workspaceFolderLanguageValue, target: vscode.ConfigurationTarget.WorkspaceFolder },
+ { val: inspect.workspaceValue, langVal: inspect.workspaceLanguageValue, target: vscode.ConfigurationTarget.Workspace }
+ ];
+ for (const { val, langVal, target } of valMatrix) {
+ const pred = (val: unknown) => {
+ // some of the updates we do only append "enable" or "custom"
+ // that means on the next run we would find these again, but as objects with
+ // these properties causing us to destroy the config
+ // so filter those already updated ones out
+ return val !== undefined && !(typeof val === "object" && val !== null && (val.hasOwnProperty("enable") || val.hasOwnProperty("custom")));
+ };
+ if (pred(val)) {
+ await config.update(newKey, val, target, false);
+ await config.update(oldKey, undefined, target, false);
+ }
+ if (pred(langVal)) {
+ await config.update(newKey, langVal, target, true);
+ await config.update(oldKey, undefined, target, true);
+ }
+ }
+ }
+ }
+}