@@ -14,9 +14,10 @@ endfunction
1414let s: folder = {
1515 \ ' name' : ' environments' ,
1616 \ ' re' : {
17- \ ' start' : g: vimtex #re #not_comment . ' \\begin\s*\{.{-}\}' ,
18- \ ' end' : g: vimtex #re #not_comment . ' \\end\s*\{.{-}\}' ,
19- \ ' name' : g: vimtex #re #not_comment . ' \\%(begin|end)\s*\{\zs.{-}\ze\}'
17+ \ ' start' : g: vimtex #re #not_comment .. ' \\begin\s*\{.{-}\}' ,
18+ \ ' end' : g: vimtex #re #not_comment .. ' \\end\s*\{.{-}\}' ,
19+ \ ' name' : g: vimtex #re #not_comment
20+ \ .. ' \\%(begin|end)\s*\{(.{-})\}(\s*\{.*\})?'
2021 \ },
2122 \ ' whitelist' : [],
2223 \ ' blacklist' : [],
@@ -46,7 +47,7 @@ endfunction
4647
4748" }}}1
4849function ! s: folder .level (line , lnum) abort dict " {{{1
49- let l: env = matchstr (a: line , self .re .name)
50+ let l: env = matchlist (a: line , self .re .name)[ 1 ]
5051
5152 if ! empty (l: env ) && self .validate (l: env )
5253 if a: line = ~# self .re .start
@@ -63,7 +64,8 @@ endfunction
6364
6465" }}}1
6566function ! s: folder .text (line , level ) abort dict " {{{1
66- let env = matchstr (a: line , self .re .name)
67+ let match = matchlist (a: line , self .re .name)
68+ let env = match [1 ]
6769 if ! self .validate (env) | return | endif
6870
6971 " Set caption/label based on type of environment
@@ -84,7 +86,7 @@ function! s:folder.text(line, level) abort dict " {{{1
8486 " Always make room for the label
8587 let width_rhs = 0
8688 if ! empty (label )
87- let label = ' (' . label . ' )'
89+ let label = ' (' .. label . . ' )'
8890 let width_rhs += len (label )
8991 endif
9092
@@ -96,7 +98,7 @@ function! s:folder.text(line, level) abort dict " {{{1
9698 if len (env) > width_lhs - width_ind - 8
9799 let env = strpart (env, 0 , width_lhs - width_ind - 8 )
98100 endif
99- let title = repeat (' ' , width_ind) . ' \begin{' . env . ' }'
101+ let title = repeat (' ' , width_ind) .. ' \begin{' .. env .. ' }' .. match [ 2 ]
100102
101103 " Add option group text
102104 if ! empty (option )
@@ -116,7 +118,7 @@ function! s:folder.text(line, level) abort dict " {{{1
116118
117119 if width_available >= 5
118120 if strchars (caption) > width_available
119- let caption = strpart (caption, 0 , width_available - 1 ) . ' …'
121+ let caption = strpart (caption, 0 , width_available - 1 ) .. ' …'
120122 endif
121123 let title .= caption
122124 endif
0 commit comments