biomejs / biome-zed

Biome extension for Zed
https://biomejs.dev
MIT License
93 stars 2 forks source link

Extension ignoring biome.json #12

Closed lcsvcn closed 4 days ago

lcsvcn commented 3 months ago

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.

luckydye commented 3 months ago

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

Marcisbee commented 2 months ago

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

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:

luckydye commented 2 months ago

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?

chungweileong94 commented 2 months ago

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.

sporto commented 2 months ago

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.

luckydye commented 4 days ago

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.