Is your feature request related to a problem? Please describe.
I work on vscode-yaml, and we're investigating using the toString() function from parsed YAML documents to replace the implementation of our formatting feature. Our current implementation uses prettier to format the document. For the most part, we're able to provide all the same formatting options with toString() as we are with prettier.
However, one of the options prettier provides is called trailingComma; enabling it, then formatting turns something like this:
key:
[
"value1",
"value2",
"value3",
"value4",
"value5",
"value6",
"value7",
"value8",
"value9"
]
into this (note the added comma):
key:
[
"value1",
"value2",
"value3",
"value4",
"value5",
"value6",
"value7",
"value8",
"value9",
]
This isn't provided as an option currently in ToStringOptions.
Describe the solution you'd like
A new boolean option to ToStringOptions that, when enabled, adds a trailing comma when a flow sequence or flow map is split across multiple lines.
Describe alternatives you've considered
We could remove this formatting option from vscode-yaml, stick with using prettier for formatting, or write our own formatter.
Additional context
I'm willing to implement this functionality if it's something you're okay with having in the repo. I also understand if you don't want to add more options to the toString() functionality.
Here are some relevant issues where we talked about changing the implementation of vscode-yaml's formatter:
Is your feature request related to a problem? Please describe.
I work on vscode-yaml, and we're investigating using the
toString()function from parsed YAML documents to replace the implementation of our formatting feature. Our current implementation uses prettier to format the document. For the most part, we're able to provide all the same formatting options withtoString()as we are with prettier.However, one of the options prettier provides is called
trailingComma; enabling it, then formatting turns something like this:into this (note the added comma):
This isn't provided as an option currently in
ToStringOptions.Describe the solution you'd like
A new boolean option to
ToStringOptionsthat, when enabled, adds a trailing comma when a flow sequence or flow map is split across multiple lines.Describe alternatives you've considered
We could remove this formatting option from vscode-yaml, stick with using prettier for formatting, or write our own formatter.
Additional context
I'm willing to implement this functionality if it's something you're okay with having in the repo. I also understand if you don't want to add more options to the
toString()functionality.Here are some relevant issues where we talked about changing the implementation of vscode-yaml's formatter: