3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-12-20
6 if exists("b:did_indent")
11 setlocal indentexpr=GetTclIndent()
12 setlocal indentkeys=0{,0},!^F,o,O,0]
13 setlocal nosmartindent
15 if exists("*GetTclIndent")
19 function s:prevnonblanknoncomment(lnum)
20 let lnum = prevnonblank(a:lnum)
22 let line = getline(lnum)
23 if line !~ '^\s*\(#\|$\)'
26 let lnum = prevnonblank(lnum - 1)
31 function s:count_braces(lnum, count_open)
34 let line = getline(a:lnum)
36 let i = match(line, pattern)
38 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'tcl\%(Comment\|String\)'
49 let i = match(line, pattern, i + 1)
51 return a:count_open ? n_open : n_close
54 function GetTclIndent()
55 let line = getline(v:lnum)
57 return cindent(v:lnum)
58 elseif line =~ '^\s*}'
59 return indent(v:lnum) - &sw
62 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
67 let ind = indent(pnum) + s:count_braces(pnum, 1) * &sw
69 let pline = getline(pnum)
71 let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * &sw