Fix #634: Added option for indented verbatim envs

This commit is contained in:
Karl Yngve Lervåg 2016-12-03 12:32:58 +01:00
parent 305eb16133
commit 1cd633d6ba
2 changed files with 16 additions and 1 deletions

View File

@ -584,6 +584,12 @@ Options~
Default value: 1 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* *g:vimtex_index_hide_line_numbers*
If enabled, then line numbers will be hidden in the index windows. That is, If enabled, then line numbers will be hidden in the index windows. That is,
|nonumber| and |norelativenumber| will be set locally. |nonumber| and |norelativenumber| will be set locally.

View File

@ -12,6 +12,11 @@ let b:did_vimtex_indent = 1
call vimtex#util#set_default('g:vimtex_indent_enabled', 1) call vimtex#util#set_default('g:vimtex_indent_enabled', 1)
if !g:vimtex_indent_enabled | finish | endif 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 let s:cpo_save = &cpo
set cpo&vim set cpo&vim
@ -76,11 +81,15 @@ endfunction
" }}}1 " }}}1
function! s:is_verbatim(line, lnum) " {{{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' let l:syn = synIDattr(synID(a:lnum, 1, 1), 'name') ==# 'texZone'
return l:env && l:syn return l:env && l:syn
endfunction endfunction
let s:is_verbatim_regex = '\v\\%(begin|end)\{%('
\ . join(g:vimtex_indent_verbatim_envs, '|')
\ . ')'
" }}}1 " }}}1
function! s:indent_envs(cur, prev) " {{{1 function! s:indent_envs(cur, prev) " {{{1