Implement inheritance of config trees (without YAML anchors...) #1063
Labels
enhancement
New feature or request
feature-request
User requested features
frontend
Contour Terminal Emulator (GUI frontend)
Because YAML anchors do not allow specialising a child node of an anchored-in tree, we need to instead roll our own joint of merging user-specific changes via inheritance.
Use case
default
which is what contour supplies, then I havemaster
andlight
which are two themed customised things). When Contour comes with changes to the default schema, it's a PITA to upgrade the other two profiles because a simple diff tool just can't help as my custom profiles are always additions versus the default.Proposal
1. Hardcode for each top-level listing map (e.g.
profiles
andcolour_schemes
) the__default__
key. This is the key where Contour's "official" configuration should be put (e.g., in thecontour generate config ...
output).This will make updates to the official configuration easier, as we need to only update one well-defined and reserved tree.
2. (Optionally) Introduce the
__inherits__
or__base__
(I'm purposefully using some reserved underscore mangling yadda here) which takes as an argument a single (or multiple?) other named entity from the same tree: e.g., a profile might inherit another profile.This could make custom configurations more composable (a'la CMakePresets), but might make the implementation unnecessarily messy!
3. (Irrespective of whether 2. is implemented...) when resolving a specific
<top-level-tree-structure>.<user-defined-identifier>.whatever.blah
key, use the following logic (in this example, rolling with the profiles, but thecolour_schemes
is the same yadda!):profiles.foo.whatever.blah
exist, resolve to that value.profiles.foo.whatever.blah
does not exist, butprofiles.<T>.whatever.blah
exists, resolve to that.<T>
is that<T>
is the last in that list<T>
is__default__
4. When new keys are added to the schema (a.k.a. when the warning mentioned above is emitted), optionally offer merging such changes into the
__default__
base "class". This way, it will also automatically be inherited into every user-customised profile.Example
With this, I could achieve the following way of customisation which would make my profile YAML easier to read and edit:
Why not YAML anchors instead?
YAML anchors do not support the use case described in this ticket, and the
Expectation:
line above does NOT hold...The text was updated successfully, but these errors were encountered: