Describe the bug
When a .svelte document is formatted on save the indentation does not change.
To Reproduce
.svelte fileExpected behavior
I expect the code to be formatted on save.
Screenshots
An example of code not being formatted below.

System (please complete the following information):
Additional context
I'm using this with .editorconfig.
Does this mean if you do formatting "by hand" (with the sortcut/command) the code is formatted? Or is it not formatted at all?
I tried debugging it further. I tried including a .prettierrc config and installing Prettier and I was able to get something working. Since disabling Prettier and removing the .prettierrc config it no longer has the issue and it formats on save. My guess would be that even before formatting by hand wouldn't have worked.
I should uninstall VScode and try from scratch if I get time.
I'm not familiar with how formatting works, but I'm thinking about the following scenarios:
.prettierrc config?.editorconfig? Currently, editor config works when .prettierrc is present..prettierrc config.editorconfig, but this can be added.Under the hood, formatting works like the following:
prettier-plugin-svelte.If you try to format but it does not format anything, could you look into Output->Svelte and see if there is anything suspicious (or just copy the log in here)?
Thanks for clarifying those points. If I get chance I'll try re-installing VScode and trying to reproduce the issue.
I do have the same error. The code does not get modified on save.\
This only occurs in .svelte files, other files will get auto-formatted on save.\
My Output->Svelte only prints the Line Using Svelte v3.24.0 from ....\
Output->Prettier keeps empty on .svelte files, but works as expected and fills output on other files (eg: js, ts, ..)
Triggered via console prettier --write "**/*.{css,html,js,json,md,scss,svelte,ts,yml}", svelte files will get auto-formatted - but not after save in vs-code.
Does it format if you explicitely invoke the "format" command, or does it not format at all?
Does it format if you explicitely invoke the "format" command, or does it not format at all?
If i force vs-code format (ctr + shift + i), it does format all files except *.svelte files.
There is a setting svelte.format.enable, is it set to true in your settings?
You said that inside Output-Svelte, only Using svelte ... is shown, which means it does not even get to the formatting code. If it would, there should be Using Prettier ... in the output as well.
There is a setting
svelte.format.enable, is it set totruein your settings?
Yes, this setting is true
You said that inside Output-Svelte, only
Using svelte ...is shown, which means it does not even get to the formatting code. If it would, there should beUsing Prettier ...in the output as well.
It seems to me that IDE and console does not work with the same options / settings.
Yesterday i added the option to preprocess sass, which works nice, without any problems (via cli webpack-dev-server --config config/webpack.config.js --progress), but the IDE throws an error (Output Svelte):
Using Svelte v3.24.0 from /home/user/path/project/node_modules/svelte/compiler
Preprocessing failed
Error: Cannot find any of modules: sass,node-sass
at Object.importAny (/home/user/path/project/node_modules/svelte-preprocess/dist/modules/importAny.js:29:15) {
__source: 'Style'
}
Maybe this is related..
I think this is an unrelated issue. You need to install either sass (recommended) or node-sass. See here for more info.
I think this is an unrelated issue. You need to install either
sass(recommended) ornode-sass. See here for more info.
Thanks for the link. I just added the node binary path into svelte.language-server.runtime, which resolves the none-sass error :zap:.
The settings svelte.language-server.ls-path and svelte.language-server.port are empty. All other settings like svelte.plugin.typescript.enable are enabled.
Possible reason: https://github.com/sveltejs/prettier-plugin-svelte/issues/74#issuecomment-665831712
@s0me0ther @limitlessloop could you check if this could be the cause of your problem? https://github.com/sveltejs/prettier-plugin-svelte/issues/74#issuecomment-665831712
@s0me0ther @limitlessloop could you check if this could be the cause of your problem? sveltejs/prettier-plugin-svelte#74 (comment)
@dummdidumm , this works great for svelte files now, thank you!\
But, if i change the default formatter from esbenp.prettier-vscode to svelte.svelte-vscode i can only format svelte files :/.\
Is there a way to use different formatters on different filetypes?
Did you set the default to all the file type?
Did you set the default to all the file type?
Yes i did. I'm pretty new to VSCode..\
Now i use following Settings, which works like a charm:
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},
Thank you all for solving this Issue!
Most helpful comment
Yes i did. I'm pretty new to VSCode..\
Now i use following Settings, which works like a charm:
Thank you all for solving this Issue!