Mercurial > repo
view src/ploki/indent/ploki.vim @ 8065:591b1467ccdf
<int-e> le/rn paste/"Paste" is a short story by Henry James. Its contents has been cut into pieces and distributed over numerous tin boxes on the World Wide Web, little pearls of wisdom buried among ordinary pastes.
author | HackBot |
---|---|
date | Sun, 15 May 2016 13:14:57 +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