zed icon indicating copy to clipboard operation
zed copied to clipboard

Add setting to choose specific language server for formatting

Open luckydye opened this issue 9 months ago • 1 comments

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:

  • N/A

luckydye avatar May 04 '24 15:05 luckydye

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

maxdeviant avatar May 04 '24 18:05 maxdeviant

@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 :)

mikayla-maki avatar May 18 '24 01:05 mikayla-maki

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

luckydye avatar May 18 '24 14:05 luckydye

Going to close this until we have time to revisit.

We can continue discussion in https://github.com/zed-industries/zed/issues/11288.

maxdeviant avatar Jun 18 '24 14:06 maxdeviant