zed icon indicating copy to clipboard operation
zed copied to clipboard

Wrong primary language_server for formatting

Open luckydye opened this issue 9 months ago • 4 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

When trying to run formatting via lsp, it does not use the right language server.

I tried to to prioritise them with the "language_servers" settings like this:

"language_servers": [
    "biome",
    "typescript-language-server",
    "!eslint"
],

But I noticed it will still only use "typescript-language-server" to format the buffer.

Printing the language_server.name() to logs: image Should be "biome_lsp".

Environment

Zed: v0.135.0 (Zed Dev d8ca15372c5dccb4f49b6ae13014059f9594dc03) OS: macOS 14.2.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

luckydye avatar May 02 '24 04:05 luckydye

@luckydye What do you have your "formatter setting set to? Is it "formatter": "language_server"?

maxdeviant avatar May 02 '24 16:05 maxdeviant

@maxdeviant Yes, these are my exact settings:

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

luckydye avatar May 02 '24 16:05 luckydye

Maybe it would make sense to have a setting like this?

{
  "formatter": {
    "language_server": "biome"
  }
}

luckydye avatar May 04 '24 13:05 luckydye

This works for me, doesn't it work on you?

  "formatter": {
    "code_actions": {
      "source.fixAll.eslint": true
    }
  },

unitythemaker avatar May 16 '24 10:05 unitythemaker

@unitythemaker source.fixAll fixes linting errors in most cases. This may work for for eslint, but its not a universal solution. Mainly because eslint sees formatting errors as lint errors, but biome for example, follows a different philosophy.

luckydye avatar May 18 '24 14:05 luckydye

@luckydye I've just landed a PR which - amongst other things - adds name argument to the `language_server formatter:

"formatter": {"language_server": {"name": "YOUR_LSP_NAME"}}

osiewicz avatar Jul 23 '24 19:07 osiewicz

@osiewicz ohh perfect! Thanks!

luckydye avatar Jul 23 '24 19:07 luckydye