Improved indenting (including fix to #66)
This commit is contained in:
parent
3ff568cec4
commit
90792d70b1
@ -50,7 +50,6 @@ let s:delimiters_close = '\(' . join([
|
|||||||
let s:tikz_commands = '\\\(' . join([
|
let s:tikz_commands = '\\\(' . join([
|
||||||
\ 'draw',
|
\ 'draw',
|
||||||
\ 'fill',
|
\ 'fill',
|
||||||
\ 'foreach',
|
|
||||||
\ 'path',
|
\ 'path',
|
||||||
\ 'node',
|
\ 'node',
|
||||||
\ 'add\(legendentry\|plot\)',
|
\ 'add\(legendentry\|plot\)',
|
||||||
@ -127,7 +126,11 @@ function! LatexIndent()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Indent opening and closing delimiters
|
" Indent opening and closing delimiters
|
||||||
let ind += s:indent_braces(cline, pline) * &sw
|
let popen = s:count_delimiters(pline, s:delimiters_open)
|
||||||
|
let copen = s:count_delimiters(cline, s:delimiters_open)
|
||||||
|
let pclose = s:count_delimiters(pline, s:delimiters_close)
|
||||||
|
let cclose = s:count_delimiters(cline, s:delimiters_close)
|
||||||
|
let ind += &sw*(max([popen - pclose, 0]) - max([cclose - copen, 0]))
|
||||||
|
|
||||||
" Indent list items
|
" Indent list items
|
||||||
if pline =~ '^\s*\\\(bib\)\?item'
|
if pline =~ '^\s*\\\(bib\)\?item'
|
||||||
@ -151,14 +154,8 @@ function! LatexIndent()
|
|||||||
endfunction
|
endfunction
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" {{{1 s:indent_braces
|
" {{{1 s:count_delimiters
|
||||||
function! s:indent_braces(cline, pline)
|
function! s:count_delimiters(line, pattern)
|
||||||
return s:match_brace(a:pline, s:delimiters_open)
|
|
||||||
\ - s:match_brace(a:pline, s:delimiters_close)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" {{{1 s:match_brace
|
|
||||||
function! s:match_brace(line, pattern)
|
|
||||||
let sum = 0
|
let sum = 0
|
||||||
let indx = match(a:line, a:pattern)
|
let indx = match(a:line, a:pattern)
|
||||||
while indx >= 0
|
while indx >= 0
|
||||||
|
Loading…
Reference in New Issue
Block a user