gitconfig.vim 841 B

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