biomejs / biome-vscode

Biome extension for Visual Studio Code and VSCodium
https://marketplace.visualstudio.com/items?itemName=biomejs.biome
Apache License 2.0
237 stars 32 forks source link

🐛 `editor.formatOnSave` only works if set in language-specific configuration blocks #401

Closed hood closed 1 month ago

hood commented 1 month ago

VS Code version

1.95.0-insider

Extension version

v2024.10.131712 (pre-release)

Biome version

1.9.3

Operating system

Description

The following configuration, setting biome as a project-wide formatted, won’t work.

{
  "editor.formatOnSave": true,
  "editor.formatOnSaveMode": "file",
  "biome.enabled": true,
  "editor.defaultFormatter": "biomejs.biome"
}

If set on a per-language basis, Biome will actually start formatting files automatically.

(Example)

{
  "editor.formatOnSave": true,
  "editor.formatOnSaveMode": "file",
  "biome.enabled": true,
  "[typescriptreact]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
  "[typescript]": {
    "editor.defaultFormatter": "biomejs.biome"
  },
}

Steps to reproduce

{
  "editor.formatOnSave": true,
  "editor.formatOnSaveMode": "file",
  "biome.enabled": true,
  "editor.defaultFormatter": "biomejs.biome"
}

Expected behavior

Should automatically format files when configured to do so.

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Link to a minimal reproduction

No response

Logs

No response

ematipico commented 1 month ago

Unfortunately this isn't something we can fix. The formatting signal is sent by the client (VSCode).

Probably your environment has some settings that override the generic formatter.

I suggest looking at this PR https://github.com/biomejs/biome-vscode/pull/374, there's a tweet from Colin that explains a possible bug.

While your expectations are correct, we can only suggest possible workarounds