Annotation of rpl/vim/indent/rpl.vim, revision 1.1

1.1     ! bertrand    1: " Vim indent file
        !             2: " Language:    RPL/2
        !             3: " Version: 0.3
        !             4: " Last Change: 2005 October 22
        !             5: " Maintainer:  BERTRAND Joël <joel.bertrand@systella.fr>
        !             6: 
        !             7: " Only load this indent file when no other was loaded.
        !             8: if exists("b:did_indent")
        !             9:   finish
        !            10: endif
        !            11: let b:did_indent = 1
        !            12: 
        !            13: setlocal indentkeys+==~end,=~case,=~if,=~then,=~else,=~do,=~until,=~while,=~repeat,=~select,=~default,=~for,=~start,=~next,=~step,<<>,<>>
        !            14: 
        !            15: " Define the appropriate indent function but only once
        !            16: setlocal indentexpr=RplGetFreeIndent()
        !            17: if exists("*RplGetFreeIndent")
        !            18:   finish
        !            19: endif
        !            20: 
        !            21: function RplGetIndent(lnum)
        !            22:   let ind = indent(a:lnum)
        !            23:   let prevline=getline(a:lnum)
        !            24:   " Strip tail comment
        !            25:   let prevstat=substitute(prevline, '!.*$', '', '')
        !            26: 
        !            27:   " Add a shiftwidth to statements following if, iferr, then, else, elseif,
        !            28:   " case, select, default, do, until, while, repeat, for, start
        !            29:   if prevstat =~? '\<\(if\|iferr\|do\|while\)\>' && prevstat =~? '\<end\>'
        !            30:   elseif prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)' && prevstat =~? '\s\+>>\($\|\s\+\)'
        !            31:   elseif prevstat =~? '\<\(if\|iferr\|then\|else\|elseif\|select\|case\|do\|until\|while\|repeat\|for\|start\|default\)\>' || prevstat =~? '\(^\|\s\+\)<<\($\|\s\+\)'
        !            32:     let ind = ind + &sw
        !            33:   endif
        !            34: 
        !            35:   if prevstat =~? '/\*'
        !            36:     let ind = ind + 1
        !            37:   endif
        !            38: 
        !            39:   " Subtract a shiftwidth from then, else, elseif, end, until, repeat, next,
        !            40:   " step
        !            41:   let line = getline(v:lnum)
        !            42:   if line =~? '^\s*\(then\|else\|elseif\|until\|repeat\|next\|step\|default\|end\)\>'
        !            43:     let ind = ind - &sw
        !            44:   elseif line =~? '^\s*>>\($\|\s\+\)'
        !            45:     let ind = ind - &sw
        !            46:   endif
        !            47: 
        !            48:   if prevstat =~? '\*/'
        !            49:     let ind = ind - 1
        !            50:   endif
        !            51:   return ind
        !            52: endfunction
        !            53: 
        !            54: function RplGetFreeIndent()
        !            55:   " Find the previous non-blank line
        !            56:   let lnum = prevnonblank(v:lnum - 1)
        !            57: 
        !            58:   " Use zero indent at the top of the file
        !            59:   if lnum == 0
        !            60:     return 0
        !            61:   endif
        !            62: 
        !            63:   let ind=RplGetIndent(lnum)
        !            64:   return ind
        !            65: endfunction
        !            66: 
        !            67: " vim:sw=2 tw=130

CVSweb interface <joel.bertrand@systella.fr>