toml-sort icon indicating copy to clipboard operation
toml-sort copied to clipboard

more line spacing (optional)?

Open brody4hire opened this issue 1 year ago • 0 comments

I was hoping I could use toml-sort to maintain & preserve formatting of something like this:

[a.config]
list1 = [
    "abc",
    "def",
    "ghi",
]

value1 = 123 # abc


[b.config]
value2 = 456

list2 = [
    7, # def
    8,
    # ghi
    9,
]

context: I can use toml-sort as a TOML formatting tool with the --no-sort-tables option, haven't found anything better for Python so far. Just have to find a way to work this issue, and avoid orphaned comments like I described in: https://github.com/pappasam/toml-sort/issues/59#issuecomment-1749860965


Possible workaround solution though ugly with some more comments added (with --spaces-indent-inline-array & --trailing-comma-inline-array options, of course):

# configure some things

[a.config]
list1 = [
    "abc",
    "def",
    "ghi",
]
# ---
value1 = 123 # abc

# ---
# configure specific things for b
[b.config]
value2 = 456
# ---
list2 = [
    7, # def
    8,
    # ghi
    9,
]

I may try to develop & propose a better solution, time permitting.

brody4hire avatar Oct 06 '23 01:10 brody4hire