Added initial indent support for tikz commands

This commit is contained in:
Karl Yngve Lervåg 2014-04-14 08:48:33 +02:00
parent c0a828b496
commit 02dd1eb587

View File

@ -3,6 +3,7 @@ if exists("b:did_indent")
endif
let b:did_indent = 1
let s:cpo_save = &cpo
let s:tikz_indented = 0
set cpo&vim
" {{{1 Options and common patterns
@ -36,6 +37,12 @@ let s:delimiters_close = '\(' . join([
\ '\\\Cright\s*\%([^\\]\|\\.\|\\\a*\)',
\ '\\\cbigg\?\()\|\]\|\\}\)',
\ ], '\|') . '\)'
let s:tikz_commands = '\(' . join([
\ 'draw',
\ 'path',
\ 'node',
\ 'add\(legendentry\|plot\)',
\ ], '\|') . '\)'
" }}}1
" {{{1 LatexIndent
@ -118,6 +125,16 @@ function! LatexIndent()
let ind -= &sw
endif
" Indent tikz elements
if pline =~ s:tikz_commands
let ind += &sw
let s:tikz_indented += 1
endif
if s:tikz_indented > 0 && pline =~ ';\s*$'
let ind -= &sw
let s:tikz_indented -= 1
endif
return ind
endfunction
"}}}