yaml-language-server
yaml-language-server copied to clipboard
Add indent on json stringify of examples
Hi, when doing examples if it is an object, or array and not a primitive type, the examples section isn't that useful, if a large object is shown, would it be possible to add indentation to the examples
https://github.com/redhat-developer/yaml-language-server/blob/220519da363544f659e63302fc31bdda0800c34c/src/languageservice/services/yamlHover.ts#L149
I'd be happy to add it if it is something we want =D
probably something like this:
s.schema.examples.forEach((example) => {
markdownExamples.push(JSON.stringify(example, null, 4 / '\t'));
});
So instead of
```{"someObject": {"someProperty": "someValue"}}```
it would be
\```
{
"someObject": {
"someProperty": "someValue"
}
}
\```
The ` formatting was a bit messed up.
If we were more ambitious we could probably even output it as yaml instead, which is more fitting to the package name =D
I think this function can be helpful on how to implement this. I would be happy to review if you send a PR.