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

Setup text argument in user-defined command #2898

Closed
Nora-n opened this issue Mar 13, 2024 · 3 comments
Closed

Setup text argument in user-defined command #2898

Nora-n opened this issue Mar 13, 2024 · 3 comments

Comments

@Nora-n
Copy link

Nora-n commented Mar 13, 2024

I have a custom \beforetext command that adds text on the left side of an equation. Following #2755, I'd like to know how to setup a local syntax to tell vimtex that what's inside is text. I looked up the commit you made for witharrows and could easily reproduce it, but my command is not attached to any package. Would you be able to point me in the right direction to do that?

  syntax match texMathCmdText "\\beforetext\>"
        \ contained skipwhite nextgroup=texMathTextArg

As always, thank you for this fantastic plugin and your maintenance of it :-).

@lervag
Copy link
Owner

lervag commented Mar 14, 2024

Hi!

I have a custom \beforetext command that adds text on the left side of an equation. Following #2755, I'd like to know how to setup a local syntax to tell vimtex that what's inside is text. I looked up the commit you made for witharrows and could easily reproduce it, but my command is not attached to any package. Would you be able to point me in the right direction to do that?

  syntax match texMathCmdText "\\beforetext\>"
        \ contained skipwhite nextgroup=texMathTextArg

I believe you can solve this with the g:vimtex_syntax_custom_cmds option. Specify it wherever you specify your other VimTeX options. Something like this:

let g:vimtex_syntax_custom_cmds = [
      \ {'name': 'beforetext', 'mathmode': v:true,
      \  'nextgroup': 'texMathTextArg'},
      \]

As always, thank you for this fantastic plugin and your maintenance of it :-).

Thanks for the kind words! <3

@lervag lervag closed this as completed Mar 14, 2024
@Nora-n
Copy link
Author

Nora-n commented Mar 15, 2024

Thank you! I must've missed it, I just started using the useful concealing tools and changed the highlighting groups, but didn't stumble on that.

Cheers! :-)

@lervag
Copy link
Owner

lervag commented Mar 15, 2024

Thank you! I must've missed it, I just started using the useful concealing tools and changed the highlighting groups, but didn't stumble on that.

I'll be the first to admit it's easy to miss things when the documentation has reached 7000 lines of text... in any case, no problem!

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