Open OldStarchy opened 5 years ago
I have some issue.
This is happening to us as well. It is causing problems in our workflow. Any solution?
Hey guys, thank you for creating issues and using my extension. Definitely check out Prettier twig melody because that seems to be in active development and has a big company behind it. This extension relies on PrettyDiff 3 and so some bugs are out of my ability to fix. I’ll ensure that the version of PrettyDiff is updated, however, I’m not certain it will fix this annoying bug
Thank you for the reply Matthew. I will check out that extension. I appreciate all the work you have done on this project.
anyone know how to fix this annoying error? i have to put to avoid block indent
This underlying formatter PrettyDiff hasn't seen any attention for a while now. I know it's no help but I ended up disabling the formatter completely, since there are also other issues like not respecting whitespace. Having no formatter is better than a formatter that is going to potentially break your code.
have the same problem here and ... i disable the extension, because i lost more time unindent than formating XD
I solve this problem with 'prettier-plugin-twig-melody' and prettier config only for twig files
Use .prettierrc.json
{
"endOfLine": "crlf",
"tabWidth": 4,
"useTabs": true,
"printWidth": 120,
"singleAttributePerLine": true,
"twigPrintWidth": 120,
"twigAlwaysBreakObjects": true,
"twigMultiTags": [
"nav,endnav",
"switch,case,default,endswitch",
"ifchildren,endifchildren",
"cache,endcache"
],
"plugins": ["./node_modules/prettier-plugin-twig-melody"]
}
My VSCode Settings for twig
"[twig]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"twig-language-2.braces": false,
"twig-language-2.bracePadding": true,
"twig-language-2.formatting": false,
"twig-language-2.formatArray": "indent",
"twig-language-2.formatObject": "indent",
"twig-language-2.ternaryLine": true,
@OldStarchy did you find a solution? I have the same problem
No. I stopped using a formatter and just did it manually.
I realized the problem is intrinsic to text-based templating languages, which is pretty much all of them. Its impossible to "correctly" format a templating language because its possible for the template to produce invalid output which cannot be formatted. Unless you just ignore the output and only format the control structures of the template language itself, but that won't necessarily make it look nice.
Now I don't use any templating language and instead use (p)react.