biomejs / biome-zed

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

Ranking Biome vs. ESLint #5

Closed frytg closed 2 months ago

frytg commented 4 months ago

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.

luckydye commented 4 months ago

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?

frytg commented 4 months ago

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.

maxdeviant commented 4 months ago

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.

luckydye commented 4 months ago

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

maxdeviant commented 4 months ago

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!

frytg commented 4 months ago

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 commented 4 months ago

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.

luckydye commented 4 months ago

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

luckydye commented 4 months ago

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.

muuvmuuv commented 3 months ago

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

ematipico commented 3 months ago

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.

frytg commented 2 months ago

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...

...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.

Thank you all 🙌

ematipico commented 2 months ago

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:

new defaults? zed-industries/zed@v0.141.2 (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

frytg commented 2 months ago

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.

ematipico commented 2 months ago

They will eventually reach a stable solution and good documentation.

Until then, patience.