asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
341 stars 97 forks source link

Autocompletion for references #648

Open jens-auer opened 2 years ago

jens-auer commented 2 years ago

Similar to autocompletion for image and include files (#377), I would like to use autocompletion for internal and external references.

Details:

Background: We import requirements from a requirement management tool and reference them in the text. Autocomplete would reduce errors and provide better efficiency.

ggrossetie commented 2 years ago

Are you talking specifically about Antora xref or AsciiDoc xref?

jens-auer commented 2 years ago

AsciiDoc xref (https://docs.asciidoctor.org/asciidoc/latest/macros/inter-document-xref)

kharann commented 2 years ago

Agreed! This would be a nice feature :)))

apupier commented 2 years ago

The IDs that can be referenced are these ones? https://docs.asciidoctor.org/asciidoc/latest/attributes/id/

@Mogztter Do we already have an utility parsing .adoc files to retrieve all IDs of a document?

I think that we can split this task with:

ggrossetie commented 2 years ago

Do we already have an utility parsing .adoc files to retrieve all IDs of a document?

I guess you can load the document and retrieve anchors using the catalog:

The processor always cataloged the following assets, regardless of this setting: block or inline anchors (key: :refs) (...) https://docs.asciidoctor.org/asciidoctor/latest/api/catalog-assets/#what-assets-are-cataloged

ggrossetie commented 2 years ago

Provide completion for other document in the workspace when typing xref: (should we restrict to .adoc document?)

Yes I think we should restrict to .adoc. This file extension will most likely be used in the mime-type registration.

apupier commented 2 years ago

After I discovered that some part was already implemented and based on first feedback on my 2 initial pull requests, Here is a new proposal to the split of tasks: