From 09a9d0f9de257aaccf6162d9756150890b3bb6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sun, 6 Dec 2015 22:31:18 +0100 Subject: [PATCH] Support for \textit and \textbf Thanks to comment by @2sev on commit 4cbb663. --- after/syntax/tex.vim | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/after/syntax/tex.vim b/after/syntax/tex.vim index 9b64626..51fbaa6 100644 --- a/after/syntax/tex.vim +++ b/after/syntax/tex.vim @@ -11,17 +11,23 @@ elseif b:current_syntax !=# 'tex' finish endif -" {{{1 Add italic font and conceal for \emph -if has('conceal') && get(g:, 'tex_conceal', 'b') =~# 'b' - syntax region texItalStyle - \ matchgroup=texTypeStyle start="\\emph\s*{" end="}" - \ contains=@texItalGroup concealends -else - syntax region texItalStyle - \ matchgroup=texTypeStyle start="\\emph\s*{" end="}" - \ contains=@texItalGroup -endif -syntax cluster texMatchGroup add=texItalStyle +" {{{1 Italic font, bold font and conceals + +let conceal = (has('conceal') && get(g:, 'tex_conceal', 'b') =~# 'b') + \ ? 'concealends' : '' + +for [style, group, commands] in [ + \ ['texItalStyle', 'texItalGroup', ['emph', 'textit']], + \ ['texBoldStyle', 'texBoldGroup', ['textbf']], + \] + for cmd in commands + execute 'syntax region' style 'matchgroup=texTypeStyle' + \ 'start="\\' . cmd . '\s*{" end="}"' + \ 'contains=@' . group + \ conceal + endfor + execute 'syntax cluster texMatchGroup add=' . style +endfor " }}}1 " {{{1 Add syntax highlighting for \url and \href