SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2k stars 362 forks source link

Autocomplete trigger for custom commands. #1556

Closed otanan closed 2 years ago

otanan commented 2 years ago

Currently we can toggle settings to let an autocompletion list appear whenever we run \ref or \cite. It seems to also automatically handle \nameref despite no explicit mentions of this command in the source. I was hoping we could get some sort of way of injecting our own commands to look cause an autocomplete trigger to appear.

One example being when I want to create a special command for referencing problems, I would define it to be \probref, and would like the same list to appear.

ig0774 commented 2 years ago

Probably not easily at the level you’re looking for. The \ref commands we look for are defined starting here. If you look closely, you can see how \nameref is supported. Citations are handled by this horrendous regex, which really isn’t easily amenable to extension.

There is a shortcut you can use to insert citations or references at arbitrary places. Alternatively, you can use a standard Sublime key binding similar to this one to make any valid ST key binding add citations LaTeXTools knows about.

otanan commented 2 years ago

This is exactly what I was looking for! Adding "prob" to the latex_ref_completions.py script gave me the desired functionality. Thank you so much.