Skip to content

Commit 60c4450

Browse files
authored
feat: add config and command to toggle off code lens (#188)
1 parent 3b24723 commit 60c4450

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@
234234
"title": "Ask Sourcery",
235235
"category": "Sourcery"
236236
},
237+
{
238+
"command": "sourcery.chat.toggleCodeLens",
239+
"title": "Toggle Code Lens for Coding Assistant",
240+
"category": "Sourcery"
241+
},
237242
{
238243
"command": "sourcery.scan.selectLanguage",
239244
"title": "Select Language",
@@ -359,6 +364,10 @@
359364
"command": "sourcery.chat.ask",
360365
"when": "sourcery.features.coding_assistant"
361366
},
367+
{
368+
"command": "sourcery.chat.toggleCodeLens",
369+
"when": "sourcery.features.coding_assistant"
370+
},
362371
{
363372
"command": "sourcery.scan.selectLanguage",
364373
"when": "false"
@@ -386,6 +395,11 @@
386395
"default": "",
387396
"description": "Sourcery token. You can find your token at https://sourcery.ai/dashboard"
388397
},
398+
"sourcery.codeLens": {
399+
"type": "boolean",
400+
"default": true,
401+
"description": "Show code lens for Sourcery's coding assistant."
402+
},
389403
"sourcery.ruleType.refactorings": {
390404
"type": "boolean",
391405
"default": true,

src/extension.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ import { askSourceryCommand } from "./ask-sourcery";
3838

3939
function createLangServer(): LanguageClient {
4040
const token = workspace.getConfiguration("sourcery").get<string>("token");
41+
const showCodeLens = workspace
42+
.getConfiguration("sourcery")
43+
.get<boolean>("codeLens");
44+
4145
const packageJson = extensions.getExtension("sourcery.sourcery").packageJSON;
4246
const extensionVersion = packageJson.version;
4347

@@ -76,6 +80,7 @@ function createLangServer(): LanguageClient {
7680
editor_version: "vscode " + version,
7781
extension_version: extensionVersion,
7882
telemetry_enabled: env.isTelemetryEnabled,
83+
show_code_lens: showCodeLens,
7984
},
8085
};
8186

@@ -224,6 +229,14 @@ function registerCommands(
224229
})
225230
);
226231

232+
context.subscriptions.push(
233+
commands.registerCommand("sourcery.chat.toggleCodeLens", () => {
234+
const config = vscode.workspace.getConfiguration();
235+
const currentValue = config.get("sourcery.codeLens");
236+
config.update("sourcery.codeLens", !currentValue);
237+
})
238+
);
239+
227240
context.subscriptions.push(
228241
commands.registerCommand("sourcery.scan.selectLanguage", () => {
229242
const items = ["python", "javascript"];

0 commit comments

Comments
 (0)