Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / editors / scvim / indent / supercollider.vim
blob2cd9d9d1fb1ae675c712e55329334e6deb2e916a
1 "this indent function isn't that smart yet, hopefully it'll improve in the future
2 if exists ("b:did_indent")
3         finish
4 endif
5 let b:did_indent = 1
7 setlocal indentexpr=GetSCIndent()
8 setlocal indentkeys+=0),0],0}
10 if exists ("*GetSCIndent")
11         finish
12 endif
14 function GetSCIndent()
16         let curr_line = getline(v:lnum)
17         let lnum = prevnonblank(v:lnum - 1)
19         if lnum == 0
20                 return 0
21         endif
23         let prev_line = getline(lnum)
25         let ind = indent(lnum)
27         if prev_line =~ '\(\/\/.*\)\@\<![[({]\s*\([^])}]*\)\=$'
28                 let ind = ind + &sw
29         endif
31         if curr_line =~ '\v^\s*[)}\]]'
32                 "if synIDattr(synID(line("."), col("."), 0), "name") =~? "scComment" ||
33                 "       synIDattr(synID(line("."), col("."), 0), "name") =~? "scString" ||
34                 "       synIDattr(synID(line("."), col("."), 0), "name") =~? "scSymbol"
35                 "       "do nothing
36                 "else
37                         let ind = ind - &sw
38                 "end
39         endif
41         return ind
42 endfunction