(57 lines)
1 " Language: Tomo2 " Maintainer: Bruce Hill <bruce@bruce-hill.com>3 " License: WTFPL5 if exists("b:did_indent")6 finish7 endif9 let b:did_indent = 111 setlocal autoindent12 setlocal indentexpr=GetTomoIndent()13 setlocal indentkeys+=s15 " Only define the function once.16 if exists("*GetTomoIndent")17 finish18 endif20 function! GetTomoIndent()21 let line = getline(v:lnum)22 let current_ind = indent(v:lnum)23 let previousNum = prevnonblank(v:lnum - 1)24 let prev_line = getline(previousNum)25 let ind = indent(previousNum)27 if line =~ '^\s*else$'28 if prev_line =~ '^\s*else \+if\> .* then .*$' && current_ind == ind29 return current_ind30 else31 return current_ind - &tabstop32 endif33 endif35 if line =~ '^\s*\(skip\|stop\|pass\|return\|break\|continue\|)\(.*\<if\>\)\@!$'36 return current_ind - &tabstop37 endif39 if line =~ '^\s*is$'40 if prev_line =~ '^\s*is .* then .*$' && current_ind == ind41 return current_ind42 else43 return current_ind - &tabstop44 endif45 endif47 if prev_line =~ '\(^\s*\<\(for\|while\|if\|repeat\|when\|func\|convert\|lang\|struct\|enum\)\>\)\|^[^#]*[:=]\s*$'48 if prev_line !~ '^.* then '49 let ind = ind + &tabstop50 endif51 endif53 if ind == indent(previousNum)54 return current_ind55 endif56 return ind57 endfunction