Fixed #644: Use more sensible tikz context

This commit is contained in:
Karl Yngve Lervåg 2016-12-17 12:13:21 +01:00
parent 2b39554f68
commit eb1423d25c
3 changed files with 22 additions and 3 deletions

View File

@ -119,7 +119,7 @@ endfunction
function! vimtex#env#is_inside(env) " {{{1
return searchpair('\\begin\s*{' . a:env . '\*\?}', '',
\ '\\end\s*{' . a:env . '\*\?}', 'bnWm')
\ '\\end\s*{' . a:env . '\*\?}', 'bnW')
endfunction
" }}}1

View File

@ -137,7 +137,8 @@ let s:re_delims = vimtex#delim#get_delim_regexes()
" }}}1
function! s:indent_tikz(lnum, prev) " {{{1
if vimtex#env#is_inside('tikzpicture')
let l:env_lnum = vimtex#env#is_inside('tikzpicture')
if l:env_lnum > 0 && l:env_lnum < a:lnum
let l:prev_starts = a:prev =~# s:tikz_commands
let l:prev_stops = a:prev =~# ';\s*$'
@ -148,7 +149,7 @@ function! s:indent_tikz(lnum, prev) " {{{1
" Decrease indent on tikz command end, i.e. on semicolon
if ! l:prev_starts && l:prev_stops
let l:context = join(getline(max([1,a:lnum-4]), a:lnum-1), '')
let l:context = join(getline(l:env_lnum, a:lnum-1), '')
return -&sw*(l:context =~# s:tikz_commands)
endif
endif

View File

@ -130,6 +130,15 @@ Given tex (Indent: tikz):
\draw [solid] let \p{O} = (outerContactHead)
in (outerContactHead) -- (\x{O},-2.5)
node [yshift=-.25cm] {(ii)};
\begin{axis}
\addplot
table[row sep=crcr]{%
0 0\\
1 1\\
2 2\\
};
\end{axis}
\end{tikzpicture}
Do (Indent):
@ -156,6 +165,15 @@ Expect tex (Verify):
\draw [solid] let \p{O} = (outerContactHead)
in (outerContactHead) -- (\x{O},-2.5)
node [yshift=-.25cm] {(ii)};
\begin{axis}
\addplot
table[row sep=crcr]{%
0 0\\
1 1\\
2 2\\
};
\end{axis}
\end{tikzpicture}
Given tex (Indent: verbatims):