Mercurial > repo
view src/ploki/indent/ploki.vim @ 6612:2eb9df791119
<mroman> echo "#!/bin/sh" > bin/halp
author | HackBot |
---|---|
date | Fri, 29 Jan 2016 10:47:36 +0000 |
parents | ac0403686959 |
children |
line wrap: on
line source
" Only load this one if no other indent file was loaded. if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal indentexpr=GetPlokiIndent() setlocal indentkeys=!^F,o,O,0=ELSE,0=END\ IF,0=FI,0=KTHX " Only define the function once. if exists("*GetPlokiIndent") finish endif function GetPlokiIndent() if v:lnum == 1 return 0 endif let plnum = v:lnum - 1 let prevline = getline(plnum) while plnum > 0 && prevline =~ '^\s*$' let plnum = plnum - 1 let prevline = getline(plnum) endwhile let ind = indent(plnum) let thisline = getline(v:lnum) if prevline =~ '^FOR\%(\s*\S\+\)\@>\%(\s*KTHX\)\@!' let ind = ind + &sw endif if prevline =~ '^\s*\%(FOR\s*\S\+\|\d*\)\s*\%(IF\|ELSE\)' let ind = ind + &sw endif if thisline =~ '^\s*\%(FOR\s*\S\+\|\d*\)\s*\%(ELSE\|END IF\|FI\)' let ind = ind - &sw elseif ind == &sw && thisline =~ '^\s*\%(\d\+\s*\)\=KTHX' let ind = ind - &sw endif return ind endfunction