From ea7ec41064bce9b9150d9e31d2a908ff35271cc3 Mon Sep 17 00:00:00 2001 From: LU XIANGRUI <1078666705@qq.com> Date: Tue, 24 Nov 2026 06:53:51 +0900 Subject: [PATCH] feat(python): optimize imports with Ruff's CLI without a Ruff configuration (#5373) Optimize Imports in Python came only from the Ruff language server, which starts only below a Ruff configuration, so in other projects it said "Optimize imports is not available" and the Optimize imports options on save, before commit and in Code Cleanup did nothing. When no server offers `source.organizeImports` for a Python file, the IDE now runs `ruff check --extend-select I --fixable I,F401 --fix --exit-zero` on the unsaved text and offers the result as the organize-imports action, for the editor and for the MCP tools' organize-imports step alike. Imports are sorted; unused ones are removed where the project's Ruff rules check F401 (Ruff's defaults do; an `ignore` or `select` without it keeps them). It reads the project's Ruff settings or the configured Ruff configuration directory. Ruff comes from the file's project environment first (`.venv/bin/ruff`), as the Ruff language server does, then the IDE's copy and `PATH`. Without Ruff the action is disabled with "Install Ruff to optimize imports in Python files". Projects with a Ruff configuration keep using the Ruff server, which only sorts. The first commit (Ruff from the project environment for Reformat Code too) answers a review comment on #5372, which was merged before it landed there. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com> --- crates/ide-host/src/formatter.rs | 95 ++++++++++-- crates/ide-host/src/mcp/edit/format.rs | 11 +- crates/ide-host/src/ops/lsp.rs | 203 ++++++++++++++++++++++++- crates/ide-tools/src/formatter.rs | 48 +++++- docs/en/languages/python.mdx | 2 + docs/zh/languages/python.mdx | 2 + src/features/settings/pages/tools.tsx | 2 +- src/platform/locales/text/en.json | 3 + src/platform/locales/text/es.json | 1 - src/platform/locales/text/fr.json | 1 - src/platform/locales/text/ko.json | 1 - src/platform/locales/text/pl.json | 1 - src/platform/locales/text/pt.json | 1 - src/platform/locales/text/tr.json | 1 - src/platform/locales/text/zh-TW.json | 1 - src/platform/locales/text/zh.json | 4 +- 16 files changed, 349 insertions(+), 28 deletions(-) diff --git a/crates/ide-host/src/formatter.rs b/crates/ide-host/src/formatter.rs index 921b1dd1a..65d92d5c9 100644 --- a/crates/ide-host/src/formatter.rs +++ b/crates/ide-host/src/formatter.rs @@ -3,7 +3,9 @@ use crate::Host; use ide_core::event::NotifyLevel; use ide_core::settings::{BIOME_LANGUAGES, ExternalFormatter, LanguagesSettings, Settings}; -use ide_core::{ChangeSet, DocId, IdeError, IdeEvent, IdeResult, IpcPath, LanguageId, Pos, Range, TextEdit}; +use ide_core::{ + CancellationToken, ChangeSet, DocId, IdeError, IdeEvent, IdeResult, IpcPath, LanguageId, Pos, Range, TextEdit, +}; use ide_language::{LanguageConfig, PhpAlignment, Syntax}; use ide_lsp::types::FormatOptions; use ide_tools::{Tools, formatter}; @@ -29,6 +31,16 @@ fn biome_formats(file: &Path) -> bool { } } +/// `tool` installed in the environment of the interpreter nearest to `near` (`svc/.venv/bin/ruff`, +/// or `Scripts` in conda and pixi environments on Windows). A project that pins its own Ruff +/// formats with it, as its language server runs it, before the IDE's copy. +fn interpreter_tool(root: &Path, near: Option<&Path>, settings: &Settings, tool: &str) -> Option { + let python = ide_sdk::apply::python_interpreter_near(root, near, settings)?; + let dir = python.parent()?; + let exe = if cfg!(windows) { format!("{tool}.exe") } else { tool.to_owned() }; + [dir.join(&exe), dir.join("Scripts").join(&exe)].into_iter().find(|p| p.is_file()) +} + fn supports_external_format(language: &LanguageConfig, tool: ExternalFormatter) -> bool { match language.formatter.as_ref().map(|f| f.tool.as_str()) { Some("prettier") if tool == ExternalFormatter::Biome => BIOME_LANGUAGES.contains(&language.id.as_str()), @@ -408,7 +420,14 @@ async fn provider_edits( let config = language.and_then(|l| l.formatter).expect("external_tool selects languages with a formatter"); let tool = selected.name(); let name = formatter::display_name(tool); - let custom = ide_sdk::apply::setting_path(&project.root, &tool_settings.path); + let mut custom = ide_sdk::apply::setting_path(&project.root, &tool_settings.path); + if custom.is_none() && selected == ExternalFormatter::Ruff { + let (root, near, settings) = + (project.root.clone(), snap.path.parent().map(Path::to_path_buf), settings.clone()); + custom = tokio::task::spawn_blocking(move || interpreter_tool(&root, near.as_deref(), &settings, "ruff")) + .await + .map_err(|e| IdeError::internal(e.to_string()))?; + } let tools = Tools::new(&host.local_data_dir); let whole_selection = range.is_some() && !formatter::supports_range(tool, &config); let project_root = project.root.clone(); @@ -434,15 +453,7 @@ async fn provider_edits( config_file.as_deref(), )); let formatted = formatter::run(tool, command, &snap.text, &Default::default())?; - Ok(text - .diff(&formatted) - .changes - .into_iter() - .map(|c| TextEdit { - range: Range::new(text.offset_to_pos(c.from), text.offset_to_pos(c.to)), - new_text: c.insert, - }) - .collect()) + Ok(diff_edits(&text, &formatted)) }) .await .map_err(|e| IdeError::internal(e.to_string()))?; @@ -458,9 +469,71 @@ async fn provider_edits( edits.map(Some).map_err(|e| e.with_tool(tool)) } +/// The edits that turn `text` into `formatted`, one per changed region. +fn diff_edits(text: &ide_text::Document, formatted: &str) -> Vec { + text.diff(formatted) + .changes + .into_iter() + .map(|c| TextEdit { + range: Range::new(text.offset_to_pos(c.from), text.offset_to_pos(c.to)), + new_text: c.insert, + }) + .collect() +} + +/// Optimize Imports for a Python document no language server organizes (the Ruff server starts +/// only below a Ruff configuration): Ruff's CLI removes the unused imports and sorts the rest, with +/// the project's Ruff settings when there are any. `None` for other documents and untrusted projects. +pub async fn python_import_edits( + host: &Host, + window: &str, + doc: DocId, + cancel: CancellationToken, +) -> IdeResult)>> { + let project = host.project(window)?; + let snap = project.documents.snapshot(doc)?; + if snap.language.as_str() != "python" || snap.read_only || project.require_trust().is_err() { + return Ok(None); + } + let settings = project.settings.effective(); + let custom = ide_sdk::apply::setting_path(&project.root, &settings.languages.ruff.path); + let configured = settings.languages.ruff.configuration_directory.clone(); + let root = project.root.clone(); + let tools = Tools::new(&host.local_data_dir); + tokio::task::spawn_blocking(move || { + let config_file = ide_sdk::apply::ruff_configuration(&root, &configured)?; + let custom = custom.or_else(|| interpreter_tool(&root, snap.path.parent(), &settings, "ruff")); + let mut command = tools.formatter_command("ruff", &snap.path, custom.as_deref())?; + if let Some(dir) = snap.path.parent() { + command.current_dir(dir); + } + command.args(formatter::ruff_organize_imports_arguments(&snap.path, config_file.as_deref())); + let fixed = formatter::run("ruff", command, &snap.text, &cancel)?; + Ok(Some((snap.path, diff_edits(&ide_text::Document::new(&snap.text), &fixed)))) + }) + .await + .map_err(|e| IdeError::internal(e.to_string()))? +} + #[cfg(test)] mod tests { use super::*; + + #[test] + fn ruff_comes_from_the_environment_of_the_files_own_project() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path(); + let bin = root.join(if cfg!(windows) { "svc/.venv/Scripts" } else { "svc/.venv/bin" }); + std::fs::create_dir_all(&bin).unwrap(); + let exe = |name: &str| if cfg!(windows) { format!("{name}.exe") } else { name.to_owned() }; + std::fs::write(bin.join(exe("python")), "").unwrap(); + std::fs::write(root.join("svc/.venv/pyvenv.cfg"), "").unwrap(); + let settings = Settings::default(); + let near = root.join("svc/src"); + assert_eq!(interpreter_tool(root, Some(&near), &settings, "ruff"), None); + std::fs::write(bin.join(exe("ruff")), "").unwrap(); + assert_eq!(interpreter_tool(root, Some(&near), &settings, "ruff"), Some(bin.join(exe("ruff")))); + } use ExternalFormatter::{Biome, Oxfmt, Prettier, Ruff}; use ide_core::LanguageId; use ide_language::LanguageRegistry; diff --git a/crates/ide-host/src/mcp/edit/format.rs b/crates/ide-host/src/mcp/edit/format.rs index 9a084b7bd..3c6add16b 100644 --- a/crates/ide-host/src/mcp/edit/format.rs +++ b/crates/ide-host/src/mcp/edit/format.rs @@ -10,6 +10,7 @@ use super::diff::{ChangedFileText, MAX_DIFF_LINES, build_unified_diff}; use super::{edits_for, open_document, requested_files, whole_range}; use crate::mcp::tool::{Call, Output, Param, ParamType, Tool}; +use crate::ops::lsp::RUFF_ORGANIZE_IMPORTS; use ide_core::{DocId, IdeError, IdeResult}; use std::path::Path; @@ -157,7 +158,7 @@ async fn format(call: &Call, doc: DocId, info: &ide_workspace::DocumentInfo) -> .await } -/// Runs the `source.organizeImports` code action of the document's language server. +/// Runs the document's `source.organizeImports` code action, including the host's Ruff fallback. /// Nothing offered: nothing to do, unless the server says it has no such action at all. pub(super) async fn organize_imports(call: &Call, doc: DocId, path: &Path) -> IdeResult<()> { let host = call.host(); @@ -173,12 +174,20 @@ pub(super) async fn organize_imports(call: &Call, doc: DocId, path: &Path) -> Id } }; let organizes = |kind: &str| kind == ORGANIZE_IMPORTS || kind.starts_with("source.organizeImports."); + let ruff_unavailable = query + .actions + .iter() + .find(|a| a.kind.as_deref() == Some(RUFF_ORGANIZE_IMPORTS)) + .and_then(|a| a.disabled_reason.clone()); let action = query .actions .into_iter() .filter(|a| a.disabled_reason.is_none() && a.kind.as_deref().is_some_and(organizes)) .max_by_key(|a| a.is_preferred); let Some(action) = action else { + if let Some(reason) = ruff_unavailable { + return Err(IdeError::unavailable(reason)); + } let offered = query.advertised_kinds.is_none_or(|kinds| kinds.iter().any(|k| k == "source" || organizes(k))); return if offered { Ok(()) diff --git a/crates/ide-host/src/ops/lsp.rs b/crates/ide-host/src/ops/lsp.rs index d1c05f624..167495b8b 100644 --- a/crates/ide-host/src/ops/lsp.rs +++ b/crates/ide-host/src/ops/lsp.rs @@ -3,7 +3,9 @@ use crate::Host; use crate::plugins::{ProviderKind, editor_providers_for as editor_providers}; use ide_command::command; use ide_core::error::ErrorKind; -use ide_core::{DocId, IdeError, IdeResult, Location, Pos, Range, RequestId, ServerId, TextEdit, WorkspaceEdit}; +use ide_core::{ + CancellationToken, DocId, IdeError, IdeResult, Location, Pos, Range, RequestId, ServerId, TextEdit, WorkspaceEdit, +}; use ide_lsp::types::*; use ide_plugin::ProviderDocument; use std::path::Path; @@ -150,7 +152,7 @@ fn merge_language_highlights( server } -/// Items from plugins carry no server: commands don't apply, and a code +/// Items from plugins (and the host's own Ruff Optimize Imports) carry no server: commands don't apply, and a code /// action is resolved by the plugin named in its `data` ([`PluginActionRef`]). const PLUGIN_SERVER: ServerId = ServerId(0); @@ -909,6 +911,7 @@ pub async fn lsp_code_actions( let target = position_document(host, window, doc, range.start).await?; let range = project.lsp.injected_request_range(target, range); let result = project.lsp.code_actions(target, range, only.clone()).await; + let result = with_ruff_organize_imports(host, window, doc, &only, result, CancellationToken::new()).await; let plugin_actions = match plugin_providers(host, window, doc, ProviderKind::CodeActions) { Some((plugins, d)) => plugin_call(move || plugins.provide_code_actions(&d, range)).await.unwrap_or_default(), None => Vec::new(), @@ -931,6 +934,76 @@ pub async fn lsp_code_actions( prepare_actions(project, doc, version, actions).await } +const ORGANIZE_IMPORTS: &str = "source.organizeImports"; +pub(crate) const RUFF_ORGANIZE_IMPORTS: &str = "source.organizeImports.ruff"; + +/// `result` and, when organize imports is asked for and no server offers it, Ruff's Optimize +/// Imports for a Python file: for the editor and for the MCP tools alike. +async fn with_ruff_organize_imports( + host: &Host, + window: &str, + doc: DocId, + only: &[String], + result: IdeResult>, + cancel: CancellationToken, +) -> IdeResult> { + if cancel.is_cancelled() { + return Err(IdeError::cancelled()); + } + if !only.iter().any(|k| k == ORGANIZE_IMPORTS) || result.as_ref().is_ok_and(|a| a.iter().any(organizes_imports)) { + return result; + } + // A missing provider permits a fallback. Stale, invalid and cancelled requests must still fail. + if result.as_ref().is_err_and(|e| !matches!(e.kind, ErrorKind::NotFound | ErrorKind::Unavailable)) { + return result; + } + match ruff_organize_imports(host, window, doc, cancel).await? { + Some(action) => { + let mut actions = result.unwrap_or_default(); + actions.push(action); + Ok(actions) + } + None => result, + } +} + +fn organizes_imports(action: &CodeAction) -> bool { + action.kind.as_deref().is_some_and(|k| k == ORGANIZE_IMPORTS || k.starts_with("source.organizeImports.")) +} + +/// Optimize Imports with Ruff's CLI for a Python file no language server organizes; a missing Ruff +/// is a disabled action that says so. Like a plugin's, the action carries its edit and is applied as is. +async fn ruff_organize_imports( + host: &Host, + window: &str, + doc: DocId, + cancel: CancellationToken, +) -> IdeResult> { + let (edit, disabled_reason) = match crate::formatter::python_import_edits(host, window, doc, cancel).await { + Ok(None) => return Ok(None), + Ok(Some((path, edits))) => { + let files = vec![ide_core::FileEdit::Edit { path, edits, version: None }]; + (Some(WorkspaceEdit { files, preconditions: Vec::new() }), None) + } + Err(e) if matches!(e.data, Some(ide_core::error::ErrorData::Tool { missing: true, .. })) => { + (None, Some("Install Ruff to optimize imports in Python files".to_owned())) + } + Err(e) => return Err(e), + }; + Ok(Some(CodeAction { + title: "Optimize Imports (Ruff)".into(), + diagnostics: Vec::new(), + original_diagnostics: None, + kind: Some(RUFF_ORGANIZE_IMPORTS.into()), + is_preferred: true, + disabled_reason, + edit, + command: None, + data: None, + server: PLUGIN_SERVER, + })) +} + /// Where a plugin's code action may change or open files: the project root and its content /// roots (a group's members, extra Project Structure folders), never git's own files. fn plugin_edit_roots(project: &crate::Project) -> Vec { @@ -1063,11 +1136,19 @@ pub async fn lsp_code_action_query( let version = blocking(move || documents.version(doc)).await?; let (target, cancel) = begin_position_request(host, window, request, doc, range.start).await?; let range = project.lsp.injected_request_range(target, range); - let result = project.lsp.code_action_query(target, range, only, cancel).await; + let result = async { + let result = project.lsp.code_action_query(target, range, only.clone(), cancel.clone()).await; + let (actions, advertised_kinds) = match result { + Ok(query) => (Ok(query.actions), query.advertised_kinds), + Err(e) => (Err(e), None), + }; + let actions = with_ruff_organize_imports(host, window, doc, &only, actions, cancel).await?; + let actions = prepare_actions(project, doc, version, actions).await?; + Ok(CodeActionQuery { actions, advertised_kinds }) + } + .await; host.end_request(request); - let mut result = result?; - result.actions = prepare_actions(project, doc, version, result.actions).await?; - Ok(result) + result } /// Resolves a code action's edit without applying it (intention preview). @@ -2126,6 +2207,116 @@ pub fn plugin_formatters() -> IdeResult CodeAction { + CodeAction { + title: String::new(), + diagnostics: Vec::new(), + original_diagnostics: None, + kind: None, + is_preferred: false, + disabled_reason: None, + edit: None, + command: None, + data: None, + server: ServerId(7), + } + } + #[test] fn language_features_merge_without_overwriting_lsp_ranges_or_masking_errors() { use super::*; diff --git a/crates/ide-tools/src/formatter.rs b/crates/ide-tools/src/formatter.rs index 39016f5f8..a304c6111 100644 --- a/crates/ide-tools/src/formatter.rs +++ b/crates/ide-tools/src/formatter.rs @@ -87,7 +87,8 @@ impl Tools { self.exe_in(&crate::managed_bin_dir(&self.root, spec, self.platform)?, spec.commands[0]) } - /// Explicit executable/script, then the nearest project package, then managed tools and PATH. + /// Explicit executable/script (for Ruff, also the project environment's copy), then the nearest + /// project package, then managed tools and PATH. pub fn formatter_command(&self, tool: &str, file: &Path, custom: Option<&Path>) -> IdeResult { self.resolve_formatter_command(tool, file, custom).map_err(|e| e.with_tool(tool)) } @@ -200,6 +201,23 @@ pub fn arguments( args } +/// `ruff check` that sorts the imports (I) of the text on stdin and removes the unused ones (F401) +/// and prints the result, for Optimize Imports where the Ruff server isn't running. Only those two +/// are fixed, and F401 only where the project's rules check it (it is in Ruff's defaults; an +/// `ignore` or `select` without it keeps the imports). Fixes that remain (unsafe ones, such as +/// re-exports in `__init__.py`) are not errors. +pub fn ruff_organize_imports_arguments(file: &Path, config_file: Option<&Path>) -> Vec { + let mut args: Vec = + ["check", "--extend-select", "I", "--fixable", "I,F401", "--fix", "--exit-zero", "--quiet"] + .map(OsString::from) + .into(); + if let Some(config_file) = config_file { + args.extend(["--config".into(), config_file.as_os_str().to_owned()]); + } + args.extend(["--stdin-filename".into(), file.as_os_str().to_owned(), "-".into()]); + args +} + impl Tools { /// `php vendor/bin/php-cs-fixer fix` of `target` with the project's configuration, from the /// configuration's folder; `php` is the interpreter chosen in the settings, else the one on `PATH`. @@ -425,4 +443,32 @@ mod tests { assert!(supports_range("ruff", &config)); assert!(!args.iter().any(|arg| arg == "--stdin-filepath")); } + + #[test] + fn ruff_organizes_imports_of_stdin_without_failing_on_what_it_cannot_fix() { + let file = Path::new("/project/src/example.py"); + let args = |config: Option<&Path>| -> Vec { + ruff_organize_imports_arguments(file, config) + .into_iter() + .map(|a| a.to_string_lossy().into_owned()) + .collect() + }; + assert_eq!( + args(None), + [ + "check", + "--extend-select", + "I", + "--fixable", + "I,F401", + "--fix", + "--exit-zero", + "--quiet", + "--stdin-filename", + "/project/src/example.py", + "-" + ] + ); + assert_eq!(args(Some(Path::new("/shared/ruff.toml")))[8..10], ["--config", "/shared/ruff.toml"]); + } } diff --git a/docs/en/languages/python.mdx b/docs/en/languages/python.mdx index 4cefff509..b8bafa6c7 100644 --- a/docs/en/languages/python.mdx +++ b/docs/en/languages/python.mdx @@ -94,6 +94,8 @@ Other options on the page: **Reformat Code** (`⌘⌥L` / `Ctrl+Alt+L`) uses Ruff. In **Settings › Languages & Frameworks › Ruff** you can set the Ruff path, a configuration directory, the **Formatting provider** (**Automatic (language server first)** or Ruff), and **Run on save**. Without a configuration directory, Ruff reads the nearest `pyproject.toml` (`[tool.ruff]`), `ruff.toml` or `.ruff.toml`. +**Optimize Imports** (`⌃⌥O` / `Ctrl+Alt+O`) sorts the imports. Below a Ruff configuration the Ruff server does it and leaves unused imports alone (Ruff's fix-all removes them). Elsewhere the IDE runs `ruff check --extend-select I --fixable I,F401 --fix` on the file, which also removes unused imports unless your Ruff rules leave out F401; Ruff must be installed. The same goes for Optimize imports on save, before commit and in Code Cleanup. + **Rearrange Code** (Find Action, or the Code menu) orders the methods of every class in the file: `__new__`, `__init__` and `__post_init__`, other dunder methods, public methods, `_protected`, then `__private` ones, each group in its original order. The docstring and class attributes before the first method stay put; a method moves with its decorators and the comment lines directly above it, and definitions sharing a name (a property and its setter, `@overload` stubs) move together. A class is left as it is when moving could change it: other statements, standalone comments or `# region` / `# fmt: off` markers among its methods, or a decorator, default value or annotation that names another of its methods. Files with syntax errors are not rearranged. ## Run and test diff --git a/docs/zh/languages/python.mdx b/docs/zh/languages/python.mdx index 66d9cff28..0dc61d571 100644 --- a/docs/zh/languages/python.mdx +++ b/docs/zh/languages/python.mdx @@ -94,6 +94,8 @@ Ruff 只为位于 Ruff 配置之下的文件启动:`ruff.toml`、`.ruff.toml` **重新格式化代码**(`⌘⌥L` / `Ctrl+Alt+L`)使用 Ruff。在 **设置 › 语言和框架 › Ruff** 中可以设置 Ruff 路径、配置目录、**格式化工具**(**自动(优先语言服务器)** 或 Ruff)以及 **保存时运行**。不指定配置目录时,Ruff 读取最近的 `pyproject.toml`(`[tool.ruff]`)、`ruff.toml` 或 `.ruff.toml`。 +**优化导入**(`⌃⌥O` / `Ctrl+Alt+O`)对导入排序。在 Ruff 配置所在目录及其子目录中由 Ruff 服务器完成,未使用的导入保持不变(由 Ruff 的一键修复删除)。其他位置由 IDE 对文件运行 `ruff check --extend-select I --fixable I,F401 --fix`,除非 Ruff 规则不包含 F401,否则同时删除未使用的导入;需要安装 Ruff。保存时、提交前和代码清理中的优化导入也是如此。 + **重新排列代码**(在查找操作或代码菜单中)对文件中每个类的方法排序:`__new__`、`__init__` 和 `__post_init__`,其他双下划线方法,公开方法,`_受保护` 方法,最后是 `__私有` 方法;同组内保持原有顺序。第一个方法之前的文档字符串和类属性不动;方法连同装饰器和紧贴其上方的注释行一起移动,同名定义(property 及其 setter、`@overload` 声明)一起移动。移动可能改变类的行为时,类保持不变:方法之间夹有其他语句、独立注释或 `# region` / `# fmt: off` 标记,或者装饰器、默认值、类型注解引用了本类的其他方法。有语法错误的文件不会重新排列。 ## 运行与测试 diff --git a/src/features/settings/pages/tools.tsx b/src/features/settings/pages/tools.tsx index 9dd83ba0d..eae1159f2 100644 --- a/src/features/settings/pages/tools.tsx +++ b/src/features/settings/pages/tools.tsx @@ -359,7 +359,7 @@ const SAVE_ACTIONS = [ { k: "actionsOnSave.optimizeImports", label: "Optimize imports", - hint: "Runs the language server's Organize Imports action.", + hint: "Uses the language server or a tool such as Ruff to organize imports.", }, { k: "actionsOnSave.cleanup", diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 8b32c6b8d..b87816408 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -3748,6 +3748,9 @@ "Next Columns": "Next Columns", "View Options": "View Options", "Visible columns": "Visible columns", + "Install Ruff to optimize imports in Python files": "Install Ruff to optimize imports in Python files", + "Optimize Imports (Ruff)": "Optimize Imports (Ruff)", + "Uses the language server or a tool such as Ruff to organize imports.": "Uses the language server or a tool such as Ruff to organize imports.", "Pipenv Environment": "Pipenv Environment", "Install packages from Pipfile": "Install packages from Pipfile", "Runs “pipenv --python ” in the project, which writes a Pipfile (from requirements.txt if there is one) when the project has none. Pipenv chooses where to store the environment and reuses an existing one.": "Runs “pipenv --python ” in the project, which writes a Pipfile (from requirements.txt if there is one) when the project has none. Pipenv chooses where to store the environment and reuses an existing one.", diff --git a/src/platform/locales/text/es.json b/src/platform/locales/text/es.json index 947b091b1..303eeb92c 100644 --- a/src/platform/locales/text/es.json +++ b/src/platform/locales/text/es.json @@ -1880,7 +1880,6 @@ "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "Ejecuta Optimizar importaciones cuando el archivo no tiene errores, a menos que modifique la línea del cursor.", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "Ejecuta scripts de npm y servidores de lenguaje basados en Node (vtsls, eslint, pyright…).", "Runs sync, builds and Maven run configurations. A chosen home is used instead of the project's mvnw. Bypassed while the Maven daemon is enabled.": "Ejecuta sincronización, compilaciones y configuraciones de ejecución de Maven. Se usa el directorio elegido en lugar del mvnw del proyecto. Se omite mientras el daemon de Maven esté habilitado.", - "Runs the language server's Organize Imports action.": "Ejecuta la acción Organizar importaciones del servidor de lenguaje.", "Runs the language server's formatter before an explicit save (Actions on Save).": "Ejecuta el formateador del servidor de lenguaje antes de un guardado explícito (Acciones al guardar).", "Search history": "Historial de búsqueda", "Search history ({previous} / {next})": "Historial de búsqueda ({previous} / {next})", diff --git a/src/platform/locales/text/fr.json b/src/platform/locales/text/fr.json index 4b9ac5b2a..dccd4e41c 100644 --- a/src/platform/locales/text/fr.json +++ b/src/platform/locales/text/fr.json @@ -1796,7 +1796,6 @@ "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "Exécute Optimiser les imports lorsque le fichier ne contient pas d'erreur, sauf si cela modifie la ligne du curseur.", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "Exécute les scripts npm et les serveurs de langage basés sur Node (vtsls, eslint, pyright…).", "Runs sync, builds and Maven run configurations. A chosen home is used instead of the project's mvnw. Bypassed while the Maven daemon is enabled.": "Exécute la synchronisation, les builds et les configurations d'exécution Maven. Un répertoire choisi remplace le mvnw du projet. Ignoré lorsque le démon Maven est activé.", - "Runs the language server's Organize Imports action.": "Exécute l'action Organiser les imports du serveur de langage.", "Runs the language server's formatter before an explicit save (Actions on Save).": "Exécute le formateur du serveur de langage avant un enregistrement explicite (Actions à l'enregistrement).", "Search history": "Historique de recherche", "Search history ({previous} / {next})": "Historique de recherche ({previous} / {next})", diff --git a/src/platform/locales/text/ko.json b/src/platform/locales/text/ko.json index dfa030733..13c5bfe10 100644 --- a/src/platform/locales/text/ko.json +++ b/src/platform/locales/text/ko.json @@ -1931,7 +1931,6 @@ "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "파일에 오류가 없으면 import 최적화를 실행합니다. 단, 캐럿 줄이 변경되는 경우는 제외합니다.", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "npm 스크립트와 Node 기반 언어 서버(vtsls, eslint, pyright…)를 실행합니다.", "Runs sync, builds and Maven run configurations. A chosen home is used instead of the project's mvnw. Bypassed while the Maven daemon is enabled.": "동기화, 빌드 및 Maven 실행 구성을 실행합니다. 선택한 홈이 프로젝트의 mvnw 대신 사용됩니다. Maven 데몬이 활성화되어 있으면 사용되지 않습니다.", - "Runs the language server's Organize Imports action.": "언어 서버의 import 정리 액션을 실행합니다.", "Runs the language server's formatter before an explicit save (Actions on Save).": "명시적으로 저장하기 전에 언어 서버의 서식 지정 도구를 실행합니다(저장 시 액션).", "Search history": "검색 기록", "Search history ({previous} / {next})": "검색 기록({previous} / {next})", diff --git a/src/platform/locales/text/pl.json b/src/platform/locales/text/pl.json index 6d39f76cb..d595d95ff 100644 --- a/src/platform/locales/text/pl.json +++ b/src/platform/locales/text/pl.json @@ -1870,7 +1870,6 @@ "Runs Maven with -o": "Uruchamia Maven z opcją -o", "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "Uruchamia Optymalizację importów, gdy plik nie zawiera błędów, chyba że zmieniłoby to wiersz kursora.", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "Uruchamia skrypty npm oraz serwery językowe oparte na środowisku Node (vtsls, eslint, pyright…).", - "Runs the language server's Organize Imports action.": "Uruchamia akcję Organizuj importy serwera językowego.", "Runs the language server's formatter before an explicit save (Actions on Save).": "Uruchamia formatowanie serwera językowego przed jawnym zapisem (Akcje podczas zapisywania).", "Search history": "Historia wyszukiwania", "Searching for usages of '{symbol}'": "Wyszukiwanie użyć '{symbol}'", diff --git a/src/platform/locales/text/pt.json b/src/platform/locales/text/pt.json index 392064084..970f0d861 100644 --- a/src/platform/locales/text/pt.json +++ b/src/platform/locales/text/pt.json @@ -1871,7 +1871,6 @@ "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "Executa Otimizar importações quando o arquivo não tiver erros, a menos que isso altere a linha do cursor.", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "Executa scripts npm e servidores de linguagem baseados em Node (vtsls, eslint, pyright…).", "Runs sync, builds and Maven run configurations. A chosen home is used instead of the project's mvnw. Bypassed while the Maven daemon is enabled.": "Executa sincronização, compilações e configurações de execução do Maven. O diretório escolhido é usado em vez do mvnw do projeto. Ignorado quando o daemon do Maven está ativado.", - "Runs the language server's Organize Imports action.": "Executa a ação Organizar importações do servidor de linguagem.", "Runs the language server's formatter before an explicit save (Actions on Save).": "Executa o formatador do servidor de linguagem antes de um salvamento explícito (Ações ao salvar).", "Search history": "Histórico de pesquisa", "Searching for usages of '{symbol}'": "Pesquisando usos de '{symbol}'", diff --git a/src/platform/locales/text/tr.json b/src/platform/locales/text/tr.json index 5045b6ba8..123bd0ee1 100644 --- a/src/platform/locales/text/tr.json +++ b/src/platform/locales/text/tr.json @@ -4625,7 +4625,6 @@ "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "Dosyada hata yoksa, imleç satırını değiştirmeyecekse İçe Aktarmaları Düzenle'yi çalıştırır.", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "npm betiklerini ve Node tabanlı dil sunucularını (vtsls, eslint, pyright…) çalıştırır.", "Runs sync, builds and Maven run configurations. A chosen home is used instead of the project's mvnw. Bypassed while the Maven daemon is enabled.": "Senkronizasyonu, derlemeleri ve Maven çalıştırma yapılandırmalarını yürütür. Seçilen Maven ana dizini, projenin mvnw dosyası yerine kullanılır. Maven daemon etkinse kullanılmaz.", - "Runs the language server's Organize Imports action.": "Dil sunucusunun İçe Aktarmaları Düzenle eylemini çalıştırır.", "Runs the language server's formatter before an explicit save (Actions on Save).": "Açıkça kaydetme işleminden önce dil sunucusunun biçimlendiricisini çalıştırır (Kaydetme Eylemleri).", "Search history": "Arama geçmişi", "Search history ({previous} / {next})": "Arama geçmişi ({previous} / {next})", diff --git a/src/platform/locales/text/zh-TW.json b/src/platform/locales/text/zh-TW.json index 101d7fa1e..132a7222c 100644 --- a/src/platform/locales/text/zh-TW.json +++ b/src/platform/locales/text/zh-TW.json @@ -2690,7 +2690,6 @@ "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "檔案沒有錯誤時執行「最佳化匯入」,除非這會更改游標所在行。", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "執行 npm 指令碼和基於 Node 的語言伺服器(vtsls、eslint、pyright…)。", "Runs sync, builds and Maven run configurations. A chosen home is used instead of the project's mvnw. Bypassed while the Maven daemon is enabled.": "用於同步、建置和 Maven 執行組態。選定後將代替專案的 mvnw。啟用 Maven daemon 時將被繞過。", - "Runs the language server's Organize Imports action.": "執行語言伺服器的「整理匯入」操作。", "Runs the language server's formatter before an explicit save (Actions on Save).": "在顯式儲存前執行語言伺服器的格式化程式(儲存時操作)。", "Search history": "搜尋歷史", "Search history ({previous} / {next})": "搜尋歷史({previous} / {next})", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 4ba3258bf..3d68e5643 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -3106,7 +3106,6 @@ "Runs Optimize Imports when the file has no errors, unless it would change the caret line.": "文件没有错误时运行“优化导入”,除非这会更改光标所在行。", "Runs npm scripts and Node-based language servers (vtsls, eslint, pyright…).": "运行 npm 脚本和基于 Node 的语言服务器(vtsls、eslint、pyright…)。", "Runs sync, builds and Maven run configurations. A chosen home is used instead of the project's mvnw. Bypassed while the Maven daemon is enabled.": "用于同步、构建和 Maven 运行配置。选定后将代替项目的 mvnw。启用 Maven daemon 时将被绕过。", - "Runs the language server's Organize Imports action.": "运行语言服务器的“整理导入”操作。", "Runs the language server's formatter before an explicit save (Actions on Save).": "在显式保存前运行语言服务器的格式化程序(保存时操作)。", "Search history": "搜索历史", "Search history ({previous} / {next})": "搜索历史({previous} / {next})", @@ -9984,6 +9983,9 @@ "Next Rows": "下一组行", "Previous Columns": "上一组列", "Next Columns": "下一组列", + "Install Ruff to optimize imports in Python files": "安装 Ruff 以优化 Python 文件的导入", + "Optimize Imports (Ruff)": "优化导入(Ruff)", + "Uses the language server or a tool such as Ruff to organize imports.": "使用语言服务器或 Ruff 等工具优化导入。", "Pipenv Environment": "Pipenv 环境", "Install packages from Pipfile": "安装 Pipfile 中的软件包", "Runs “pipenv --python ” in the project, which writes a Pipfile (from requirements.txt if there is one) when the project has none. Pipenv chooses where to store the environment and reuses an existing one.": "在项目中运行“pipenv --python ”。项目没有 Pipfile 时会写入一个(有 requirements.txt 时从中导入)。环境的存放位置由 Pipenv 决定,已有环境会被复用。",