I have recently ran into an issue when folding YAML in neovim in which all comments following a sequence get folded with the sequence instead of being left alone.
An example might illustrate the point. Given the following YAML document:
Key1:
- value 1
- value 2
# This is a comment to Key 2, it should not belong to the mapping above
Key2: "Value"
We can see from TSPlayground that the comment ends up nested inside of the block_mapping.
This is particularly annoying since it's common to add comments above the keys in YAML. In fact, this style of comment features throughout the documentation.
Comments are a presentation detail and must not have any effect on the serialization tree or representation graph. In particular, comments are not associated with a particular node. The usual purpose of a comment is to communicate between the human maintainers of a file. A typical example is comments in a configuration file. Comments must not appear inside scalars, but may be interleaved with such scalars inside collections.
Although, this is open to interpretation I think it would be desirable that the grammar takes comment indentation when parsing. This will allow for a more readable document when folded.
I have recently ran into an issue when folding YAML in neovim in which all comments following a sequence get folded with the sequence instead of being left alone.
An example might illustrate the point. Given the following YAML document:
We can see from
TSPlayground
that the comment ends up nested inside of theblock_mapping
.So when folded, comment to Key 2 are hidden away.
This is particularly annoying since it's common to add comments above the keys in YAML. In fact, this style of comment features throughout the documentation.
Moreover, the documentation says:
Although, this is open to interpretation I think it would be desirable that the grammar takes comment indentation when parsing. This will allow for a more readable document when folded.