I have been searching for a way to sort imports in Svelte files. Previously I've used trivago/prettier-plugin-sort-imports but that does not yet work well for Svelte. Does anyone have any other suggestions?
» npm install prettier-plugin-organize-imports
» npm install prettier-plugin-svelte
I'm working with svelte and until now I was formatting files with the LSP. However I wanted to format the imports and added prettierd and a prettier pluguin to format my imports. I configured conform.nvim as
opts = {
formatters_by_ft = {
lua = { "stylua" },
javascript = { "prettierd" },
typescript = { "prettierd" },
svelte = { "prettierd" },
},
format_on_save = {
timeout_ms = 500,
async = false,
lsp_format = "fallback",
},
},But I'm not getting svelte files formatted, if I delete typescript and svelte lines then I get to format with the LSP. I changed prettierd to prettier just to make sure conform was being called and it was. And if I run npx prettier --write "src/**/*.{js,ts,svelte}" imports are formatted as expected.
So I'm a bit lost;
are prettierd and svelteLSP incompatible?
how could I add import formatting to my svelte files?
And, what are the accepted fields of formatters_by_ft?
thank you
» npm install @trivago/prettier-plugin-sort-imports
» npm install @ianvs/prettier-plugin-sort-imports