Biome Language Server
Biome provides first-class support for the Language Server Protocol (LSP).
Supported methods
Section titled “Supported methods”The Biome Language Server currently 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 exposes the following settings, that an extension can expose to users.
require_configuration
Section titled “require_configuration”Type: boolean
Default: false
Whether the Biome Language Server requires a configuration file. When set to true, it won’t analyze any file (except for parsing) until there’s a biome.json file in the root of the project.
{ "require_configuration": true}configuration_path
Section titled “configuration_path”Type: string
Default: null
A 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 Biome Language Server reads this option only when 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 version of the Biome configuration. The options of this configuration will override the options coming from any biome.json file read from disk (or the defaults).
For example, let’s say your project enables the rule noConsole with error severity:
{ "linter": { "rules": { "suspicious": { "noConsole": "error" } } }}However, during local development, you want to disable this rule because it’s useful and you don’t want to see red squiggles. In your inline_config, you would write something like the following:
{ "inline_config": { "linter": { "rules": { "suspicious": { "noConsole": "off" } } } }}go_to_definition
Section titled “go_to_definition”Type: boolean
Default: true
Enables the LSP’s textDocument/definition capabilities using the Biome module graph.
What’s 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.
What’s out of scope:
- Resolve variables defined in dependencies.
- Resolve variables defined in dependencies that aren’t 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 different ways.
Use the LSP proxy
Section titled “Use the LSP proxy”Biome has a command called lsp-proxy. When executed, Biome will spawn two processes:
- a daemon that does execute the requested operations;
- a server that functions as a proxy between the requests of the client - the editor - and the server - the daemon;
If your editor can interact with a server and send JSON-RPC requests, you only need to configure the editor to run that command.
You can check how the Neovim Biome extension does it.
Use stdin
Section titled “Use stdin”If your editor doesn’t support LSP, you can use the biome binary directly and call it using standard input.
The following commands can be called via standard input:
Biome will return the new output (or the original output if changes haven’t occurred) to standard output and the diagnostics to standard error.
When you use stdin, you must pass the --stdin-file-path option. The file path doesn’t need to exist in your file system, it can be any name. What’s important is to provide the correct file extension, so Biome knows how to treat your file.
It’s the editor’s responsibility to locate and resolve the path of the binary and then call it when it’s needed. The binaries are shipped to npm based on the architectures and OS that we support:
@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 name is biome or biome.exe, and it can be found in the root directory of the library, e.g.: @biomejs/cli-darwin-arm64/biome, @biomejs/cli-win32-x64/biome.exe.
The language server exposes some options that editor extensions can expose to users.
Use the daemon with the binary
Section titled “Use the daemon with the binary”Using the binary via CLI is very efficient, although you won’t be able to provide logs to your users. The CLI allows you to bootstrap a daemon and then use the CLI commands through the daemon itself.
In order to do so, you first need to start a daemon process with the start command:
biome startThen, every command needs to add the --use-server options, e.g.:
echo "console.log('')" | biome format --use-server --stdin-file-path=dummy.jsLanguage Server logs
Section titled “Language Server logs”The Biome daemon saves logs in your file system. Logs are stored in a folder called biome-logs. The path of this folder changes based on your operating system:
- Linux:
~/.cache/biome; - Windows:
C:\Users\<UserName>\AppData\Local\biomejs\biome\cache - macOS:
/Users/<UserName>/Library/Caches/dev.biomejs.biome
For other operative systems, you can find the folder in the system’s temporary directory.
To obtain the precise path, execute the following command:
biome explain daemon-logsThe log files are rotated on an hourly basis.
Copyright (c) 2023-present Biome Developers and Contributors.