diff options
| author | Ben Beltran <ben@freshout.us> | 2012-10-08 11:44:10 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@freshout.us> | 2012-10-08 11:44:10 -0500 |
| commit | 0d23b6e515a01a5782532351821ebfa11f3d6cf2 (patch) | |
| tree | aa395b7e50ccb533d6b48b809016ac06f2d5bc8c /vim/indent/gitconfig.vim | |
| parent | a91731eac872b7837c2821341db5888702125cef (diff) | |
Add vim again :)
Diffstat (limited to 'vim/indent/gitconfig.vim')
| -rw-r--r-- | vim/indent/gitconfig.vim | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vim/indent/gitconfig.vim b/vim/indent/gitconfig.vim new file mode 100644 index 0000000..e190fc3 --- /dev/null +++ b/vim/indent/gitconfig.vim @@ -0,0 +1,36 @@ +" Vim indent file +" Language: git config file +" Maintainer: Tim Pope <vimNOSPAM@tpope.org> + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetGitconfigIndent() +setlocal indentkeys=o,O,*<Return>,0[,],0;,0#,=,!^F + +let b:undo_indent = 'setl ai< inde< indk<' + +" Only define the function once. +if exists("*GetGitconfigIndent") + finish +endif + +function! GetGitconfigIndent() + let line = getline(prevnonblank(v:lnum-1)) + let cline = getline(v:lnum) + if line =~ '\\\@<!\%(\\\\\)*\\$' + " odd number of slashes, in a line continuation + return 2 * &sw + elseif cline =~ '^\s*\[' + return 0 + elseif cline =~ '^\s*\a' + return &sw + elseif cline == '' && line =~ '^\[' + return &sw + else + return -1 + endif +endfunction |