summaryrefslogtreecommitdiffstats
path: root/indent/indent_pir.vim
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-03-26 08:27:06 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-03-26 08:27:06 +0200
commitcaada1036793d9d131840ce65b488403b1d1963f (patch)
tree9cb738d05cb9555c867cbb9e7304c62ceabca2a4 /indent/indent_pir.vim
parent3a80316ff8ff7a21b1f57e2a923b281ac1b4b146 (diff)
downloadvim-caada1036793d9d131840ce65b488403b1d1963f.zip
vim-caada1036793d9d131840ce65b488403b1d1963f.tar.gz
add indent
Diffstat (limited to 'indent/indent_pir.vim')
-rw-r--r--indent/indent_pir.vim75
1 files changed, 75 insertions, 0 deletions
diff --git a/indent/indent_pir.vim b/indent/indent_pir.vim
new file mode 100644
index 0000000..29dd9f6
--- /dev/null
+++ b/indent/indent_pir.vim
@@ -0,0 +1,75 @@
+" Description: imcc indenter
+" Author: Andrew Rodland <arodland@entermail.net>
+" Last Change: 2004 Aug 3
+
+" As usual, we want to be alone
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent=1
+
+setlocal indentexpr=PIRIndent()
+setlocal indentkeys=o,O,*<Return>,<bs>,:,=.end,0#
+
+fun! InPOD(lnum)
+ return synIDattr(synID(a:lnum, 1, 1), "name") =~? '^myPod$\|^pod[A-Z]'
+endfun
+
+fun! PIRIndent()
+ let thisline = getline(v:lnum)
+
+ let POD_START = '^=[a-z]'
+
+ if thisline =~? POD_START
+ return 0
+ endif
+
+
+ if InPOD(v:lnum)
+ return -1
+ endif
+
+ let LABEL_OR_COMMENT = '^\s*\k\+:\s*$\|^#'
+ if thisline =~? LABEL_OR_COMMENT
+ return 0
+ endif
+
+ let lnum=v:lnum
+ while lnum > 0
+ let lnum = prevnonblank(lnum-1)
+ let prevline = getline(lnum)
+
+ if prevline !~? LABEL_OR_COMMENT
+ if !InPOD(lnum)
+ break
+ endif
+ endif
+ endwhile
+
+ if lnum < 1
+ return 0
+ endif
+
+ let ind = indent(lnum)
+
+ let SUB = '^\s*\.pcc_sub\s\+\|^\s*\.sub\s\+'
+ let RETURNBLOCK = '\s*\.pcc_begin_return\s*$'
+ let END = '^\s*\.end\s*$\|^\s*\.pcc_end_return\s*$'
+
+ if prevline =~? SUB
+ let ind = ind + &sw
+ endif
+
+ if prevline =~? RETURNBLOCK
+ let ind = ind + &sw
+ endif
+
+ if thisline =~? END
+ let ind = ind - &sw
+ endif
+
+ return ind
+
+endfun
+
+