From 1cd633d6ba375b2fcf018e9a5db66f790f073ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sat, 3 Dec 2016 12:32:58 +0100 Subject: [PATCH] Fix #634: Added option for indented verbatim envs --- doc/vimtex.txt | 6 ++++++ indent/tex.vim | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 5a70431..8fe465c 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -584,6 +584,12 @@ Options~ Default value: 1 +*g:vimtex_indent_verbatim_envs* + Use this option to set a list of verbatim environments in which there should + be no automatic indentation. + + Default value: ['verbatim', 'lstlisting', 'minted'] + *g:vimtex_index_hide_line_numbers* If enabled, then line numbers will be hidden in the index windows. That is, |nonumber| and |norelativenumber| will be set locally. diff --git a/indent/tex.vim b/indent/tex.vim index 296b758..03c8442 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -12,6 +12,11 @@ let b:did_vimtex_indent = 1 call vimtex#util#set_default('g:vimtex_indent_enabled', 1) if !g:vimtex_indent_enabled | finish | endif +call vimtex#util#set_default('g:vimtex_indent_verbatim_envs', [ + \ 'verbatim', + \ 'lstlisting', + \ 'minted', + \]) let s:cpo_save = &cpo set cpo&vim @@ -76,11 +81,15 @@ endfunction " }}}1 function! s:is_verbatim(line, lnum) " {{{1 - let l:env = a:line !~# '\v\\%(begin|end)\{%(verbatim|lstlisting|minted)' + let l:env = a:line !~# s:is_verbatim_regex let l:syn = synIDattr(synID(a:lnum, 1, 1), 'name') ==# 'texZone' return l:env && l:syn endfunction +let s:is_verbatim_regex = '\v\\%(begin|end)\{%(' + \ . join(g:vimtex_indent_verbatim_envs, '|') + \ . ')' + " }}}1 function! s:indent_envs(cur, prev) " {{{1