moetelo / twiggy

Twig language support for VS Code and Neovim.
https://marketplace.visualstudio.com/items?itemName=moetelo.twiggy
34 stars 4 forks source link

Twig formatting #4

Open ajiho opened 11 months ago

ajiho commented 11 months ago

First of all, thank you for this plugin,Because I spend most of my time writing HTML code, I think losing HTML intellisense would be very painful for me,And I habitually format the code (shift+alt+f), and vscode will prompt me that there is no formatting program,I don't want to go back to PHP Storm, so if there is a better development experience, I would like to get some advice from you

moetelo commented 7 months ago

https://github.com/VincentLanglet/Twig-CS-Fixer This could work.

Don't want to integrate prettydiff here like the vscode-twig-language-2 does because prettydiff itself is not well maintained (no code changes since 2019, only the readme.md updates).

moetelo commented 7 months ago

I see that VincentLanglet/Twig-CS-Fixer fixes only Twig-related issues. We need something above it to also format HTML.

vralle commented 7 months ago

Hi there! How about built-in HTML formatter? VS Code has perfect HTML support, HTML language server and Handlebars support. settings.json:

{
    "html.format.indentHandlebars": true,
    "html.format.templating": true,
}
moetelo commented 6 months ago

@vralle

VSCode-only solution is ok, but I'd rather add something that's editor-independent.

vsc uses js-beautify under the hood (code ref)

There is also an issue for Twig: https://github.com/beautifier/js-beautify/issues/991


This could work: https://github.com/zackad/prettier-plugin-twig-melody