Skip to content

Provide anchor references as links #541

@remcohaszing

Description

@remcohaszing

Is your enhancement related to a problem? Please describe.

yaml-language-server turns JSON pointer references into links based on vscode-json-languageservice. YAML has a native support to references though: anchors. It makes sense to support anchors instead of or in addition to JSON pointers.

Describe the solution you would like

The links provider should provide links for anchors. The solution is fairly simple. In src/languageservice/services/yamlLinks.ts:

  • Iterate over the AST
  • Register an anchor by name if found
  • Create a link to an anchor when an anchor id is found

Do this for every SingleYAMLDocument.

Describe alternatives you have considered

N/A

Additional context

I tried this. yaml-language-server-parser supports anchors, but the conversion to the vscode-json-languageservice compatible AST removes all anchors and anchor references. I tried adding it, but it doesn’t really have a good place inside this AST format.

It’s probably best to wait for the new AST format introduced in #442

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions