Fixed #644: Use more sensible tikz context
This commit is contained in:
parent
2b39554f68
commit
eb1423d25c
@ -119,7 +119,7 @@ endfunction
|
|||||||
|
|
||||||
function! vimtex#env#is_inside(env) " {{{1
|
function! vimtex#env#is_inside(env) " {{{1
|
||||||
return searchpair('\\begin\s*{' . a:env . '\*\?}', '',
|
return searchpair('\\begin\s*{' . a:env . '\*\?}', '',
|
||||||
\ '\\end\s*{' . a:env . '\*\?}', 'bnWm')
|
\ '\\end\s*{' . a:env . '\*\?}', 'bnW')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
|
@ -137,7 +137,8 @@ let s:re_delims = vimtex#delim#get_delim_regexes()
|
|||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! s:indent_tikz(lnum, prev) " {{{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_starts = a:prev =~# s:tikz_commands
|
||||||
let l:prev_stops = a:prev =~# ';\s*$'
|
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
|
" Decrease indent on tikz command end, i.e. on semicolon
|
||||||
if ! l:prev_starts && l:prev_stops
|
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)
|
return -&sw*(l:context =~# s:tikz_commands)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -130,6 +130,15 @@ Given tex (Indent: tikz):
|
|||||||
\draw [solid] let \p{O} = (outerContactHead)
|
\draw [solid] let \p{O} = (outerContactHead)
|
||||||
in (outerContactHead) -- (\x{O},-2.5)
|
in (outerContactHead) -- (\x{O},-2.5)
|
||||||
node [yshift=-.25cm] {(ii)};
|
node [yshift=-.25cm] {(ii)};
|
||||||
|
|
||||||
|
\begin{axis}
|
||||||
|
\addplot
|
||||||
|
table[row sep=crcr]{%
|
||||||
|
0 0\\
|
||||||
|
1 1\\
|
||||||
|
2 2\\
|
||||||
|
};
|
||||||
|
\end{axis}
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
|
|
||||||
Do (Indent):
|
Do (Indent):
|
||||||
@ -156,6 +165,15 @@ Expect tex (Verify):
|
|||||||
\draw [solid] let \p{O} = (outerContactHead)
|
\draw [solid] let \p{O} = (outerContactHead)
|
||||||
in (outerContactHead) -- (\x{O},-2.5)
|
in (outerContactHead) -- (\x{O},-2.5)
|
||||||
node [yshift=-.25cm] {(ii)};
|
node [yshift=-.25cm] {(ii)};
|
||||||
|
|
||||||
|
\begin{axis}
|
||||||
|
\addplot
|
||||||
|
table[row sep=crcr]{%
|
||||||
|
0 0\\
|
||||||
|
1 1\\
|
||||||
|
2 2\\
|
||||||
|
};
|
||||||
|
\end{axis}
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
|
|
||||||
Given tex (Indent: verbatims):
|
Given tex (Indent: verbatims):
|
||||||
|
Loading…
Reference in New Issue
Block a user