Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 1 | " Vim indent file |
| 2 | " Language: gitolite configuration |
Bram Moolenaar | 01164a6 | 2017-11-02 22:58:42 +0100 | [diff] [blame] | 3 | " URL: https://github.com/sitaramc/gitolite/blob/master/contrib/vim/indent/gitolite.vim |
| 4 | " (https://raw.githubusercontent.com/sitaramc/gitolite/master/contrib/vim/indent/gitolite.vim) |
| 5 | " Maintainer: Sitaram Chamarty <sitaramc@gmail.com> |
| 6 | " (former Maintainer: Teemu Matilainen <teemu.matilainen@iki.fi>) |
| 7 | " Last Change: 2017 Oct 05 |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 8 | |
| 9 | if exists("b:did_indent") |
| 10 | finish |
| 11 | endif |
| 12 | let b:did_indent = 1 |
| 13 | |
| 14 | setlocal autoindent |
| 15 | setlocal indentexpr=GetGitoliteIndent() |
| 16 | setlocal indentkeys=o,O,*<Return>,!^F,=repo,\",= |
| 17 | |
| 18 | " Only define the function once. |
| 19 | if exists("*GetGitoliteIndent") |
| 20 | finish |
| 21 | endif |
| 22 | |
Bram Moolenaar | b6b046b | 2011-12-30 13:11:27 +0100 | [diff] [blame] | 23 | let s:cpo_save = &cpo |
| 24 | set cpo&vim |
| 25 | |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 26 | function! GetGitoliteIndent() |
| 27 | let prevln = prevnonblank(v:lnum-1) |
| 28 | let pline = getline(prevln) |
| 29 | let cline = getline(v:lnum) |
| 30 | |
| 31 | if cline =~ '^\s*\(C\|R\|RW\|RW+\|RWC\|RW+C\|RWD\|RW+D\|RWCD\|RW+CD\|-\)[ \t=]' |
Bram Moolenaar | 3ec574f | 2017-06-13 18:12:01 +0200 | [diff] [blame] | 32 | return shiftwidth() |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 33 | elseif cline =~ '^\s*config\s' |
Bram Moolenaar | 3ec574f | 2017-06-13 18:12:01 +0200 | [diff] [blame] | 34 | return shiftwidth() |
Bram Moolenaar | 01164a6 | 2017-11-02 22:58:42 +0100 | [diff] [blame] | 35 | elseif cline =~ '^\s*option\s' |
| 36 | return shiftwidth() |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 37 | elseif pline =~ '^\s*repo\s' && cline =~ '^\s*\(#.*\)\?$' |
Bram Moolenaar | 3ec574f | 2017-06-13 18:12:01 +0200 | [diff] [blame] | 38 | return shiftwidth() |
Bram Moolenaar | f1568ec | 2011-12-14 21:17:39 +0100 | [diff] [blame] | 39 | elseif cline =~ '^\s*#' |
| 40 | return indent(prevln) |
| 41 | elseif cline =~ '^\s*$' |
| 42 | return -1 |
| 43 | else |
| 44 | return 0 |
| 45 | endif |
| 46 | endfunction |
Bram Moolenaar | b6b046b | 2011-12-30 13:11:27 +0100 | [diff] [blame] | 47 | |
| 48 | let &cpo = s:cpo_save |
| 49 | unlet s:cpo_save |