vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

gitconfig.vim (841B)


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