annotate runtime/indent/gitolite.vim @ 48:67300faee616 v7-3-618

v7-3-618
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 01 Aug 2012 18:08:28 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 " Vim indent file
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 " Language: gitolite configuration
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 " URL: https://github.com/tmatilai/gitolite.vim
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 " Maintainer: Teemu Matilainen <teemu.matilainen@iki.fi>
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 " Last Change: 2011-12-24
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 if exists("b:did_indent")
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 finish
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 endif
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 let b:did_indent = 1
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 setlocal autoindent
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 setlocal indentexpr=GetGitoliteIndent()
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 setlocal indentkeys=o,O,*<Return>,!^F,=repo,\",=
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 " Only define the function once.
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 if exists("*GetGitoliteIndent")
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 finish
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 endif
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 let s:cpo_save = &cpo
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 set cpo&vim
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 function! GetGitoliteIndent()
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 let prevln = prevnonblank(v:lnum-1)
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 let pline = getline(prevln)
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 let cline = getline(v:lnum)
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 if cline =~ '^\s*\(C\|R\|RW\|RW+\|RWC\|RW+C\|RWD\|RW+D\|RWCD\|RW+CD\|-\)[ \t=]'
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 return &sw
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 elseif cline =~ '^\s*config\s'
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 return &sw
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 elseif pline =~ '^\s*repo\s' && cline =~ '^\s*\(#.*\)\?$'
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 return &sw
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 elseif cline =~ '^\s*#'
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 return indent(prevln)
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 elseif cline =~ '^\s*$'
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 return -1
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 else
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 return 0
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 endif
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 endfunction
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 let &cpo = s:cpo_save
67300faee616 v7-3-618
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 unlet s:cpo_save