(42 lines)
1 " Language: Nomsu2 " 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=GetNomsuIndent()13 setlocal indentkeys+=0],0),1),1.15 " Only define the function once.16 if exists("*GetNomsuIndent")17 finish18 endif20 function! GetNomsuIndent()21 let line = getline(v:lnum)22 let current_ind = indent(v:lnum)23 let previousNum = prevnonblank(v:lnum - 1)24 let previous = getline(previousNum)25 let ind = indent(previousNum)27 " TODO: don't auto-indent inside a multi-line comment?28 if previous =~ '\%([{[(:]\|("\)$' && previous !~ '^\s*#'29 let ind += &tabstop30 endif32 " TODO: dedent to matching parens, don't just dedent once33 if line =~ '^\s*\%([\])}]\|")\|\.\.\)'34 "let ind -= &tabstop35 return current_ind - &tabstop36 endif38 if ind == indent(previousNum)39 return current_ind40 endif41 return ind42 endfunction