Zed 扩展
¥Installation
需要 Zed >= v0.131.0。
¥Requires Zed >= v0.131.0.
此扩展程序可在 Zed 编辑器的扩展视图中找到。打开 zed: extensions 文件并搜索 Biome。它在底层运行 Biome 二进制文件,并按以下顺序检查 Biome 的安装情况:
¥This extension is available in the extensions view inside the Zed editor. Open zed: extensions and search for Biome. It runs the Biome binary under the hood and checks for Biome installations in the following order:
-
Zed 配置中指定的路径,例如:
¥Path specified in Zed’s configuration, for example like this:
{ "lsp": { "biome": { "binary": { "path": "/var/biome-2.2.3/bin/biome", "arguments": [ "lsp-proxy" ] } } }}-
通过
package.json在本地安装 Biome¥Locally installed Biome via
package.json -
PATH中已安装系统级 Biome¥System-wide installed Biome in
PATH
如果两者都不存在,它将要求 Zed 使用 npm 安装 Biome 并使用它。
¥If neither exists, it will ask Zed to install Biome using npm and use that.
¥Configuration
默认情况下,biome.json 文件必须位于工作区的根目录。
¥By default, the biome.json file is required to be in the root of the workspace.
否则,可以通过 lsp 设置进行配置:
¥Otherwise, it can be configured through the lsp settings:
{ "lsp": { "biome": { "settings": { "config_path": "<path>/biome.json" } } }}¥Formatting
要使用语言服务器作为格式化程序,请在设置中将 biome 指定为格式化程序:
¥To use the language server as a formatter, specify biome as your formatter in the settings:
{ "languages": { "JavaScript": { "formatter": { "language_server": { "name": "biome" } } }, "TypeScript": { "formatter": { "language_server": { "name": "biome" } } }, "TSX": { "formatter": { "language_server": { "name": "biome" } } }, "JSON": { "formatter": { "language_server": { "name": "biome" } } }, "JSONC": { "formatter": { "language_server": { "name": "biome" } } }, "CSS": { "formatter": { "language_server": { "name": "biome" } } }, "GraphQL": { "formatter": { "language_server": { "name": "biome" } } }, }}请参阅 语言支持 获取更多信息。
¥See Language Support for more information.
仅当存在 biome.json 文件时才启用 biome
Section titled “仅当存在 biome.json 文件时才启用 biome”¥Enable biome only when biome.json is present
{ "lsp": { "biome": { "settings": { "require_config_file": true } } }}运行代码操作格式:
Section titled “运行代码操作格式:”¥Run code actions on format:
{ "languages": { "JavaScript": { "formatter": { "language_server": { "name": "biome" } }, "code_actions_on_format": { "source.fixAll.biome": true, "source.organizeImports.biome": true } }, "TypeScript": { "formatter": { "language_server": { "name": "biome" } }, "code_actions_on_format": { "source.fixAll.biome": true, "source.organizeImports.biome": true } }, "TSX": { "formatter": { "language_server": { "name": "biome" } }, "code_actions_on_format": { "source.fixAll.biome": true,
"source.organizeImports.biome": true } } }}如果你想在保存时应用 不安全修复,则必须执行 规则 safe 的代码修复。
¥If you want to apply unsafe fixes on save, you must make the code fix of the rule safe.
基于项目的配置
Section titled “基于项目的配置”¥Project based configuration
你可以将这些设置添加到项目根目录下的 Zed 项目设置 (.zed/settings.json) 中,或者作为 Zed 用户设置 (~/.config/zed/settings.json) 进行设置,后者将默认应用于所有项目。
¥You can include these settings in Zed Project Settings (.zed/settings.json) at the root of your project folder or as Zed User Settings (~/.config/zed/settings.json) which will apply to all projects by default.
为特定项目禁用 Biome
Section titled “为特定项目禁用 Biome”¥Disable biome for a particular project
你可以使用以下命令在项目中排除特定语言(例如 GraphQL)的 biome:
¥You can exclude biome for a given language (e.g. GraphQL) on project with:
{ "languages": { "GraphQL": { "language_servers": [ "!biome", "..." ] } }}¥Global Settings
不建议在 Zed 的 setting.json 文件中将 biome 添加到顶层 language_servers、formatter 或 code_actions_on_format 键中。全局指定 biome 为 language_server 或 formatter 可能会导致 biome 不支持的语言(例如 Rust、Python 等)的功能失效。请参阅 语言支持 获取支持的语言完整列表。
¥It is not recommended to add biome to top-level language_servers, formatter or code_actions_on_format keys in your Zed setting.json. Specifying biome as language_server or formatter globally may break functionality for languages that biome does not support (Rust, Python, etc). See language support for a complete list of supported languages.
本文档之前推荐使用全局设置;请切换你的 Zed 设置,以便针对每种语言显式配置 biome。
¥This documentation previously recommended global settings; please switch your Zed settings to explicitly configure biome on a per language basis.
Biome v2.1 中文网 - 粤ICP备13048890号