- Notifications
You must be signed in to change notification settings - Fork409
From version 2.0, Vimtex provides a full syntax plugin for LaTeX files. Thechanges allow much finer as well as more consistent control over the syntaxhighlighting. However, it should be stressed that Vimtex v2.0 syntax groups arenot named the same as the built-in syntax highlighting. This brings breakingchanges e.g. for configuration or plugins that rely on the syntax groups names.
This wiki page aims to both give some hints on how to customize the syntaxhighlighting and to show some ways to alleivate the breaking changes.
The following is a listing that one may use to avoid these incompatibilities:
highlightlinktexMathZoneVtexMathZoneLIhighlightlinktexMathZoneWtexMathZoneLDhighlightlinktexMathZoneXtexMathZoneTIhighlightlinktexMathZoneYtexMathZoneTDhighlightlinktexMathZoneGtexMathZoneEnvhighlightlinktexMathZoneGStexMathZoneEnvStarredhighlightlinktexMathZoneZtexMathZoneEnsuredhighlightlinktexStatementtexCmd
Vimtex now provides a comprehensive set of syntax groups that can be used for fine-tuning syntax highlighting of TeX files to your own tastes. The reference for the core syntax groups can be found in:help vimtex-syntax-reference.
The following snippet can serve as a basis for your own customization. You can put it in yourinit.vim or in a colorscheme file. It's written for neovim withtermguicolors set, but should be easy to adapt for Vim.
setbackground=darkfunction!s:highlight(group, guifg, guibg, attr)letl:cmd='highlight' .a:groupifa:guifg!=''letl:cmd.=' guifg=' .a:guifgendififa:guibg!=''letl:cmd.=' guibg=' .a:guibgendififa:attr!=''letl:cmd.=' gui=' .a:attrendifexecutel:cmdendfunctionlets:polar1='#161821'lets:polar2='#2E3440'lets:polar3='#3B4252'lets:polar4='#6B7089'lets:snow1='#C6C8D1'lets:snow2='#D8DEE9'lets:snow3='#E5E9F0'lets:frost1='#8FBCBB'lets:frost2='#88C0D0'lets:frost3='#81A1C1'lets:frost4='#5E81AC'lets:aurora1='#E27878'lets:aurora2='#E2A478'lets:aurora3='#EBCB8B'lets:aurora4='#A3BE8C'lets:aurora5='#A093C7'" basic groupscalls:hi('texCmd',s:frost3,'','')calls:hi('texArg',s:aurora3,'','')calls:hi('texOpt',s:frost2,'','')" sectioning etc.calls:hi('texCmdPart',s:aurora2,'','')calls:hi('texPartArgTitle',s:aurora3,'','')calls:hi('texCmdTitle',s:aurora2,'','')calls:hi('texCmdAuthor',s:aurora2,'','')calls:hi('texTitleArg',s:aurora3,'','bold')calls:hi('texAuthorArg',s:aurora3,'','italic')calls:hi('texFootnoteArg',s:snow1,'','italic')" environmentscalls:hi('texCmdEnv',s:frost3,'','')calls:hi('texEnvArgName',s:aurora2,'','')calls:hi('texEnvOpt',s:aurora3,'','')" mathcalls:hi('texMathZone',s:frost1,'','')calls:hi('texMathCmd',s:frost2,'','')calls:hi('texMathDelim',s:frost2,'','')calls:hi('texMathDelimZone',s:frost3,'','')calls:hi('texMathCmdEnv',s:frost3,'','')calls:hi('texMathEnvArgName',s:frost3,'','')hi!linktexCmdMathTexttexCmdMathEnvhi!linktexCmdMathEnvtexMathCmdEnv" referencescalls:hi('texCmdRef',s:frost3,'','')calls:hi('texRefArg',s:aurora4,'','')calls:hi('texRefOpt',s:aurora5,'','')calls:hi('texUrlArg',s:frost4,'','underline')hi!linktexCmdCReftexCmdRefhi!linktexHrefArgLinktexUrlArghi!linktexHrefArgTexttexOpt" symbolscalls:hi('texSymbol',s:aurora5,'','')calls:hi('texSpecialChar',s:frost3,'','')hi!linktexDelimtexSymbolhi!linktexTabularChartexSymbol" filescalls:hi('texFileArg',s:aurora5,'','')calls:hi('texFileOpt',s:frost2,'','')" bibcalls:hi('bibType',s:aurora2,'','')calls:hi('bibKey',s:aurora4,'','')calls:hi('bibEntryKw',s:frost1,'','')calls:hi('bibVariable',s:aurora3,'','')