xref autocomplete in VSCode

13 views
Skip to first unread message

phario

unread,
Sep 8, 2025, 8:54:15 AMSep 8
to PreTeXt support
Hi, 

One of the current issues I have in writing is the lack of autocomplete functionality on cross-referencing. Here, with most editors, when you do a cross-reference, say to

<xref id="thm-picard">

You'd like to have autocomplete functionality on "thm-"

Has anyone looked into this possibility? 

Not being able to do autocomplete on theorems, equations, etc. really hampers the ability to write. Currently, I have to look at the HTML (or whatever output), search for the reference location, then go to my document, search for a nearby string. Then copy the reference. Then go back to the original location and enter the string. 

I think you essentially need an LSP for this, but I'm not sure.

As a halfway house, is it possible to output the xref string into the document during drafting mode? 

Thanks!

Sean Fitzpatrick

unread,
Sep 8, 2025, 9:15:45 AMSep 8
to pretext...@googlegroups.com
This has generally worked fine for me - I think your should already have this functionality. 
The only exception is that if I've just authored an xml:id. I need to at least save the document before it shows up as an auto complete option. (Maybe I need to restart vscode.)

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/eee5e854-06c0-4292-a087-4bdba0af0a54n%40googlegroups.com.

Oscar Levin

unread,
Sep 8, 2025, 9:49:18 AMSep 8
to pretext...@googlegroups.com
If you are using the pretext-tools extension with VS Code, this is supposed to work.  I think it might still assume that your entry file is "source/main.ptx".  If you are not getting these auto-complete suggestions, let me know and I can try to fix it.

David W. Farmer

unread,
Sep 8, 2025, 9:52:21 AMSep 8
to pretext...@googlegroups.com

Even if autocomplete does not work, the HTML has a link to that
theorem at the edge of the left margin, and that URL includes the id.
> https://groups.google.com/d/msgid/pretext-support/CAOU9BaU8VvUYbkpkF_dJjWFEw-Ci_4NaktnAi7fGX4QeNSrUuw%40mail.gmail.com.
>
>

phario

unread,
Sep 8, 2025, 7:11:13 PMSep 8
to PreTeXt support
Hi both, 

I didn't realise it was supposed to work. I've tried to examine clashing settings in my VSCode settings file but I couldn't detect what might screw it up. I've pasted my setting file here: https://pastecode.io/s/cprrfrdy

Can you have a look and see if anything strikes? 

I guess I can remove my other extensions and zero out the settings.json file. It would be good to know what are the minimal settings from pretext. 

Oscar Levin

unread,
Sep 8, 2025, 10:21:22 PMSep 8
to pretext...@googlegroups.com
My only guess looking at your settings is that there might be a conflict with the VIM stuff.  You can create a new blank profile in VS Code and load pretext-tools and see if that gives you the completions.  Do you get completions for things like `<theorem>`?  Those should be triggered when you type `<`.  The xref completions are triggered when you are on a line that contains `<xref ref="`, triggered on the `"` I believe.

Reply all
Reply to author
Forward
0 new messages