How to know the context / parent element when inside YAML? if possible at all


I’m creating a YAML editor for a small part of my service, and I’d like to provide some autocomplete, the capabilities of CodeMirror are so far beyond amazing but I wanted to know the possibility of knowing where I am inside the document.
e.g. consider the following YAML

id: "someAlpaNum"
    category: "category-name"
    template: "template-name"
    - first_operation: ["blabla", "bla bla bla"]
    - "<---How to know that I'm inside 'operations' here if did auto-complete"
          - "<----how to know here too that I'm inside 'child' "

Is there away to know if I’m inside the sections above in YAML?


You could consider reading the source of the YAML mode to figure out if it puts anything in its state object that you can work with, and use getTokenAt to retrieve that state at a given position. I didn’t write that mode so I can’t tell you how to use it off the top of my head.


@marijn it’s really amazing how responsive you always are, regardless of whether you have an answer or not.

Keep up the great work, thumbs up.