eseom / nunjucks-template

This is a vscode extension for nunjucks template language which is also available to all Jinja style templates
40 stars 8 forks source link

Customizing Formatting? #15

Closed mattwaler closed 11 months ago

mattwaler commented 4 years ago

Hello!

First of all, this is the best looking nunjucks formatter available, well done!

I was wondering if there is any way to tweak the underlying formatter either via a config file in projects or via VS code settings? I don't see that in the current README.

laberin commented 4 years ago

What formatter do you prefer, for example?

mattwaler commented 4 years ago

Exposing something similar to how prettier works would be awesome if possible! That or just exposing user settings in their JSON file for specific format options like wrapping attributes on new lines, indenting the head and body tags or not, stuff like that.

I'm not entirely sure this is possible but it would be great if it was!

charlesroper commented 3 years ago

Thanks for this extension - I've just tried a bunch of them and yours is best. 🥇

The way the Nunjucks Template Formatter extension makes it easy to change settings is great. Screenshot below. That project is now archived so maybe you could salvage some of the code from there?

For now, do you know if there's a way to force the "End self-closing tags with a space" setting right now? Nunjucks Template Formatter and yours both use prettydiff2 so I'm assuming it should be possible?

Many thanks!

image

anghelos commented 3 years ago

I would also like to be able to keep line breaks. It makes my files much more legible!

mattwaler commented 2 years ago

Closing because this seems inactive!

eseom commented 2 years ago

@anghelos a "preserveEmptyLine" configuration was added.

Im about to see Nunjucks Template Formatter Any suggestion is welcome

anghelos commented 2 years ago

@eseom awesome, thanks! It looks like there are still a few bugs with indentation and new lines, however. I'll open a new issue for clarity.

bruno-vaz commented 2 years ago

It would really help if the extension could respect/inherit the html.format settings, now when I activate this extension, it stops respecting the html.format.wrapAttributes setting. I don't know the complexity of implementing such a feature but I don't understand why VS Code formatters for HTML-like template languages have this problem and apparently have to reimplement basic HTML formatter settings.

eseom commented 2 years ago

It would really help if the extension could respect/inherit the html.format settings, now when I activate this extension, it stops respecting the html.format.wrapAttributes setting. I don't know the complexity of implementing such a feature but I don't understand why VS Code formatters for HTML-like template languages have this problem and apparently have to reimplement basic HTML formatter settings.

First of all, because of the template syntax like {{ variable }}, a new formatter have to be implemented for the formatting. This extension is using prettydiff2, Fortunately it supports a lot of options for formatting. I think it would support the option like the wrapAttributes. Instead of inheriting the original formatter, it had better to adjust the options into prettydiff2.

Could you list what options would be needed except wrapAttributes?

iamrealmarsel commented 1 year ago

It would be great if this extension had options like here VS Code Twig Language 2

as an example, some of the options from there: Screen Shot 2022-11-04 at 9 54 00 PM

mattwaler commented 11 months ago

Closing as stale.