Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize \ref completion #1463

Open
JakobScholbach opened this issue Feb 21, 2020 · 2 comments
Open

Customize \ref completion #1463

JakobScholbach opened this issue Feb 21, 2020 · 2 comments

Comments

@JakobScholbach
Copy link

I love a feature of LatexTools: if I type \ref{, it automatically scans for all occurrences of \label{…} and offers these for some auto-completion.

How do I customize this? I want to achieve the same behavior with \thref{ and \thlabel{…} instead.

Thanks!

@r-stein
Copy link
Member

r-stein commented Feb 21, 2020

The behavior of ref and label is hard coded and not configurable.
You may however adapt the source code. Select View > Browse Packages... then open the LaTeXTools folder and the file latex_ref_completions.py.

Then add "th" to the array in this line (i.e. "title", "headname", "tocname", "th") to open the completion for \thref.

Then adapt this line to

for command in doc.filter_commands(['label', 'thlabel']):

and this line to

view.find_all(r'\\(?:th)?label\{([^\{\}]+)\}', 0, '\\1', completions)

to also scan the \thlabel commands

@JakobScholbach
Copy link
Author

Thank you, r-stein, this works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants