Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support to configure --config-path through settings #23

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</picture>
</p>


<div align="center">

[![CI main](https://github.com/biomejs/biome-zed/actions/workflows/main.yml/badge.svg)](https://github.com/biomejs/biome-zed/actions/workflows/main.yml)
Expand Down Expand Up @@ -38,16 +37,29 @@ This extension is available in the extensions view inside the Zed editor. Open `

## Configuration

Example configurations in zed `settings.json`.
Run code actions on format:

```json5
luckydye marked this conversation as resolved.
Show resolved Hide resolved
```jsonc
// settings.json
{
"format_on_save": "on",
"code_actions_on_format": {
"source.fixAll": true,
"source.fixAll.biome": true,
"source.organizeImports.biome": true
},
"formatter": "language_server"
}
}
```

Configure the `--config-path` flag for the language server:

```jsonc
// settings.json
{
"lsp": {
"biome": {
"settings": {
"config_path": "<path>/biome.json"
}
}
}
}
```
11 changes: 10 additions & 1 deletion src/biome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl zed::Extension for BiomeExtension {
let path = self.server_script_path(language_server_id, worktree)?;
let settings = LspSettings::for_worktree(language_server_id.as_ref(), worktree)?;

let args = vec![
let mut args = vec![
env::current_dir()
.unwrap()
.join(path)
Expand All @@ -98,6 +98,15 @@ impl zed::Extension for BiomeExtension {
"lsp-proxy".to_string(),
];

if let Some(settings) = settings.settings {
let config_path = settings.get("config_path").and_then(|value| value.as_str());

if let Some(path) = config_path {
args.push("--config-path".to_string());
args.push(path.to_string());
}
}

if let Some(binary) = settings.binary {
return Ok(zed::Command {
command: binary.path.map_or(zed::node_binary_path()?, |path| path),
Expand Down