diff --git a/package.json b/package.json index acd4770..fb3c9ce 100644 --- a/package.json +++ b/package.json @@ -63,37 +63,39 @@ "properties": { "ruff.args": { "default": [], - "markdownDescription": "Additional command-line arguments to pass to `ruff`, e.g., `\"args\": [\"--config=/path/to/pyproject.toml\"]`. Supports a subset of Ruff's command-line arguments, ignoring those that are required to operate the LSP, like `--force-exclude` and `--verbose`.", + "markdownDescription": "Additional command-line arguments to pass to `ruff check`, e.g., `\"args\": [\"--config=/path/to/pyproject.toml\"]`. Supports a subset of Ruff's command-line arguments, ignoring those that are required to operate the LSP, like `--force-exclude` and `--verbose`.", + "markdownDeprecationMessage": "**Deprecated**: Please use `#ruff.lint.args` instead.", "items": { "type": "string" }, "scope": "resource", "type": "array" }, - "ruff.path": { + "ruff.lint.args": { "default": [], - "markdownDescription": "Path to a custom `ruff` executable, e.g., `[\"/path/to/ruff\"]`.", - "scope": "resource", + "markdownDescription": "Additional command-line arguments to pass to `ruff check`, e.g., `\"args\": [\"--config=/path/to/pyproject.toml\"]`. Supports a subset of Ruff's command-line arguments, ignoring those that are required to operate the LSP, like `--force-exclude` and `--verbose`.", "items": { "type": "string" }, + "scope": "resource", "type": "array" }, - "ruff.importStrategy": { - "default": "fromEnvironment", - "markdownDescription": "Strategy for loading the `ruff` executable. `fromEnvironment` picks up Ruff from the environment, falling back to the bundled version if needed. `useBundled` uses the version bundled with the extension.", + "ruff.run": { + "default": "onType", + "markdownDescription": "Run Ruff on every keystroke (`onType`) or on save (`onSave`).", + "markdownDeprecationMessage": "**Deprecated**: Please use `#ruff.lint.run` instead.", "enum": [ - "fromEnvironment", - "useBundled" + "onType", + "onSave" ], "enumDescriptions": [ - "Use `ruff` from environment, falling back to the bundled version if `ruff` is not found.", - "Always use the bundled version of `ruff`." + "Run Ruff on every keystroke.", + "Run Ruff on save." ], "scope": "window", "type": "string" }, - "ruff.run": { + "ruff.lint.run": { "default": "onType", "markdownDescription": "Run Ruff on every keystroke (`onType`) or on save (`onSave`).", "enum": [ @@ -107,9 +109,32 @@ "scope": "window", "type": "string" }, + "ruff.path": { + "default": [], + "markdownDescription": "Path to a custom `ruff` executable, e.g., `[\"/path/to/ruff\"]`.", + "scope": "resource", + "items": { + "type": "string" + }, + "type": "array" + }, + "ruff.importStrategy": { + "default": "fromEnvironment", + "markdownDescription": "Strategy for loading the `ruff` executable. `fromEnvironment` picks up Ruff from the environment, falling back to the bundled version if needed. `useBundled` uses the version bundled with the extension.", + "enum": [ + "fromEnvironment", + "useBundled" + ], + "enumDescriptions": [ + "Use `ruff` from environment, falling back to the bundled version if `ruff` is not found.", + "Always use the bundled version of `ruff`." + ], + "scope": "window", + "type": "string" + }, "ruff.interpreter": { "default": [], - "markdownDescription": "Path to a Python interpreter to use to run the linter server.", + "markdownDescription": "Path to a Python interpreter to use to run the LSP server.", "scope": "window", "items": { "type": "string" diff --git a/src/common/settings.ts b/src/common/settings.ts index 8be5c52..d2bf1e1 100644 --- a/src/common/settings.ts +++ b/src/common/settings.ts @@ -21,20 +21,28 @@ type CodeAction = { }; }; +type Lint = { + args?: string[]; + run?: Run; +}; + export interface ISettings { cwd: string; workspace: string; - args: string[]; path: string[]; interpreter: string[]; importStrategy: ImportStrategy; - run: Run; codeAction: CodeAction; enable: boolean; enableExperimentalFormatter: boolean; showNotifications: string; organizeImports: boolean; fixAll: boolean; + lint: Lint; + + // Deprecated settings (prefer `lint.args`, etc.). + args: string[]; + run: Run; } export function getExtensionSettings(namespace: string): Promise { @@ -86,17 +94,20 @@ export async function getWorkspaceSettings( return { cwd: workspace.uri.fsPath, workspace: workspace.uri.toString(), - args: resolveVariables(config.get("args") ?? [], workspace), path: resolveVariables(config.get("path") ?? [], workspace), interpreter: resolveVariables(interpreter, workspace), importStrategy: config.get("importStrategy") ?? "fromEnvironment", - run: config.get("run") ?? "onType", codeAction: config.get("codeAction") ?? {}, + lint: config.get("lint") ?? {}, enable: config.get("enable") ?? true, organizeImports: config.get("organizeImports") ?? true, fixAll: config.get("fixAll") ?? true, showNotifications: config.get("showNotifications") ?? "off", enableExperimentalFormatter: config.get("enableExperimentalFormatter") ?? false, + + // Deprecated settings (prefer `lint.args`, etc.). + args: resolveVariables(config.get("args") ?? [], workspace), + run: config.get("run") ?? "onType", }; } @@ -110,12 +121,11 @@ export async function getGlobalSettings(namespace: string): Promise { return { cwd: process.cwd(), workspace: process.cwd(), - args: getGlobalValue(config, "args", []), path: getGlobalValue(config, "path", []), interpreter: [], importStrategy: getGlobalValue(config, "importStrategy", "fromEnvironment"), - run: getGlobalValue(config, "run", "onType"), codeAction: getGlobalValue(config, "codeAction", {}), + lint: getGlobalValue(config, "lint", {}), enable: getGlobalValue(config, "enable", true), organizeImports: getGlobalValue(config, "organizeImports", true), fixAll: getGlobalValue(config, "fixAll", true), @@ -125,6 +135,10 @@ export async function getGlobalSettings(namespace: string): Promise { "enableExperimentalFormatter", false, ), + + // Deprecated settings (prefer `lint.args`, etc.). + args: getGlobalValue(config, "args", []), + run: getGlobalValue(config, "run", "onType"), }; } @@ -133,17 +147,20 @@ export function checkIfConfigurationChanged( namespace: string, ): boolean { const settings = [ - `${namespace}.args`, `${namespace}.codeAction`, + `${namespace}.enableExperimentalFormatter`, `${namespace}.enable`, `${namespace}.fixAll`, `${namespace}.importStrategy`, `${namespace}.interpreter`, + `${namespace}.lint`, `${namespace}.organizeImports`, `${namespace}.path`, - `${namespace}.run`, `${namespace}.showNotifications`, - `${namespace}.enableExperimentalFormatter`, + + // Deprecated settings (prefer `lint.args`, etc.). + `${namespace}.args`, + `${namespace}.run`, ]; return settings.some((s) => e.affectsConfiguration(s)); }