Only indent tikz if tikz is loaded
This commit is contained in:
parent
a5d006513f
commit
3e63a12448
@ -485,8 +485,17 @@ endfunction
|
||||
|
||||
" }}}1
|
||||
function! s:init_local_options() " {{{1
|
||||
let b:vimtex.sources = []
|
||||
let b:vimtex.packages = {}
|
||||
for l:line in vimtex#parser#tex(b:vimtex.tex, {
|
||||
\ 'detailed' : 0,
|
||||
\ 're_stop' : '\\begin\s*{document}',
|
||||
\})
|
||||
if l:line =~# '\\usepackage.*{tikz}'
|
||||
let b:vimtex.packages.tikz = 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
let b:vimtex.sources = []
|
||||
for [l:file, l:lnum, l:line] in vimtex#parser#tex(b:vimtex.tex)
|
||||
let l:cand = substitute(l:file, '\M' . b:vimtex.root, '', '')
|
||||
if l:cand[0] ==# '/' | let l:cand = l:cand[1:] | endif
|
||||
|
@ -138,6 +138,8 @@ let s:re_delims = vimtex#delim#get_delim_regexes()
|
||||
|
||||
" }}}1
|
||||
function! s:indent_tikz(lnum, prev) " {{{1
|
||||
if !has_key(b:vimtex.packages, 'tikz') | return 0 | endif
|
||||
|
||||
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
|
||||
|
@ -141,8 +141,9 @@ Given tex (Indent: tikz):
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
|
||||
Do (Indent):
|
||||
gg=G
|
||||
Execute (Indent):
|
||||
let b:vimtex.packages.tikz = 1
|
||||
normal gg=G
|
||||
|
||||
Expect tex (Verify):
|
||||
\tikz \fill[green] rectangle (0.5,0.5); Something
|
||||
|
Loading…
Reference in New Issue
Block a user