Closed chungweileong94 closed 4 months ago
The only workaround I know right now is to uninstall the biome extension every time I work on a non-biome project.
This is a good question, I think the vscode extension requires biome to be installed in the project. Though I find it also nice to be able to edit any TS file, outside of a project, and have biome formatting etc. with default configuration.
I think a good solution would be to have the option in zed settings to enable or disable biome. Then you can choose to enable the extension in only the projects that it is used in (via .zed/settings.json), otherwise disable it globally. But an api for settings like that doesn't exist yet...
I think a good solution would be to have the option in zed settings to enable or disable biome.
I'm still pretty new in Rust, they seem to have exposed the LSP settings to the extension author, but I'm not so sure.
And also, correct me if I'm wrong, after digging into the extension code, it seems like it will always use the latest biome binary regardless of which biome version I'm using in my project?
I'm still pretty new in Rust, they seem to have exposed the LSP settings to the extension author, but I'm not so sure.
I was talking about the zed user settings, not LSP settings.
And also, correct me if I'm wrong, after digging into the extension code, it seems like it will always use the latest biome binary regardless of which biome version I'm using in my project?
It will use the binary from your node_modules if it exists. Otherwise downloads the latest version.
This is a question that has been asked for a long time. I think, for now, it's acceptable to disable the extension if the binary isn't installed.
Although, in the future, I think we will plan to ship the binary again, because we want to provide more features that are more appropriate to a LSP (refactors, rename, etc.)
In my case, the language server doesn't use the biome.json configuration in my monorepo, instead formatting with the default.
Is there a way to check which configuration that biome uses through server (or rpc message) logs?
I was talking about the zed user settings, not LSP settings.
Yeah, I understand that, but the user could also configure their LSP setting too. https://zed.dev/docs/configuring-zed#lsp
It will use the binary from your node_modules if it exists. Otherwise, download the latest version.
That's what I thought when I saw the logic, but it doesn't seem to be the case for me after I checked the Zed log, it always downloads the latest binary regardless.
In my case, the language server doesn't use the biome.json configuration in my monorepo, instead formatting with the default.
From what I know so far, biome doesn't support monorepo at the moment, it only takes the biome.json
at the root. But you could override it for subrepo, https://biomejs.dev/guides/big-projects/#monorepos
From what I know so far, biome doesn't support monorepo at the moment, it only takes the
biome.json
at the root. But you could override it for subrepo, https://biomejs.dev/guides/big-projects/#monorepos
I only defined one biome.json at the root of my repository, which works on both VSCode and when running biome format/check
in the terminal. I am currently sticking with this configuration.
"formatter": {
"external": {
"command": "bunx",
"arguments": [
"@biomejs/biome",
"check",
"--apply",
"--stdin-file-path={buffer_path}"
]
}
}
},
Maybe this should be a separate issue btw
I was talking about the zed user settings, not LSP settings.
Yeah, I understand that, but the user could also configure their LSP setting too. https://zed.dev/docs/configuring-zed#lsp
Ah sorry! I actually didn't know that ^^ I need to try that, that would be great.
That's what I thought when I saw the logic, but it doesn't seem to be the case for me after I checked the Zed log, it always downloads the latest binary regardless.
Hmm I guess the extension doesn't find the binary for some reason...
Hmm I guess the extension doesn't find the binary for some reason...
I think it only checks the existence of the binary relatively somewhere in the Zed extension directory. I was wondering if we could utilize the worktree
, similar (but not the same) to how the zig extension did. https://github.com/zed-industries/zed/blob/2c78cf349b94d69a4b027400d9d388992a4e4517/extensions/zig/src/zig.rs#L21
That's a good approach. Any PR is very welcome!
So I was able to get the extension to use the project binary, then only realized that the LSP will live across the workspaces.
For instance, it will always use the LSP binary from the first opened workspace, subsequence opened workspaces will still use the LSP binary from the first one, unless you restart the Zed manually. I'm not so sure if this is the current limitation of Zed extensions, or if I did something wrong as I am pretty new to Rust.
Here's the repo I hacked things together, https://github.com/chungweileong94/biome-zed/tree/local-biome-server
So I was able to get the extension to use the project binary, then only realized that the LSP will live across the workspaces.
For instance, it will always use the LSP binary from the first opened workspace, subsequence opened workspaces will still use the LSP binary from the first one, unless you restart the Zed manually. I'm not so sure if this is the current limitation of Zed extensions, or if I did something wrong as I am pretty new to Rust.
Here's the repo I hacked things together, https://github.com/chungweileong94/biome-zed/tree/local-biome-server
Seems odd. Try if worktree.root_path()
returns the correct path in langague_server_command()
. Maybe it's still using cached_server_path
. Extensions may be inited per session not per window.
Seems odd. Try if
worktree.root_path()
returns the correct path inlangague_server_command()
. Maybe it's still usingcached_server_path
. Extensions may be inited per session not per window.
I actually did try to disable the cached_server_path
part, and it's the same, likely the langague_server_command()
doesn't even get called twice.
Anyway, mind if I ask how can I possibly "log" anything? As I wasn't able to figure out how to log anything in Zed.
I don't know about zed, but the Biome LSP does emit logs once it is launched: https://biomejs.dev/guides/integrate-in-editor/#daemon-logs
Seems odd. Try if
worktree.root_path()
returns the correct path inlangague_server_command()
. Maybe it's still usingcached_server_path
. Extensions may be inited per session not per window.I actually did try to disable the
cached_server_path
part, and it's the same, likely thelangague_server_command()
doesn't even get called twice.Anyway, mind if I ask how can I possibly "log" anything? As I wasn't able to figure out how to log anything in Zed.
I believe you can just use println!("hello there!");
will be printed to zed: logs.
I am trying to playing around with the extension, I can't see any logs. Even with tracing
, nothing gets printed.
Even a panic!
doesn't trigger anything when locally building the extension
I actually did try to disable the
cached_server_path
part, and it's the same, likely thelangague_server_command()
doesn't even get called twice.
So turns out the language_server_command()
does get called again every time we open a new workspace, and I manage to get the extension to use the workspace binary instead, the lack of logging ready confused me a lot😵💫
Will put up the PR once I cleanup the implementation.
Unfornately, for some reason, I'm not able to check if the workspace binary exists. This code keeps returning false for some reason. Not sure if this is because of the Zed wasm thing.
Update: I managed to work around the issue, by using a pretty hacky way, can check the PR for more details.
FYI if you build zed from source and run with cargo, you do get logs like this:
and println's too... which is why I thought logs work :)
Closing, it seems to work now. Closed by #9
Currently, if a project doesn't have a
biome.json
or does have a@biomejs/biome
package installed, the extension will download a separate biome binary instead. However, it's not friendly for projects that are yet to migrate to the biome.It would be good if the biome LSP enable when either
biome.json
or@biomejs/biome
is found (or maybe both).