Ruff: Do not pass --preview flag, respect binary settings (#15001)

Bumps version to 0.0.2 as well.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-07-23 09:57:42 +02:00 committed by GitHub
parent 1fae99a7c4
commit 5d77a7dc6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 6 deletions

2
Cargo.lock generated
View file

@ -14016,7 +14016,7 @@ dependencies = [
[[package]]
name = "zed_ruff"
version = "0.0.1"
version = "0.0.2"
dependencies = [
"zed_extension_api 0.0.6",
]

View file

@ -1,6 +1,6 @@
[package]
name = "zed_ruff"
version = "0.0.1"
version = "0.0.2"
edition = "2021"
publish = false
license = "Apache-2.0"

View file

@ -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"

View file

@ -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<zed::Command> {
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![],
})
}