blob: 7d5d44b779537878c680b648ba2303294685a337 [file] [log] [blame]
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00001" Vim indent file
2" Language: git config file
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
Bram Moolenaar543b7ef2013-06-01 14:50:56 +02004" Last Change: 2013 May 30
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00005
6if exists("b:did_indent")
7 finish
8endif
9let b:did_indent = 1
10
11setlocal autoindent
12setlocal indentexpr=GetGitconfigIndent()
13setlocal indentkeys=o,O,*<Return>,0[,],0;,0#,=,!^F
14
Bram Moolenaar53bfca22012-04-13 23:04:47 +020015let b:undo_indent = 'setl ai< inde< indk<'
16
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000017" Only define the function once.
18if exists("*GetGitconfigIndent")
19 finish
20endif
21
22function! GetGitconfigIndent()
Bram Moolenaar7a329912010-05-21 12:05:36 +020023 let line = getline(prevnonblank(v:lnum-1))
24 let cline = getline(v:lnum)
25 if line =~ '\\\@<!\%(\\\\\)*\\$'
26 " odd number of slashes, in a line continuation
27 return 2 * &sw
28 elseif cline =~ '^\s*\['
29 return 0
30 elseif cline =~ '^\s*\a'
31 return &sw
32 elseif cline == '' && line =~ '^\['
33 return &sw
34 else
35 return -1
36 endif
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000037endfunction