Nnomuas
Nnomuas

Reputation: 73

Different syntax highlighting between inline and display-math in vim

I work on Vim with the solarized colorscheme. In my .tex files, the syntax highlighting is different from $...$ to \[...\](or align environment).

The inline maths are in yellow, while the display-maths are in red. As you can see here

The mathzone seems recognized because i'm using a math context with Ultisnips that works.

Is this difference normal, and if it is, is there a way to highlight the both in the same way ? I precise that i'm using Vimtex.

Upvotes: 2

Views: 405

Answers (1)

Matt
Matt

Reputation: 15091

That's a colorscheme inconsistency. Solarized defines highlight only for texMathZoneX but it does nothing with texMath or texMathZoneY. Hence the result. You can use other colorscheme or do some workaround. E.g.

augroup FixColors | au!
    autocmd ColorScheme solarized
        \ if &bg ==# 'dark' |
            \ hi texMath ctermfg=3 ctermbg=8 guifg=#b58900 guibg=#002b36 |
        \ else |
            \ hi texMath ctermfg=3 ctermbg=15 guifg=#b58900 guibg=#fdf6e3 |
        \ endif |
        \ hi! link texMathZoneX texMath
augroup end

Upvotes: 2

Related Questions