]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/indent/gitconfig.vim
Merge branch 'main' of git.sr.ht:~rbdr/dotfiles
[rbdr/dotfiles] / vim / indent / gitconfig.vim
CommitLineData
0d23b6e5
BB
1" Vim indent file
2" Language: git config file
3" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4
5if exists("b:did_indent")
6 finish
7endif
8let b:did_indent = 1
9
10setlocal autoindent
11setlocal indentexpr=GetGitconfigIndent()
12setlocal indentkeys=o,O,*<Return>,0[,],0;,0#,=,!^F
13
14let b:undo_indent = 'setl ai< inde< indk<'
15
16" Only define the function once.
17if exists("*GetGitconfigIndent")
18 finish
19endif
20
21function! GetGitconfigIndent()
22 let line = getline(prevnonblank(v:lnum-1))
23 let cline = getline(v:lnum)
24 if line =~ '\\\@<!\%(\\\\\)*\\$'
25 " odd number of slashes, in a line continuation
26 return 2 * &sw
27 elseif cline =~ '^\s*\['
28 return 0
29 elseif cline =~ '^\s*\a'
30 return &sw
31 elseif cline == '' && line =~ '^\['
32 return &sw
33 else
34 return -1
35 endif
36endfunction