-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Can't get Biome to organize imports on save #15464
Comments
I posted this issue on the Biome extension repo but it looks like it might be an issue with Zed sending the code action (not sure): biomejs/biome-zed#35 |
Here are my Biome daemon logs in case that's helpful: ~/Library/Caches/dev.biomejs.biome/biome-logs/server.log.2024-07-30-15├─ 1ms DEBUG biome_lsp::handlers::analysis Suggested actions: │ [CodeAction(CodeAction { title: "Organize Imports (Biome)", kind: Some(CodeActionKind("source.organizeImports.biome")), diagnostics: None, edit: Some(WorkspaceEdit { changes: Some({Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/Users/michael/Code/client-app/packages/functions/handlers/AbstractApiHandler.ts", query: None, fragment: None }: [TextEdit { range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 11 } }, new_text: "{ assertUser }" }, TextEdit { range: Range { start: Position { line: 0, character: 19 }, end: Position { line: 0, character: 23 } }, new_text: "api" }, TextEdit { range: Range { start: Position { line: 0, character: 24 }, end: Position { line: 0, character: 28 } }, new_text: "helpers" }, TextEdit { range: Range { start: Position { line: 0, character: 29 }, end: Position { line: 0, character: 33 } }, new_text: "asserts" }, TextEdit { range: Range { start: Position { line: 1, character: 7 }, end: Position { line: 1, character: 19 } }, new_text: "User" }, TextEdit { range: Range { start: Position { line: 1, character: 20 }, end: Position { line: 1, character: 22 } }, new_text: "" }, TextEdit { range: Range { start: Position { line: 1, character: 29 }, end: Position { line: 1, character: 32 } }, new_text: "core" }, TextEdit { range: Range { start: Position { line: 1, character: 33 }, end: Position { line: 1, character: 40 } }, new_text: "auth" }, TextEdit { range: Range { start: Position { line: 1, character: 41 }, end: Position { line: 1, character: 48 } }, new_text: "User" }, TextEdit { range: Range { start: Position { line: 6, character: 50 }, end: Position { line: 7, character: 46 } }, new_text: "" }, TextEdit { range: Range { start: Position { line: 10, character: 0 }, end: Position { line: 10, character: 0 } }, new_text: "import AbstractHandler from \"./AbstractHandler\";\n" }]}), document_changes: None, change_annotations: None }), command: None, is_preferred: Some(true), disabled: None, data: None })] ┌─┘ └─┐biome_lsp::handlers::formatting::format{params=DocumentFormattingParams { text_document: TextDocumentIdentifier { uri: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/Users/michael/Code/client-app/packages/functions/handlers/AbstractApiHandler.ts", query: None, fragment: None } }, options: FormattingOptions { tab_size: 2, insert_spaces: true, properties: {}, trim_trailing_whitespace: Some(true), insert_final_newline: Some(true), trim_final_newlines: Some(true) }, work_done_progress_params: WorkDoneProgressParams { work_done_token: None } }} ├─ 0ms DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: TypeScript { definition_file: false }, variant: Standard, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/michael/Code/client-app/packages/functions/handlers/AbstractApiHandler.ts" } ├─ 0ms DEBUG biome_service::workspace The file has the following feature sets: │ {OrganizeImports: Supported, Lint: Supported, Search: FileNotSupported, Format: Supported} ├─ 0ms DEBUG biome_lsp::handlers::formatting Formatting... ├─ 0ms DEBUG biome_service::workspace::server File capabilities: Js(JsFileSource { language: TypeScript { definition_file: false }, variant: Standard, module_kind: Module, version: ES2022, embedding_kind: None }) BiomePath { path: "/Users/michael/Code/client-app/packages/functions/handlers/AbstractApiHandler.ts" } ├─ 0ms DEBUG biome_service::file_handlers::javascript Options used for format: │ Indent style: Space │ Indent width: 2 │ Line ending: LF │ Line width: 88 │ Quote style: Double Quotes │ JSX quote style: Double Quotes │ Quote properties: As needed │ Trailing commas: All │ Semicolons: Always │ Arrow parentheses: Always │ Bracket spacing: true │ Bracket same line: false │ Attribute Position: Auto │ ├─ 0ms INFO biome_service::file_handlers::javascript Format file /Users/michael/Code/client-app/packages/functions/handlers/AbstractApiHandler.ts └─┐biome_formatter::printer::Printer::print{} ┌─┘ ┌─┘ ├─112m WARN tower_lsp Got a textDocument/didSave notification, but it is not implemented |
same for me |
I'm still using Biome as external formatter. And I can't figure out a working config to have vtsls code actions on format even if my life depends on it. Current config that kinda worked some time ago but not anymore: {
"format_on_save": "on",
"language_servers": [
"vtsls",
"biome",
"!eslint",
"!prettier",
"!typescript-language-server",
"..."
],
"formatter": [
{
"language_server": {
"name": "vtsls"
}
},
{
"external": {
"command": "npx",
"arguments": [
"biome",
"check",
"--write",
"--stdin-file-path={buffer_path}"
]
}
}
],
"code_actions_on_format": {
"source.removeUnusedImports.ts": true
}
}
|
Nothing seems to works with this ide, I tried to configure eslint first, no way to make it work, now trying biome, it works kinda, but organise imports doesn't work, eventhough it works in webstorm, i'm growing tired of fighting against this software tbh. |
Biome import sorting works for me on following the settings mentioned in https://github.com/biomejs/biome-zed Example repo with settings https://github.com/aws/aws-sdk-js-codemod/blob/ac758504da4ccdf2502ead248748e7af8d6053ea/.zed/settings.json#L2-L6 |
This is not working for me with And now this is something that is working for me currently (as local project settings):
It organizes the imports via biome and removes the unused imports (I guess via vtsls). But for some reason is not working on my work machine. Also you need to have:
in your project |
Can someone please check this issue against the newly released version of Biome - 1.9.4. I submitted a small fix for their LSP to correctly report available code actions. I think everything should be working with that version. Thanks! |
Thanks @vitallium ! "language_servers": [
"typescript-language-server",
"biome",
"!vtsls",
"!eslint",
"!prettier",
"..."
],
"formatter": {
"language_server": {
"name": "biome"
}
},
"code_actions_on_format": {
"source.fixAll.biome": true,
"source.organizeImports.biome": true,
"source.removeUnusedImports.ts": true
} |
It seems after landing biomejs/biome#4122 to Biome this LSP action started working. I think we can close this issue as completed. |
Check for existing issues
Describe the bug / provide steps to reproduce it
I have the Biome extension installed and have these settings:
When saving, the TS file is formatted but the imports are not sorted. I believe the LSP is set up correctly since I can manually trigger the code action:
Environment
Zed: v0.146.1 (Zed Preview)
OS: macOS 14.5.0
Memory: 32 GiB
Architecture: aarch64
I've also tried in:
Zed: v0.145.1 (Zed)
OS: macOS 14.5.0
Memory: 32 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your Zed.log file to this issue.
Zed.log
The text was updated successfully, but these errors were encountered: