diff --git a/package.json b/package.json index a4b230d..093f248 100644 --- a/package.json +++ b/package.json @@ -234,6 +234,11 @@ "title": "Ask Sourcery", "category": "Sourcery" }, + { + "command": "sourcery.chat.toggleCodeLens", + "title": "Toggle Sourcery Code Lens", + "category": "Sourcery" + }, { "command": "sourcery.scan.selectLanguage", "title": "Select Language", @@ -359,6 +364,10 @@ "command": "sourcery.chat.ask", "when": "sourcery.features.coding_assistant" }, + { + "command": "sourcery.chat.toggleCodeLens", + "when": "sourcery.features.coding_assistant" + }, { "command": "sourcery.scan.selectLanguage", "when": "false" @@ -386,6 +395,11 @@ "default": "", "description": "Sourcery token. You can find your token at https://sourcery.ai/dashboard" }, + "sourcery.codeLens": { + "type": "boolean", + "default": true, + "description": "Show code lens for Sourcery's coding assistant." + }, "sourcery.ruleType.refactorings": { "type": "boolean", "default": true, diff --git a/src/extension.ts b/src/extension.ts index 59ca9e0..666827d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -38,6 +38,10 @@ import { askSourceryCommand } from "./ask-sourcery"; function createLangServer(): LanguageClient { const token = workspace.getConfiguration("sourcery").get("token"); + const showCodeLens = workspace + .getConfiguration("sourcery") + .get("codeLens"); + const packageJson = extensions.getExtension("sourcery.sourcery").packageJSON; const extensionVersion = packageJson.version; @@ -76,6 +80,7 @@ function createLangServer(): LanguageClient { editor_version: "vscode " + version, extension_version: extensionVersion, telemetry_enabled: env.isTelemetryEnabled, + show_code_lens: showCodeLens, }, }; @@ -224,6 +229,14 @@ function registerCommands( }) ); + context.subscriptions.push( + commands.registerCommand("sourcery.chat.toggleCodeLens", () => { + const config = vscode.workspace.getConfiguration(); + const currentValue = config.get("sourcery.codeLens"); + config.update("sourcery.codeLens", !currentValue); + }) + ); + context.subscriptions.push( commands.registerCommand("sourcery.scan.selectLanguage", () => { const items = ["python", "javascript"];