sveltejs / prettier-plugin-svelte

Format your svelte components using prettier.
MIT License
714 stars 95 forks source link

Svelte 5: using snippets, breaks the formatting functionality #439

Closed rayl0 closed 2 months ago

rayl0 commented 2 months ago

I don't know if some people are experiencing this issue or is it only me, but I am having serious headaches, I am using svelte 5, and whenever I use "Snippets", the code won't format. If I remove them, and only use slots, it works fine.

rayl0 commented 2 months ago

I don't know what I was doing, but the problem was me not using prettier-plugin-svelte at all

felixakiragreen commented 3 weeks ago

I had the same problem, the svelte create app doesn't generate a prettier config file, so I had to make my own. I thought it was working because of my prettier config inside vscode settings.

geshov commented 2 days ago

I have the same problem on Svelte 5 - when using snippets, the plugin "Svelte for VS Code" stops formatting code in the file .svelte,

The project was created according to the instructions on the official Svelte website:

npm create vite@latest my-svelte-project -- --template svelte

Considering that SvelteKit users do not have this problem, I suspect that it can be solved with the help of some additional settings.

dummdidumm commented 2 days ago

That project doesn't come with prettier installed, you need setup prettier yourself according to https://github.com/sveltejs/prettier-plugin-svelte?tab=readme-ov-file#setup

geshov commented 2 days ago

That project doesn't come with prettier installed, you need setup prettier yourself according to https://github.com/sveltejs/prettier-plugin-svelte?tab=readme-ov-file#setup

According to this instruction, formatting is performed by a command from the CLI, after installing these packages, it is unclear whether formatting will work in the editor using the plugin "Svelte for VS Code"?

Thanks!