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

Feature request: extend \ref to custom commands like \figref or \secref #1323

Open
niosus opened this issue May 10, 2018 · 6 comments
Open

Comments

@niosus
Copy link

niosus commented May 10, 2018

When writing a huge document it is really helpful to define the way figures, sections, etc. are referenced in a single place to allow changing this at any point in time. Currently, LaTeXTools works with \ref and \eqref, but won't work with custom commands like \secref for sections or \figref for figures. Is it possible to extend the completion functionality to these too?

UPD: I have added a small PR to solve this issue. It would probably make more sense to add a setting for that, but I don't have the time now to look into how to do it here. I might return to this later if somebody finds it a useful feature.

@r-stein
Copy link
Member

r-stein commented May 10, 2018

Do you use the dropdown when pressing { or the autocompletion with ctrl+space?

@niosus
Copy link
Author

niosus commented May 10, 2018

In this issue I meant the dropdown triggering on typing smth like \figref. See the PR for a working example of what I mean.

@r-stein
Copy link
Member

r-stein commented May 10, 2018

If you only want that menu (other autocompletion is imo not really helpful for citations) you can just add this keybinding to your user keybindings:

    {
        "keys": ["{"],
        "command": "latex_fill_all",
        "args": { "completion_type": "ref", "insert_char": "{" },
        "context": [
            { "key": "selector", "operand": "text.tex.latex" },
            { "key": "preceding_text", "operator": "regex_match", "operand": "\\\\(?:sec|fig|tab)ref", "match_all": true },
        ],
    },

@niosus
Copy link
Author

niosus commented May 10, 2018

Cool! I did not think of doing this. Neat. I guess I can close the issue and the PR now.

@niosus niosus closed this as completed May 10, 2018
@niosus
Copy link
Author

niosus commented May 14, 2018

Hmm, @r-stein this actually does not work on all my machines. Is there an easy way to debug this? I did not find any setting to control verbosity of plugin output in this plugin, is there one that I am missing?

@niosus niosus reopened this May 14, 2018
@r-stein
Copy link
Member

r-stein commented May 14, 2018

You can open the console and write sublime.log_commands(True) to see which commands are executed.

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

Successfully merging a pull request may close this issue.

2 participants