From a070901fb2e43e79eb56a8fec7f9d16bc8479b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 10 Jan 2017 23:15:41 +0100 Subject: [PATCH] Improve speed of s:is_verbatim --- autoload/vimtex/env.vim | 3 ++- indent/tex.vim | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/autoload/vimtex/env.vim b/autoload/vimtex/env.vim index 1378e31..327bf73 100644 --- a/autoload/vimtex/env.vim +++ b/autoload/vimtex/env.vim @@ -118,8 +118,9 @@ endfunction " }}}1 function! vimtex#env#is_inside(env) " {{{1 + let l:stopline = max([line('.') - 50, 1]) return searchpair('\\begin\s*{' . a:env . '\*\?}', '', - \ '\\end\s*{' . a:env . '\*\?}', 'bnW') + \ '\\end\s*{' . a:env . '\*\?}', 'bnW', 0, l:stopline) endfunction " }}}1 diff --git a/indent/tex.vim b/indent/tex.vim index 2c4188a..b55675a 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -80,9 +80,8 @@ endfunction " }}}1 function! s:is_verbatim(line, lnum) " {{{1 - let l:env = a:line !~# '\v\\%(begin|end)\{%(verbatim|lstlisting|minted)' - let l:syn = synIDattr(synID(a:lnum, 1, 1), 'name') ==# 'texZone' - return l:env && l:syn + return a:line !~# '\v\\%(begin|end)\{%(verbatim|lstlisting|minted)' + \ && vimtex#env#is_inside('\%(lstlisting\|verbatim\|minted\)') endfunction " }}}1