Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting doesn't seem to work in Zed 0.151.2 #46

Closed
shellheim opened this issue Sep 10, 2024 · 16 comments
Closed

Formatting doesn't seem to work in Zed 0.151.2 #46

shellheim opened this issue Sep 10, 2024 · 16 comments

Comments

@shellheim
Copy link

#45 Fixes the issue of biome not being downloaded at all but still the downloaded version isn't used to do formatting when formatting is enabled. Obviously, the fixes related to it also don't get applied though I don't if that might be a separate problem or just a resultant of this one.

Steps to Reproduce

  1. Install biome from the extensions tab
  2. Open a file with an error.
  3. Ask biome to format by changing your configuration.
  4. Observe that no formatting happens

Config

//biome
{
  "lsp": {
    "biome": {
      "settings": {
        "config_path": "~/Code/biome.json",
        "require_config_file": false
      }
    }
  },
  "formatter": {
    "language_server": {
      "name": "biome"
    }
  },
  "code_actions_on_format": {
    "source.fixAll.biome": true,
    "source.organizeImports.biome": true
  }
}
@luckydye
Copy link
Collaborator

I can't reporoduce your issue, can you attach logs?

@Aleksion
Copy link

Same issue here.
Biome is working and is detecting errors - but it's not running formatting.
And when manually running format, it's not running the code actions.

Screenshot 2024-09-12 at 1 20 07 PM Screenshot 2024-09-12 at 1 20 15 PM Screenshot 2024-09-12 at 1 21 55 PM

@chungweileong94
Copy link
Contributor

chungweileong94 commented Sep 13, 2024

And when manually running format, it's not running the code actions

I believe this is actually a separate issue, mostly caused by Zed, I haven't got time to look into this.
#35

Issue on Zed repo: zed-industries/zed#15464

@shellheim
Copy link
Author

Sorry for being so late. I did some testing now, looked at the logs and disabled prettier. Biome is formatting fine but the code actions don't run. But that seems to a zed issue as pointed out above.

ahuth added a commit to ahuth/andrew-stack that referenced this issue Sep 14, 2024
Doesn't actually work completely, due to biomejs/biome-zed#46
@jackTabsCode
Copy link
Contributor

Formatting is working for me, but code actions aren't running. On Zed 154.

@elawad
Copy link

elawad commented Sep 21, 2024

Code actions seem to be fixed now after latest Biome release. I was able to organize imports and apply safe fixes on save.

biome 1.9.2
biome-zed 0.1.2
zed 0.153.6
// settings.json
{
  "formatter": {
    "language_server": {
      "name": "biome"
    }
  },
  "code_actions_on_format": {
    "source.fixAll.biome": true,
    "source.organizeImports.biome": true
  }
}

@elawad
Copy link

elawad commented Sep 21, 2024

@Aleksion You may want to remove "format_on_save": "language_server". That line is breaking Biome's format.

And fyi format_on_save is already enabled by default in Zed.

@chrisvander
Copy link

@elawad had the opposite experience, Biome seemed to be refusing to format or do anything, and I had to re-add the "format_on_save": "language_server" line.

@luckydye
Copy link
Collaborator

luckydye commented Oct 9, 2024

Reference https://zed.dev/docs/configuring-zed#format-on-save for updated configuration options. Old options like "format_on_save": "language_server" may be a bit buggy.

Since code-actions seem to work again, as well as formatting, ill close this issue.

@luckydye luckydye closed this as completed Oct 9, 2024
@chrisvander
Copy link

@luckydye I wish I didn't have to use that configuration option, but surprisingly (at least to me) the following language specific configuration does not work:

"TypeScript": {
	"format_on_save": "on",
        "formatter": "language_server",
	"language_servers": [
		"biome",
		"vtsls",
		"!typescript-language-server",
		"!eslint"
	]
}

Removing the "formatter" option and changing "format_on_save" to language server allows formatting to work again. Attempting to do my formatting with Biome. Maybe this should be another issue?

@luckydye
Copy link
Collaborator

@chrisvander try the recomended configuration for formatter: https://biomejs.dev/reference/zed/#formatting

@chrisvander
Copy link

That was the first thing I tried. This does not work, not on save nor with the editor: format command:

"TypeScript": {
    "formatter": {
      "language_server": {
        "name": "biome"
      }
    },
    "code_actions_on_format": {
      "source.fixAll.biome": true,
      "source.organizeImports.biome": true
    },
    "language_servers": [
      "vtsls",
      "biome",
      "!typescript-language-server",
      "!eslint"
    ]
  }

@chrisvander
Copy link

This feels like it shouldn't work, but does:

"TypeScript": {
	"format_on_save": {
		"language_server": {
			"name": "biome"
		}
	},
	"code_actions_on_format": {
		"source.fixAll.biome": true,
		"source.organizeImports.biome": true
	},
	"language_servers": [
		"vtsls",
		"biome",
		"!typescript-language-server",
		"!eslint"
	]
}

Note that I haven't figured out the right combination of settings to get editor: format to work.

What other info should I share?

@elawad
Copy link

elawad commented Oct 10, 2024

@chrisvander Perhaps the TypeScript key config is not working?
I was able to get it to work in JS, TS, React, etc without specifying a language.

And I didn't need to include "language_servers": [ ... ]

@jackTabsCode
Copy link
Contributor

I was never able to get the Biome extension to work.. UNTIL I did a clean re-install of Zed. That means deleting both the application, and it's data files, which on macOS, you can find in ~/Library/Application Support/Zed. I believe there might have been some extension stuff it wasn't cleaning up causing Biome's extension not to install or work properly.

I now am able to get lints to show up in-editor, and formatting works too.
Here's my project configuration too, if it helps:

	"formatter": {
		"language_server": {
			"name": "biome"
		}
	},
	"language_servers": [
		"!eslint",
		"!tailwindcss-language-server",
		"!typescript-language-server",
		"..."
	],
	"prettier": {
		"allowed": false
	},
	"code_actions_on_format": {
		"source.fixAll.biome": true,
		"source.organizeImports.biome": true
	},

@N3koSempai
Copy link

@chrisvander try the recomended configuration for formatter: https://biomejs.dev/reference/zed/#formatting

has a reference. this work for me . i have this config:

 "lsp": {
    "biome": {
      "settings": {
        "require_config_file": true
      }
    }
  },
  "formatter": {
    "language_server": {
      "name": "biome"
    }
  },
  "code_actions_on_format": {
    "source.fixAll.biome": true,
    "source.organizeImports.biome": true
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants