feature request: Organize import using Biome.js for typescript, javascript, typescriptreact, javascriptreact
Did you check existing requests?
- [X] I have searched the existing issues
Describe the feature
I want to organize the imports using biome.js when I format my buffer/file using biome.js for typescript, javascript, typescriptreact, javascriptreact
Provide background
No response
What is the significance of this feature?
strongly desired
Additional details
For now I am using the args to organize the imports. But it is highly recommend to have a config to organize the imports using biome
This is a workaround for now
-- confirm.lua
return {
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
lua = { "stylua" },
["javascript"] = { "biome" },
["javascriptreact"] = { "biome" },
["typescript"] = { "biome" },
["typescriptreact"] = { "biome" },
["json"] = { "biome" },
["css"] = { "biome" },
},
formatters = {
biome = {
command = "biome",
args = { "check", "--formatter-enabled=true", "--linter-enabled=false", "--organize-imports-enabled=true", "--write", "--stdin-file-path", "$FILENAME" },
},
},
},
},
}
According to the docs it looks like the formatter, linter, and import sorter are all enabled by default. The default conform biome formatter calls biome format. If you want to use biome check, use the biome-check formatter.
Also, to make changes to a formatter args, you can provide append_args or prepend_args instead of overriding the args entirely.
@stevearc Yes I can pass args but I can't pass the arg --import-sort-enable to the biome format command because it doesn't support that arg
@stevearc can you share any config with biome-check.
@rahulpeacock I had some luck with this setup.
@andrew-t-james-core this is also a workaround but is there a default config from conform ??
Can you not just use the built-in biome-check formatter? It runs biome check which, from my understanding, will organize the imports
formatters_by_ft = {
lua = { "stylua" },
["javascript"] = { "biome-check" },
["javascriptreact"] = { "biome-check" },
["typescript"] = { "biome-check" },
["typescriptreact"] = { "biome-check" },
["json"] = { "biome-check" },
["css"] = { "biome-check" },
},
Can you not just use the built-in
biome-checkformatter? It runsbiome checkwhich, from my understanding, will organize the importsformatters_by_ft = { lua = { "stylua" }, ["javascript"] = { "biome-check" }, ["javascriptreact"] = { "biome-check" }, ["typescript"] = { "biome-check" }, ["typescriptreact"] = { "biome-check" }, ["json"] = { "biome-check" }, ["css"] = { "biome-check" }, },
This works for me 🚀
@stevearc would you be willing to accept updates to the biome formatters descriptions to explicitly call out the differences between biome, biome-check and biome-organize-imports?
It took me quite some time to understand that there were 3 separate builtin formatters that are all associated to biome and this seems to be a common issue.
@gugahoi yeah if you want to clarify these formatters I would be happy to review it
Can you not just use the built-in
biome-checkformatter? It runsbiome checkwhich, from my understanding, will organize the importsformatters_by_ft = { lua = { "stylua" }, ["javascript"] = { "biome-check" }, ["javascriptreact"] = { "biome-check" }, ["typescript"] = { "biome-check" }, ["typescriptreact"] = { "biome-check" }, ["json"] = { "biome-check" }, ["css"] = { "biome-check" }, },
idk why biome-organize-imports not working but biome-check does work