diff --git a/autoload/vimtex/delim.vim b/autoload/vimtex/delim.vim index 159cd1b..e041ada 100644 --- a/autoload/vimtex/delim.vim +++ b/autoload/vimtex/delim.vim @@ -158,19 +158,6 @@ function! vimtex#delim#init_script() " {{{1 \ . '\)\|\\\%(left\|right\)\s*\.', \} - let s:re.delim_mathmod = { - \ 'open' : '\%(\%(' . s:re.delim_mods.open . '\)\s*\)\%(' - \ . join(map(copy(s:delims.delim_math.re), 'v:val[0]'), '\|') - \ . '\)\|\\left\s*\.', - \ 'close' : '\%(\%(' . s:re.delim_mods.close . '\)\s*\)\%(' - \ . join(map(copy(s:delims.delim_math.re), 'v:val[1]'), '\|') - \ . '\)\|\\right\s*\.', - \ 'both' : '\%(\%(' . s:re.delim_mods.both . '\)\s*\)\%(' - \ . join(map(copy(s:delims.delim_math.re), 'v:val[0]'), '\|') . '\|' - \ . join(map(copy(s:delims.delim_math.re), 'v:val[1]'), '\|') - \ . '\)\|\\\%(left\|right\)\s*\.', - \} - let s:delims.env_all = {} let s:delims.delim_all = {} let s:delims.all = {} @@ -229,8 +216,7 @@ endfunction function! vimtex#delim#get_delim_regexes(...) " {{{1 return exists('s:re') \ ? [s:re.delim_math.open, s:re.delim_math.close, - \ s:re.delim_tex.open, s:re.delim_tex.close, - \ s:re.delim_mathmod.open, s:re.delim_mathmod.close] + \ s:re.delim_tex.open, s:re.delim_tex.close] \ : [] endfunction diff --git a/indent/tex.vim b/indent/tex.vim index a2db851..b1ef209 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -115,12 +115,43 @@ let s:envs_enditem = s:envs_item . '\|' . s:envs_endlist function! s:indent_delims_simple(line, lnum, prev_line, prev_lnum) " {{{1 if empty(s:re_delims) | return 0 | endif - return &sw*( max([ s:count(a:prev_line, s:re_delims[4]) - \ - s:count(a:prev_line, s:re_delims[5]), 0]) - \ - max([ s:count(a:line, s:re_delims[5]) - \ - s:count(a:line, s:re_delims[4]), 0])) + return &sw*( max([ s:count(a:prev_line, s:re_open) + \ - s:count(a:prev_line, s:re_close), 0]) + \ - max([ s:count(a:line, s:re_close) + \ - s:count(a:line, s:re_open), 0])) endfunction +let s:delims_open = [ + \ '\(', + \ '\[', + \ '\\\{', + \ '\\langle', + \ '\\lvert', + \ '\\lfloor', + \ '\\lceil', + \ '\\ulcorner', + \] +let s:delims_close = [ + \ '\)', + \ '\]', + \ '\\\}', + \ '\\rangle', + \ '\\rvert', + \ '\\rfloor', + \ '\\rceil', + \ '\\urcorner', + \] +let s:re_open = '\v' + \ . '%(\\left|\\[bB]igg?l?)\s*%(' . join(s:delims_open, '|') . ')' + \ . '|\\left\s*\.' + \ . '|\{' + \ . '|\\\[' +let s:re_close = '\v' + \ . '%(\\right|\\[bB]igg?r?)\s*%(' . join(s:delims_close, '|') . ')' + \ . '|\\right\s*\.' + \ . '|\}' + \ . '|\\\]' + " }}}1 function! s:indent_delims_complex(line, lnum, prev_line, prev_lnum) " {{{1 if empty(s:re_delims) | return 0 | endif