Fix #634: Added option for indented verbatim envs
This commit is contained in:
parent
305eb16133
commit
1cd633d6ba
@ -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.
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user