Improve/Fix tikz indentation (#390)
This commit is contained in:
parent
2250d4258f
commit
7bb6aa6306
@ -62,7 +62,7 @@ function! VimtexIndent() " {{{1
|
|||||||
let l:ind = indent(l:nprev)
|
let l:ind = indent(l:nprev)
|
||||||
let l:ind += s:indent_envs(l:cur, l:prev)
|
let l:ind += s:indent_envs(l:cur, l:prev)
|
||||||
let l:ind += s:indent_delims(l:cur, l:prev)
|
let l:ind += s:indent_delims(l:cur, l:prev)
|
||||||
let l:ind += s:indent_tikz(l:prev)
|
let l:ind += s:indent_tikz(l:nprev, l:prev)
|
||||||
return l:ind
|
return l:ind
|
||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
@ -98,14 +98,24 @@ function! s:indent_delims(cur, prev) " {{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! s:indent_tikz(cur, prev) " {{{1
|
function! s:indent_tikz(lnum, prev) " {{{1
|
||||||
if a:prev =~# s:tikz_commands && a:prev !~# ';'
|
if vimtex#env#is_inside('tikzpicture')
|
||||||
let l:ind += &sw
|
let l:prev_starts = a:prev =~# s:tikz_commands
|
||||||
elseif a:prev !~# s:tikz_commands && a:prev =~# ';'
|
let l:prev_stops = a:prev =~# ';\s*$'
|
||||||
let l:ind -= &sw
|
|
||||||
|
" Increase indent on tikz command start
|
||||||
|
if l:prev_starts && ! l:prev_stops
|
||||||
|
return &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return l:ind
|
" 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), '')
|
||||||
|
return -&sw*(l:context =~# s:tikz_commands)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:tikz_commands = '\v\\%(' . join([
|
let s:tikz_commands = '\v\\%(' . join([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user