From 5d77a7dc6ca2556bd7ebc598de01e4af94b9bc59 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 23 Jul 2024 09:57:42 +0200 Subject: [PATCH] Ruff: Do not pass --preview flag, respect binary settings (#15001) Bumps version to 0.0.2 as well. Release Notes: - N/A --- Cargo.lock | 2 +- extensions/ruff/Cargo.toml | 2 +- extensions/ruff/extension.toml | 2 +- extensions/ruff/src/ruff.rs | 25 ++++++++++++++++++++++--- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 50c0ce21e9..2b12721af7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14016,7 +14016,7 @@ dependencies = [ [[package]] name = "zed_ruff" -version = "0.0.1" +version = "0.0.2" dependencies = [ "zed_extension_api 0.0.6", ] diff --git a/extensions/ruff/Cargo.toml b/extensions/ruff/Cargo.toml index 0c8ef12401..c7545c218b 100644 --- a/extensions/ruff/Cargo.toml +++ b/extensions/ruff/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zed_ruff" -version = "0.0.1" +version = "0.0.2" edition = "2021" publish = false license = "Apache-2.0" diff --git a/extensions/ruff/extension.toml b/extensions/ruff/extension.toml index 55c1c59732..d622b37c68 100644 --- a/extensions/ruff/extension.toml +++ b/extensions/ruff/extension.toml @@ -1,7 +1,7 @@ id = "ruff" name = "Ruff" description = "Support for Ruff, the Python linter and formatter" -version = "0.0.1" +version = "0.0.2" schema_version = 1 authors = [] repository = "https://github.com/zed-industries/zed" diff --git a/extensions/ruff/src/ruff.rs b/extensions/ruff/src/ruff.rs index 5a82530f23..d7e08ed1ad 100644 --- a/extensions/ruff/src/ruff.rs +++ b/extensions/ruff/src/ruff.rs @@ -96,12 +96,31 @@ impl zed::Extension for RuffExtension { fn language_server_command( &mut self, - language_server_id: &LanguageServerId, + server_id: &LanguageServerId, worktree: &zed::Worktree, ) -> Result { + let mut binary = None; + let mut args = None; + if let Some(binary_settings) = LspSettings::for_worktree(server_id.as_ref(), worktree) + .ok() + .and_then(|lsp_settings| lsp_settings.binary) + { + if let Some(bin_path) = binary_settings.path { + binary = Some(bin_path); + } + if let Some(bin_args) = binary_settings.arguments { + args = Some(bin_args); + } + } + let command = if let Some(binary) = binary { + binary + } else { + self.language_server_binary_path(server_id, worktree)? + }; + let args = args.unwrap_or_else(|| vec!["server".into()]); Ok(zed::Command { - command: self.language_server_binary_path(language_server_id, worktree)?, - args: vec!["server".into(), "--preview".into()], + command, + args, env: vec![], }) }