jens1o / vscode-smarty

Smarty syntax highlight extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=imperez.smarty
GNU General Public License v3.0
14 stars 9 forks source link

There is no document formatter for smarty files installed #18

Open JPustkuchen opened 6 years ago

JPustkuchen commented 6 years ago

Hi, thank you for this great tool!

Can you tell how I can enable code formatting (alt+shift+f) for smarty files or at least handle it like HTML? The emmet code snippet on the module page didn't help.

I think many users will have that problem.

jens1o commented 6 years ago

This is not supported currently.

How would you expect it to be formatted? (Could you give us an example, please?)

JPustkuchen commented 6 years ago

Minimum would be HTML formatting and handling smarty like text. I'm not sure how it will behave. Perfect solution would be to format it like in other languages: indent loops / conditionals, etc.

Examples can be seen in the shopware documentation e.g.: https://developers.shopware.com/designers-guide/smarty/

JPustkuchen commented 6 years ago

But yes, handling like HTML would be a good first step for .tpl files. Currently there is no formatting possible at all and when switching them to html in configuration smarty syntax is no more being highlighted.

jens1o commented 6 years ago

Okay, that's indeed very nice formatting. I'll look in my holidays(~ next 6 weeks) how I can implement that and what I need to do.

JPustkuchen commented 6 years ago

Very cool, thank you! I think some IDEs like PHPStorm already solve this. You may test a demo to see what they do.

kruzyk commented 5 years ago

Hi, any progress? :)

jens1o commented 5 years ago

Good ping, I honestly forgot about this. Unfortunately, I'm busy at the moment. If somebody wants to provide a pull request, I'd be very glad to merge it.

carlittoer commented 5 years ago

Hi,

Enabling the HTML formatter for smarty templates as a minimum would make the plugin much more useful.

Thanks.

kruzyk commented 5 years ago

@jens1o hmm I could try at least :) Any tips?

jens1o commented 5 years ago

First of all, thank you for your interest and time @kruzyk . :)

You could try implementing the same https://github.com/FabianLauer/vs-code-xml-format/blob/3402b6e5ce656bd930948ae6990638042d2af960/src/extension.ts

If we're lucky enough, the xml formatter is clever enough to just ignore smarty-specific syntax. :)

agiannis commented 4 years ago

This is a good feature to have . As workaround you could change to html with Ctrl+Shift+P , "Change Language Mode". Format and then go back to smarty.

kruzyk commented 4 years ago

@jens1o I tried to use the xml formatter with some minor changes, but unfortunately it didn't handle. Would you find time to deal with this topic? I know that smarty is old technology, but still used in many companies and a lot of people would use it :)