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

Allow argstyle keyword in vimtex_syntax_custom_cmds to accept name of highlight group #2574

Closed
maxmahlke opened this issue Nov 18, 2022 · 5 comments

Comments

@maxmahlke
Copy link

Is your feature request related to a problem? Please describe it.
In PR #2033 you extended the list of accepted argstyle values in the vimtex_syntax_custom_cmds setting to include different combinations of bold, italics, and underline. I would like to go even further in the customization, allowing the whole range of options that the highlight command provides (foreground colour, background colour, etc.).

Describe the solution you'd like
From PR #2033, it seems that you define custom highlight groups for the existing argstyle values and expose those to the user. A more flexible solution could be that user passes the name of a highlight group directly, which they define prior to the setting:

highlight def texMyCommandStyle gui=italic guifg=ref guibg=white

let g.vimtex_syntax_custom_cmds = [
          \ {'name': 'MyCommand', 'argstyle': 'texMyCommandStyle'},
\]

I'm not sure that this is possible but it would allow an even greater level of customization. In particular because I'm not a fan of bold or italic fonts in my buffers :-)

@lervag
Copy link
Owner

lervag commented Nov 19, 2022

In PR #2033 you extended the list of accepted argstyle values in the vimtex_syntax_custom_cmds setting to include different combinations of bold, italics, and underline. I would like to go even further in the customization, allowing the whole range of options that the highlight command provides (foreground colour, background colour, etc.).

You already can. The argstyle is meant as a simple way to link the created match group to one of the existing texStyle* highlight groups. But you are free to instead create your own highlight rules.

Given

let g:vimtex_syntax_custom_cmds = [
      \ {'name': 'foo', 'mathmode': 1, 'argstyle': 'bold'},
      \ {'name': 'bar'},
      \]

This will create these match groups:

  • texMathCmdCFoo: The command part, i.e. \foo
  • texMathCFooOpt: The option group, i.e. \foo[HERE]
  • texMathCFooArg: The argument group, i.e. \foo[...]{HERE}
  • texCmdCBar: The command part, i.e. \bar
  • texCBarOpt: The option group, i.e. \bar[HERE]
  • texCBarArg: The argument group, i.e. \bar[...]{HERE}

The argstyle option just implies that texMathCFooArg is linked to texStyleBold. But you are perfectly free to define the highlightings as you want.

@lervag lervag closed this as completed Nov 19, 2022
@maxmahlke
Copy link
Author

Great, that works, thank you! I see that this is explained at the end of help vimtex-syntax-core, maybe it would be good to reference this at the explanation of the argstyle argument in help g:vimtex_syntax_custom_cmds? Something like To apply styles not offered by 'argstyle', refer to **vimtex-syntax-core**.

lervag added a commit that referenced this issue Nov 19, 2022
@lervag
Copy link
Owner

lervag commented Nov 19, 2022

Thanks, I agree. I've updated the docs; let me know what you think.

@maxmahlke
Copy link
Author

That covers it perfectly. I've been customizing my vimtex syntax in the meantime, this plugin is just a dream come true. Thank you!

@lervag
Copy link
Owner

lervag commented Nov 20, 2022

I'm glad to hear you like it! :) <3

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

No branches or pull requests

2 participants