Relational
Several syntaxes such as Python, JavaScript or JSON support data objects in the form of arrays, lists or key-value pairs.
Those data objects can be grouped into:
- sequences
- arrays (C, C++, ...)
- lists (Python, JS, JSON, ...)
- vectors (C++ std/boost library)
- ...
- mappings (aka. key-value pairs)
- dictionaries (VBScript)
- maps (C++ std/boost library)
- objects (JSON)
- ...
That's pretty clearly expressed by meta scopes meta.sequence and meta.mapping.
List separators are commonly scoped punctuation.separator.sequence.
The situation with mapping punctuations seems a bit more unclear at the moment which caused in several solutions having found their way into the wild.
Motivation
The current situation is reflected by a couple of discussions started in pending PRs, such as #2682 (comment) or #2564 (comment) which re-introduces punctuation.separator.mapping to YAML, while it has been removed by 60e7c39.
If this topic has been discussed somewhere the related posts seem lost. Hence it may make sense to come up with a guideline how to commonly scope punctuations in data objects such as mappings or sequences in a (this) RFC issue.
Current Situation
The following table, started by @jwortmann, illustrates currently used scopes for separators of key-value pairs.
Notes:
- * not sure whether the Lua tables are directly comparable to the other mappings listed here
- Some other syntaxes use
punctuation.separator.key-value in non-data-object related expressions.
The concluding question is about priority of key-value vs. mapping or about which of both the more general part of a scope name is.
Both scope naming schemes punctuation.separator.key-value and punctuation.separator.mapping are both used with nearly the same amount, while the latter one found its way into syntaxes by being suggested by PackageDev's auto-completions.
Suggestion
We should probably condence those scopes to ...
punctuation.separator.key-value for key-value separaotrs
punctuation.separator.sequence for array items, list items and key-value-pairs
Reasons
- Not all syntaxes know about the concept of dictionaries/objects/mappings but still need a way to separate property keys from values.
- As a result of 1.
punctuation.separator.key-value seems the more general scope which color schemes can use to target most possible tokens with just one simple selector.
- If it seems important to distinguish key-value separators of mappings from others
meta.mapping punctuation.separator.key-value or ``punctuation.separator.key-value.mapping` may be used.
- A dictionary/object/mapping can be interpreted as a list of key-value pairs. Hence
punctuation.separator.sequence seems suitable to separate key-value pairs.
- To further justify
punctuation.separator.sequence - both, lists and objects often use the same character (e.g.: comma ,) to separate list items and key-value pairs (see: JSON). A common scope ensures both to be highlighted the same way by all color schemes. Further distinctions can be made by eighter meta.mapping punctuation.separator.sequence - meta.mapping meta.sequence or punctuation.separator.sequence.mapping if really needed.
Alternative
Distinguish between real data lists/objects and other kinds of key-value pairs, which means to keep punctuation.separator.mapping.key-value and punctuation.separator.key-value.
Relational
Several syntaxes such as Python, JavaScript or JSON support data objects in the form of arrays, lists or key-value pairs.
Those data objects can be grouped into:
That's pretty clearly expressed by meta scopes
meta.sequenceandmeta.mapping.List separators are commonly scoped
punctuation.separator.sequence.The situation with mapping punctuations seems a bit more unclear at the moment which caused in several solutions having found their way into the wild.
{"key1": "value1", "key2": "value2", ...} // ^ punctuation.separator.??? // ^ punctuation.separator.???Motivation
The current situation is reflected by a couple of discussions started in pending PRs, such as #2682 (comment) or #2564 (comment) which re-introduces
punctuation.separator.mappingto YAML, while it has been removed by 60e7c39.If this topic has been discussed somewhere the related posts seem lost. Hence it may make sense to come up with a guideline how to commonly scope punctuations in data objects such as mappings or sequences in a (this) RFC issue.
Current Situation
The following table, started by @jwortmann, illustrates currently used scopes for separators of key-value pairs.
:or=,or;meta.mappingpunctuation.separator.key-valuepunctuation.separator.mapping.pairpunctuation.separator.mapping.key-valuepunctuation.separator.key-valuepunctuation.terminator.rulepunctuation.separator.mapping.key-valuepunctuation.separator.sequencepunctuation.separator.mapping.key-valuepunctuation.separator.mapping.pairpunctuation.separator.mapping.key-valuepunctuation.separator.mapping.pairpunctuation.separator.mapping.key-valuekeyword.operator.assignmentpunctuation.separator.key-valuepunctuation.separator.commapunctuation.separator.key-valuepunctuation.separator.fieldpunctuation.separator.key-valuepunctuation.separator.sequencepunctuation.separator.key-valuepunctuation.separator.sequencepunctuation.separator.mapping.key-valuepunctuation.separator.mappingpunctuation.separator.key-value.mappingNotes:
punctuation.separator.key-valuein non-data-object related expressions.The concluding question is about priority of
key-valuevs.mappingor about which of both the more general part of a scope name is.Both scope naming schemes
punctuation.separator.key-valueandpunctuation.separator.mappingare both used with nearly the same amount, while the latter one found its way into syntaxes by being suggested by PackageDev's auto-completions.Suggestion
We should probably condence those scopes to ...
punctuation.separator.key-valuefor key-value separaotrspunctuation.separator.sequencefor array items, list items and key-value-pairsReasons
punctuation.separator.key-valueseems the more general scope which color schemes can use to target most possible tokens with just one simple selector.meta.mapping punctuation.separator.key-valueor ``punctuation.separator.key-value.mapping` may be used.punctuation.separator.sequenceseems suitable to separate key-value pairs.punctuation.separator.sequence- both, lists and objects often use the same character (e.g.: comma,) to separate list items and key-value pairs (see: JSON). A common scope ensures both to be highlighted the same way by all color schemes. Further distinctions can be made by eightermeta.mapping punctuation.separator.sequence - meta.mapping meta.sequenceorpunctuation.separator.sequence.mappingif really needed.Alternative
Distinguish between real data lists/objects and other kinds of key-value pairs, which means to keep
punctuation.separator.mapping.key-valueandpunctuation.separator.key-value.