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:
document [0, 0] - [6, 0]
block_node [0, 0] - [6, 0]
block_mapping [0, 0] - [6, 0]
block_mapping_pair [0, 0] - [4, 62]
key: flow_node [0, 0] - [0, 4]
plain_scalar [0, 0] - [0, 4]
string_scalar [0, 0] - [0, 4]
value: block_node [1, 2] - [4, 62]
block_sequence [1, 2] - [4, 62]
block_sequence_item [1, 2] - [1, 11]
flow_node [1, 4] - [1, 11]
plain_scalar [1, 4] - [1, 11]
string_scalar [1, 4] - [1, 11]
block_sequence_item [2, 2] - [2, 11]
flow_node [2, 4] - [2, 11]
plain_scalar [2, 4] - [2, 11]
string_scalar [2, 4] - [2, 11]
comment [4, 0] - [4, 62]
block_mapping_pair [5, 0] - [5, 13]
key: flow_node [5, 0] - [5, 4]
plain_scalar [5, 0] - [5, 4]
string_scalar [5, 0] - [5, 4]
value: flow_node [5, 6] - [5, 13]
double_quote_scalar [5, 6] - [5, 13]
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.
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
TSPlaygroundthat 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.