Skip to content

Commit

Permalink
feat: add config and command to toggle off code lens (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellebore authored Jul 10, 2023
1 parent 3b24723 commit 60c4450
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@
"title": "Ask Sourcery",
"category": "Sourcery"
},
{
"command": "sourcery.chat.toggleCodeLens",
"title": "Toggle Code Lens for Coding Assistant",
"category": "Sourcery"
},
{
"command": "sourcery.scan.selectLanguage",
"title": "Select Language",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ import { askSourceryCommand } from "./ask-sourcery";

function createLangServer(): LanguageClient {
const token = workspace.getConfiguration("sourcery").get<string>("token");
const showCodeLens = workspace
.getConfiguration("sourcery")
.get<boolean>("codeLens");

const packageJson = extensions.getExtension("sourcery.sourcery").packageJSON;
const extensionVersion = packageJson.version;

Expand Down Expand Up @@ -76,6 +80,7 @@ function createLangServer(): LanguageClient {
editor_version: "vscode " + version,
extension_version: extensionVersion,
telemetry_enabled: env.isTelemetryEnabled,
show_code_lens: showCodeLens,
},
};

Expand Down Expand Up @@ -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"];
Expand Down

0 comments on commit 60c4450

Please sign in to comment.