Mercurial > repo
view src/ploki/indent/ploki.vim @ 8916:0234daffd946
<oerjan> addquote <int-e> I couldn\'t help thinking that maybe if one considers the ramifications in full detail it will turn out that overthinking is often not helpful and therefore, not something to be proud of.
author | HackBot |
---|---|
date | Sun, 14 Aug 2016 02:31:47 +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