-
Notifications
You must be signed in to change notification settings - Fork 391
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
[Syntax Conceal] Conceal completely \hphantom{arg} #2642
Comments
I have created for neovim the file syntax match texCmd "\\hphantom{.\{-}} \?" conceal
syntax match texMathCmd "\\hphantom{.\{-}} \?" contained conceal However, this has problems when nesting other commands, e.g. syntax match texCmd "\\hphantom{[^{}]*\({[^{}]*}[^{}]*\)*} \?" conceal
syntax match texMathCmd "\\hphantom{[^{}]*\({[^{}]*}[^{}]*\)*} \?" contained conceal Another level is already nasty: syntax match texCmd "\v\\hphantom\{[^{}]*(\{[^{}]*\}[^{}]*)*(\{[^{}]*(\{[^{}]*\}[^{}]*)*\}[^{}]*(\{[^{}]]*\}[^{}]*)*)*\} ?" conceal
syntax match texMathCmd "\v\\hphantom\{[^{}]*(\{[^{}]*\}[^{}]*)*(\{[^{}]*(\{[^{}]*\}[^{}]*)*\}[^{}]*(\{[^{}]]*\}[^{}]*)*)*\} ?" contained conceal Credit goes to https://vi.stackexchange.com/a/38259/1292 for providing the expression for nested square brackets. |
The following code works for me (you could put it in syntax match texCmdPhantom "\\hphantom\>"
\ conceal skipwhite nextgroup=texPhantomArg
syntax match texMathCmdPhantom "\\hphantom\>"
\ conceal skipwhite nextgroup=texPhantomArg
syntax cluster texClusterMath add=texMathCmdPhantom
call vimtex#syntax#core#new_arg('texPhantomArg', {
\ 'opts': 'contained conceal',
\ 'contains': 'texPhantomGroups',
\})
call vimtex#syntax#core#new_arg('texPhantomGroups', {
\ 'matchgroup': 'matchgroup=NONE',
\ 'opts': 'contained conceal',
\ 'contains': 'texPhantomGroups',
\})
highlight def link texCmdPhantom texCmd
highlight def link texPhantomArg texArg
highlight def link texPhantomGroups texPhantomArg I could add this to VimTeX as a feature - do you think that would be useful? Should it be enabled by default with a flag in |
By the way: a core idea to make this work is to use |
Thanks for all your feedback.
It is great that there is a proper solution to this and I totally agree that reg exps are here not the right tool.
Obviously, I find it useful. The popular answer on https://tex.stackexchange.com/questions/74353/what-commands-are-there-for-horizontal-spacing lists quite a few commands to add horizontal spacing. VimTeX already conceals a part from this list: vimtex/autoload/vimtex/syntax/core.vim Lines 2033 to 2061 in b527d75
So one could argue that vimtex/autoload/vimtex/syntax/core.vim Lines 645 to 648 in b527d75
Actually, I have added myself |
And I actually have added |
Ah, yes, I agree. I've pushed an update that adds conceals for |
I see: delegating the blame/pressure 😅 . I would go with what is done until now, i.e. no space. Do not change existing behaviour except someone comes with a good reason. I agree that this is subjective. Concealment in general feels this ways since it is only an approximation and it depends on how one writes tex code and formats it. I actually have changed a few places how I format my code due to enabling concealment (e.g. no alignment of |
;)
Sounds good!
Yes. I personally don't like the conceals and don't use them. |
I am always impressed about the many features and quality of them you have added which you do not use yourself. Thank you for this. |
I find pleasure in trying to solve (sometimes hard) problems in a good way. As I'm no longer in academia, I also use LaTeX more seldom personally, but I still find it fun to tinker with VimTeX. :) |
Is it possible to conceal
\hphantom{arg}
completely?The text was updated successfully, but these errors were encountered: