biome-zed icon indicating copy to clipboard operation
biome-zed copied to clipboard

Extension ignoring biome.json

Open lcsvcn opened this issue 10 months ago • 5 comments

Issue: Biome Extension Overwrites Custom Formatting with Default Biome Formatting

Description: When running npx @biomejs/biome format --write src to format biome files, the operation completes successfully and applies the custom formatting as expected. However, when utilizing the biome extension, it overrides the custom formatting with the default biome formatting.

Steps to Reproduce:

Run npx @biomejs/biome format --write src to format biome files with custom formatting. Confirm that the custom formatting is applied correctly. Enable the biome extension in the project. Trigger biome formatting via the extension. Expected Behavior: The biome extension should respect and maintain the custom formatting applied to biome files when formatting them. It should not overwrite custom formatting with default biome formatting.

Actual Behavior: Despite successful custom formatting using the CLI command, the biome extension disregards the custom formatting and applies default biome formatting when triggered.

Impact: This issue disrupts the workflow of users who rely on custom formatting for biome files. It leads to inconsistencies and frustration as the extension overrides user preferences without regard for existing formatting choices.

Proposed Solution: Update the biome extension to preserve custom formatting when formatting biome files. Ensure that the extension respects the formatting applied via CLI commands and does not overwrite it with default biome formatting.

Additional Information:

Extension Version: 0.0.6 Operating System: Mac OS 14.4.1

This issue significantly affects the usability and effectiveness of the biome extension for users who rely on consistent formatting practices. Prompt resolution or guidance on how to preserve custom formatting would be greatly appreciated.

lcsvcn avatar Apr 26 '24 13:04 lcsvcn

What are your zed settings for formatting? This default you are referring to might be the default prettier settings applied by builtin zed prettier.

luckydye avatar Apr 27 '24 03:04 luckydye

I have exactly the same issue with this. Either conflicting with default formatter or doesn't seem to respect biome.json config.

I have a public repo that has this issue for reproduction: https://github.com/Marcisbee/exome-devtools

  • biome.json states that it should use tabs;
  • npx @biomejs/biome format src says it's all good - https://app.warp.dev/block/T4Ze44q4InKDK12WhFzgwe;
  • in zed opening project, then src/store.ts, then cmd+shift+i - formats all tabs to spaces.

In zed global settings file I have this:

{
  // ...
  "show_copilot_suggestions": false,
  "code_actions_on_format": {
    "source.fixAll": true,
    "source.organizeImports.biome": true
  },
  "formatter": "language_server"
}

Versions:

  • Zed 0.132.3 (3518c939cbcde8f729a146e4dc7de9001a57e593)
  • Extension 0.0.6
  • Biome 1.7.1

Marcisbee avatar Apr 29 '24 07:04 Marcisbee

The formatting over LSP is currently broken, see https://github.com/biomejs/biome-zed/issues/5 for status.

Does this issue also apply to the diagnostic output in the editor?

luckydye avatar Apr 29 '24 11:04 luckydye

Instead of using the LSP as formatter, you could do custom formatted for now.

"formatter": {
    "external": {
      "command": "./node_modules/@biomejs/biome/bin/biome",
      "arguments": ["format", "--write", "--stdin-file-path", "{buffer_path}"]
    }
}

As far as I know, prettier LSP is being treated differently, meaning it won't enable unless you have a prettier setup in the codebase.

chungweileong94 avatar Apr 30 '24 12:04 chungweileong94

Does this issue also apply to the diagnostic output in the editor?

Yes, I have a biome.js in the project with linting rules set to warn or off. In the cli they don't produce errors. But in zed I see error squiggly lines all over.

sporto avatar May 17 '24 02:05 sporto

As of Zed 0.146.0, we can now specify what language_server to use for the formatting:

{
  "formatter": {
    "language_server": {
      "name": "biome"
    }
  }
}

If you still have issues, check if your biome.json is in the correct location.

luckydye avatar Jul 23 '24 20:07 luckydye