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

conceal support for mathbf #557

Closed
anntzer opened this issue Sep 17, 2016 · 10 comments
Closed

conceal support for mathbf #557

anntzer opened this issue Sep 17, 2016 · 10 comments

Comments

@anntzer
Copy link
Contributor

anntzer commented Sep 17, 2016

This is a request for concealing \mathbf similarly to \textbf. Unfortunately, just adding mathbf at https://github.com/lervag/vimtex/blame/master/after/syntax/tex.vim#L31 does not seem to suffice, perhaps due to group nesting?
Thanks in advance.

Minimal working example

Please provide a minimal working LaTeX example, e.g.

\documentclass{minimal}
\begin{document}

\textbf{foo}
$\mathbf{foo}$

\end{document}

Minimal vimrc file

Please provide a minimal vimrc file that reproduces the issue. The following
should often suffice:

set nocompatible

" Load Vimtex
let &rtp  = '~/.vim/plugged/vimtex,' . &rtp
let &rtp .= ',~/.vim/plugged/vimtex/after'

" Load other plugins, if necessary
" let &rtp = '~/path/to/other/plugin,' . &rtp

filetype plugin indent on
syntax enable

" Vimtex options go here
set conceallevel=2
let g:tex_conceal="abdgm"
@lervag
Copy link
Owner

lervag commented Sep 17, 2016

The problem is that this is within the texMath regions. If you remove the M flag from g:tex_fast (e.g. by setting let g:tex_fast = "bcmprsSvV"), then it will work by adding mathbf to the list in line 31. However, it seems hackish to me, so I am not sure if I want to add it. In particular, I don't quite see the consequences of removing the M flag.

lervag added a commit that referenced this issue Sep 17, 2016
@aquadr
Copy link

aquadr commented Dec 7, 2016

You can do something like

syntax cluster texMathZoneGroup add=texBoldStyle
syntax cluster texMathMatchGroup add=texBoldStyle
syntax region texBoldStyle matchgroup=texStatement start='\\vect\s*{' end='}' contains=texMathZoneX contained concealends
syntax region texBoldStyle matchgroup=texStatement start='\\boldsymbol\s*{' end='}' contains=texMathZoneX contained concealends

This works well with let g:tex_fast = "M".

@lervag
Copy link
Owner

lervag commented Dec 8, 2016

Thanks @aquadr, that seems like it should or could work.

Is there a good reason not to add this by default?

Or, perhaps: Do you (either @anntzer or @aquadr or anyone else) have a list of specific math fonts that should be italized or bolded that I could create custom groups for that I would add to the clusters? I guess it does not really make sense to add texBoldStyle to the cluster. I should rather create texMathBoldStyle, add it to the cluster and link it to the texBoldStyle style. What do you think?

@aquadr
Copy link

aquadr commented Dec 8, 2016

I don't think there is a good reason not to add this by default.

My understanding of vim syntax files is limited... I think creating texMathBoldStyle and linking to texBoldStyle is reasonable (altough variables like $\mathbf{a}$ might have a different syntax highlighting color than ordinary math variables $a$).

Here is a small (surely incomplete) list of commands which could be styled:

\documentclass[]{article}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{fixmath}
\begin{document}
\begin{align}
	a \\
	\textit{a} \\
	\mathit{a} \\
	\mathbf{a} \\
	\mathbold{a} \\
	\boldsymbol{a} \\
	\bm{a} \\
	\pmb{a} \\
	\mathsf{a} \\
	\textsf{a} \\
	\mathrm{a} \\
	\text{a} 
\end{align}
\end{document}

One might argue, wheter \vec{..} or vect{..} should be bold, too :-)

@anntzer
Copy link
Contributor Author

anntzer commented Dec 8, 2016

I don't have any exhaustive list, looks like @aquadr is already doing all the work there.

@lervag
Copy link
Owner

lervag commented Dec 28, 2016

I've been looking at this and thinking. I've tried to implement it, but to me it does not look quite right. I would have to add options that control it, and the default would be to have it disabled.

Since this is "easily" added on a per user basis by adding the lines suggested by @aquadr to ones after/syntax/tex.vim file, I find it is better to let a user add such customization manually. This helps keep vimtex cleaner and simpler.

@lervag lervag closed this as completed Dec 28, 2016
@Konfekt
Copy link
Contributor

Konfekt commented May 22, 2018

Just found the two-year old

https://github.com/KeitaNakamura/tex-conceal.vim

that resolves all of this concealing quite well. Perhaps it can be mentioned, or even implemented as an option.

@lervag
Copy link
Owner

lervag commented May 22, 2018

Thanks for the notice! I'll make a comment on this in the docs. I'm not personally a big fan of conceals, and so I don't really feel like adding it to vimtex.

However, if it is a popular opinion that this should be added to vimtex, then I could reconsider (feel free to open a new issue to check if there is such an interest).

@oblitum
Copy link

oblitum commented Dec 4, 2020

Hi @lervag, I just found tex-conceal.vim and it's really nice, but today vimtex blocks most of it from working. I'm not sure how to make the two play together. There's a simple rendering test on tex-conceal.vim, it works standalone, but with vimtex, almost nothing gets concealed as expected, so it can be stated the two are currently incompatible.

@lervag
Copy link
Owner

lervag commented Dec 4, 2020

@oblitum Feel free to open a new issue on this topic. Note: I will not do anything to make Vimtex play nice with tex-conceal, but I might consider adding more conceal rules inspired by tex-conceal.

Repository owner locked as resolved and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants