Add fold regions to Tables and TableArrays #65
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tables and TableArrays are folded when
foldmethod=syntax
is set.The folds are implemented by a single regex which matches the table and table array headers. This has to replicate a large part of the syntax for TOML keys, so the regex becomes a bit involved. Fold levels are limited to 1 for a table and 0 for the part before the first table. This is because dictionary depth cannot be parsed from the header with a regex and cannot be communicated to vim by syntax statements anyway.
There is an edge case where a valid inline array looks like a table header, and is detected as such. This is hopefully rare enough in practice to not matter. A demonstration of this is added to
test.toml
.This perhaps could have been implemented with a clever use of
contains
,containedin
etc., but that would require a larger refactoring and maybe fixing of other bugs such as #58.Fixes #63.