maxbec / openHAB-Alignment-Tool

This extension adds support for formatting and indenting openHAB files. At the moment only the item-files are supported.
https://marketplace.visualstudio.com/items?itemName=max-beckenbauer.oh-alignment-tool
Eclipse Public License 2.0
21 stars 4 forks source link

User defined formatting-groups #29

Closed CWempe closed 4 years ago

CWempe commented 4 years ago

I think the new feature reformat at save is not usable when you want to reformat parts of your file different that the rest. (like #7)

So I propose a feature where you can define "formatting groups" inside your files.

This is some example code:

Switch  Awtrix01AppstateTime    "Time"  <switch>            {mqtt=">[mosquitto:awtrix/basics:command:ON:{\"enable\"\\: \"Time\"}],
                                                                   >[mosquitto:awtrix/basics:command:OFF:{\"disable\"\\: \"Time\"}]"}

Switch  HTPC_Online                                         {channel="network:pingdevice:htpc:online"}
Switch  PC_Online                                           {channel="network:pingdevice:pc:online"}
Switch  AVR_Online                                          {channel="network:pingdevice:avr:online"}
Switch  Beamer_Online                                       {channel="network:pingdevice:epson:online"}

Reformatting the whole document results in this:

image

It would look better if the lower group of items would be reformated seperately from the first line/group. Maybe this could be implemented with some kind of special comment that gets recognized by the plugin and treats all following lines as a new group until the next special group-comment is detected.

image

maxbec commented 4 years ago

A very good idea. I already thought about this. I dont know yet if it will be in the V2 release but i keep it in mind.

maxbec commented 4 years ago

With

// ##OHNG##

you habe the opportunity to start a new formatting group.