Language server
此内容尚不支持你的语言。
Biome provides first-class support for the Language Server Protocol (LSP). This page lists the methods and settings of the Biome language server, and the ways to integrate Biome in an editor extension.
Supported methods
Section titled “Supported methods”The Biome language server supports the following methods:
initializeinitializedworkspace/didChangeConfigurationworkspace/didChangeWatchedFilesworkspace/didChangeWorkspaceFolderstextDocument/didOpentextDocument/didChangetextDocument/didSavetextDocument/didClosetextDocument/publishDiagnosticstextDocument/codeActioncodeAction/resolvetextDocument/formattingtextDocument/rangeFormattingtextDocument/onTypeFormattingtextDocument/definition
Extension settings
Section titled “Extension settings”The Biome language server accepts the following settings, which an extension can expose to users.
require_configuration
Section titled “require_configuration”Type: boolean
Default: false
Requires a configuration file before the language server analyzes files. When set to true, the language server does not analyze any file (except for parsing) until there is a biome.json file in the root of the project.
{ "require_configuration": true}configuration_path
Section titled “configuration_path”Type: string
Default: null
Path to a custom configuration file. The path can point to a biome.json or biome.jsonc file, or to the folder that contains it.
The path can be relative or absolute. The language server reads this option only when it is provided. Use this option when the configuration is in a subfolder of your project.
{ "configuration_path": "./frontend/biome.json"}inline_config
Section titled “inline_config”Type: object
Default: null
An inline Biome configuration. Its options override the options from any biome.json file read from disk, or the defaults.
For example, to turn off the noConsole rule while you develop locally, even though your biome.json enables it:
{ "inline_config": { "linter": { "rules": { "suspicious": { "noConsole": "off" } } } }}go_to_definition
Section titled “go_to_definition”Type: boolean
Default: false
Enables the LSP’s textDocument/definition capabilities using the Biome module graph.
Supported:
- Resolve definitions of variables declared in the same file or in another file for JavaScript, TypeScript, JSX, TSX, and HTML-ish files.
- Resolve definitions of CSS classes used in JSX/TSX files and HTML-ish files.
- Resolve definitions of JSX/TSX components.
- Resolve definitions of HTML-ish components.
Out of scope:
- Resolve variables defined in dependencies.
- Resolve variables defined in dependencies that are not imported in the project.
Integrate Biome in an editor extension
Section titled “Integrate Biome in an editor extension”You can integrate Biome in your editor extension in three ways: through the LSP proxy, through standard input, or through the CLI connected to a daemon.
Use the LSP proxy
Section titled “Use the LSP proxy”The lsp-proxy command starts two processes:
- A daemon, a long-running server that Biome spawns in the background to process requests from the editor and the CLI. It executes the requested operations.
- A server that acts as a proxy between the client (the editor) and the daemon.
If your editor can interact with a server and send JSON-RPC requests, configure the editor to run that command. For an example, see the Neovim Biome extension.
Use stdin
Section titled “Use stdin”If your editor does not support LSP, call the biome binary directly through standard input.
The following commands accept standard input:
Biome writes the new output (or the original output if nothing changed) to standard output and the diagnostics to standard error.
When you use stdin, you must pass the --stdin-file-path option. The file does not need to exist in your file system, and it can have any name. Its extension must be correct, because Biome uses it to decide how to treat the input.
The editor is responsible for locating the binary and calling it when needed. Biome publishes one npm package per supported operating system and architecture:
@biomejs/cli-darwin-arm64@biomejs/cli-darwin-x64@biomejs/cli-linux-arm64@biomejs/cli-linux-x64@biomejs/cli-win32-arm64@biomejs/cli-win32-x64
The binary is named biome or biome.exe and sits in the root directory of the package, for example @biomejs/cli-darwin-arm64/biome or @biomejs/cli-win32-x64/biome.exe.
The language server accepts settings that editor extensions can expose to users.
Use the daemon with the binary
Section titled “Use the daemon with the binary”Calling the binary through the CLI is efficient, but you cannot provide logs to your users. To keep one process running across commands, start a daemon and run the CLI commands through it.
First, start a daemon process with the start command:
biome startThen pass the --use-server option to every command:
echo "console.log('')" | biome format --use-server --stdin-file-path=dummy.js© 2023-present Biome developers and contributors.