From 02dd1eb587eeb6c6bd790634fecf4331dd88d6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Mon, 14 Apr 2014 08:48:33 +0200 Subject: [PATCH] Added initial indent support for tikz commands --- indent/tex.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/indent/tex.vim b/indent/tex.vim index 5021756..b95dbf5 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -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 "}}}