zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
34.47k stars 1.71k forks source link

Add setting to choose specific language server for formatting #11390

Open luckydye opened 2 weeks ago

luckydye commented 2 weeks ago

Closes https://github.com/zed-industries/zed/issues/11288

Inspired by VSCode, which also lets you choose a specific formatter like this. I successfully tried this out so may as well make a PR, totally open for discussion tho :).

Example settings:

{
  "languages": {
    "TypeScript": {
      "formatter": {
        "language_server_name": "biome"
      }
    },
  }
}

Release Notes:

maxdeviant commented 2 weeks ago

I'd like to dig into/understand the underlying issue a bit more first.

Because the language_servers setting should indicate the order in which language servers are used by the formatter (at least in the case when "formatter": "language_server", is set).

mikayla-maki commented 1 day ago

@luckydye Could you expand on the use case this PR is serving, that isn't supported by the language_servers setting as @maxdeviant mentioned? Once we have a clear idea of the use case you're seeing, we can move forward :)

luckydye commented 15 hours ago

@mikayla-maki sure thing.

First of all, it is just not clear at the moment, what language server is used to format using current "formatter" settings. When I format a file, there is no way of knowing what LS did the formatting.

The "language_servers" setting, also does not really show what language server is used for formatting, since the first one in the list may not have formatting support. It would be better imo, to explicitly tell zed what I want to use.

I'm sure there may be another way of solving this.