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

Ranking Biome vs. ESLint

Open frytg opened this issue 10 months ago • 11 comments

Is there any configuration needed to make sure Zed is prefering Biome over native ESLint?

When I install the extension (v0.0.2) in Zed Preview (v0.131.4), it creates a different formatting output in JS files vs. the Biome CLI. It seems like it is doing something when saving (adjusting spaces or so), but that seems to be more the output from ESLint or some other language server. Actually running bunx biome format index.js --write however reformats the whole file (replaces spaces with tabs, which also seems to be the default) - which would be the intended way.

Is there any other way to debug or improve this?

This is in settings.json:

"format_on_save": "on",
"code_actions_on_format": {
    "source.fixAll": true,
    "source.organizeImports.biome": true
},
"formatter": "language_server"

Adding a biome.json with some arbitrary values like formatter.indentWidth: 16 also shows that it doesn't get picked up, while the CLI replaces that.

frytg avatar Apr 13 '24 13:04 frytg

There is currently no way to disable eslint in zed, I think. It is baked into the typescript extension which is builtin. So if both is configured, they may be conflicting.

One limitation is currently, that the biome.json needs to sit in the root of the zed project to be seen by the biome language server.

You can also try to set source.fixAll.biome instead, so it wont apply fixes from other language servers.

Can you provide a repo for reproduction?

luckydye avatar Apr 13 '24 14:04 luckydye

Thanks for the quick feedback! I was able to see the Biome logs and verify that it properly picks up the config, but it seems that Zed is doing some interesting processing or doesn't properly trigger formatting. I'll create a repo to reproduce this issue this coming week.

frytg avatar Apr 14 '24 14:04 frytg

There is currently no way to disable eslint in zed, I think. It is baked into the typescript extension which is builtin. So if both is configured, they may be conflicting.

I'm currently working on a fix for this (tracked by https://github.com/zed-industries/zed/issues/10906).

I just landed https://github.com/zed-industries/zed/pull/10911 to main which will allow you to add this to your settings to disable the built-in TypeScript and ESLint language servers in favor of Biome:

{
  "languages": {
    "TypeScript": {
      "language_servers": ["biome", "!typescript-language-server", "!eslint", "..."]
    }
  }
}

Will be shipping to Preview tomorrow.

maxdeviant avatar Apr 23 '24 23:04 maxdeviant

Thats great! Though the biome lsp server should be used together with the ts-server, not instead. But we can finally disable eslint! ^^

luckydye avatar Apr 24 '24 00:04 luckydye

Thats great! Though the biome lsp server should be used together with the ts-server, not instead. But we can finally disable eslint! ^^

Oh, for some reason I thought Biome had its own TS language server 😄

But yes, it can be used to disable ESLint!

maxdeviant avatar Apr 24 '24 00:04 maxdeviant

Oh wow, that looks really promising, @maxdeviant and would probably solve the ranking issue with clashes of eslint vs. Biome! I'll keep an eye on the Preview version.

frytg avatar Apr 24 '24 09:04 frytg

Hi @maxdeviant and @luckydye, I create this repository to demonstrate my use-case and errors: https://github.com/frytg/biome-zed-repro-temp

I hope this makes sense. I hope I didn't do any super dumb mistakes, which prevents this whole setup, but so far it seems quite hard and complicated to get Biome working in Zed.

frytg avatar Apr 27 '24 11:04 frytg

@frytg awsome! I agree it should be very easy.

luckydye avatar Apr 27 '24 11:04 luckydye

So the problem is, zed thinks the biome language server doesn't have the capability to run "textDocument/formatting", which is odd, cause it does.

I have a fix here: https://github.com/luckydye/zed/tree/biome-formatting-fix, but I think this would ignore any other language server that could format but is not the first priority.

Thats as far as I got for now...

Update: TLDR, formatting doesn't work because zed does not support dynamic register for formatting capabilities.

luckydye avatar Apr 27 '24 12:04 luckydye

Is there an upstream issue for dynamic register of formatting caps?

muuvmuuv avatar May 23 '24 05:05 muuvmuuv

We removed dynamic registration of formatting capabilities because not all clients support it.

Also, you can't have static and dynamic registration of the same capabilities, some clients like VSCode break.

ematipico avatar May 23 '24 05:05 ematipico

I'm sorry I have to come back to this. I absolutely love the recent progress and developments of Zed, but the overall language server selection process still boggles me and will likely force me to switch back, since it's basically not working to configure and maintain a persistent experience

Also, there are so many open issues about this...

  • https://github.com/zed-industries/zed/issues/10906
  • https://github.com/zed-industries/zed/issues/12881
  • https://github.com/zed-industries/zed/issues/13492
  • https://github.com/zed-industries/zed/issues/11288
  • https://github.com/biomejs/biome-zed/issues/24
  • https://github.com/biomejs/biome-zed/issues/12
  • new defaults? https://github.com/zed-industries/zed/releases/tag/v0.141.2

...that all seem to evolve aroung the same issues. Don't get me wrong, I don't want to criticize anyone's work, but what can we do to make this a pleasant and consistent experience? It takes 1min to configure the Biome plugin in VSCode and make it the default.

  • How can we explicitly configure one plugin for a certain language (e.g. only use Biome for JavaScript – linting and formatting!)?
  • How can we make sure the plugin configuration loads properly (workspace root or similar)?
  • Can we add all those details to the overall Zed docs? e.g. language_servers is nowhere on zed.dev?

Thank you all 🙌

frytg avatar Jun 27 '24 15:06 frytg

but what can we do to make this a pleasant and consistent experience?

I don't want to disrespect anyone, especially you, but you know what's the answer :) But I'll try:

  • Zed is a very young editor whose interest and knowledge base among developers is proportional to its longevity. VSCode is way more mature and old than Zed.
  • Zed is a moving target and they change things fast, they can also break stuff. They are allowed to do so, they haven't released v1
  • It's just me and a couple of other volunteers. Please help us by sending a PR.

new defaults? zed-industries/[email protected] (release)

This was released yesterday, I find really hard to fix it swiftly.

Overall, I am very displeased with your message, I don't feel any support for us volunteers. Thank you for your message

ematipico avatar Jun 27 '24 15:06 ematipico

As someone who is not part of the inner works of Biome & Zed it is just hard to understand where the issue could be. Both are amazing tools, but at the moment I (and seemingly lots other people) don't understand the intended optiomal configuration and expected outcomes of the integration of those two. And that totally being aware of how young both projects are.

frytg avatar Jun 27 '24 15:06 frytg

They will eventually reach a stable solution and good documentation.

Until then, patience.

ematipico avatar Jun 27 '24 16:06 ematipico