gitolite.vim 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. " Vim indent file
  2. " Language: gitolite configuration
  3. " URL: https://github.com/sitaramc/gitolite/blob/master/contrib/vim/indent/gitolite.vim
  4. " (https://raw.githubusercontent.com/sitaramc/gitolite/master/contrib/vim/indent/gitolite.vim)
  5. " Maintainer: Sitaram Chamarty <sitaramc@gmail.com>
  6. " (former Maintainer: Teemu Matilainen <teemu.matilainen@iki.fi>)
  7. " Last Change: 2022 Apr 06
  8. if exists("b:did_indent")
  9. finish
  10. endif
  11. let b:did_indent = 1
  12. setlocal autoindent
  13. setlocal indentexpr=GetGitoliteIndent()
  14. setlocal indentkeys=o,O,*<Return>,!^F,=repo,\",=
  15. let b:undo_indent = "setl ai< inde< indk<"
  16. " Only define the function once.
  17. if exists("*GetGitoliteIndent")
  18. finish
  19. endif
  20. let s:cpo_save = &cpo
  21. set cpo&vim
  22. function! GetGitoliteIndent()
  23. let prevln = prevnonblank(v:lnum-1)
  24. let pline = getline(prevln)
  25. let cline = getline(v:lnum)
  26. if cline =~ '^\s*\(C\|R\|RW\|RW+\|RWC\|RW+C\|RWD\|RW+D\|RWCD\|RW+CD\|-\)[ \t=]'
  27. return shiftwidth()
  28. elseif cline =~ '^\s*config\s'
  29. return shiftwidth()
  30. elseif cline =~ '^\s*option\s'
  31. return shiftwidth()
  32. elseif pline =~ '^\s*repo\s' && cline =~ '^\s*\(#.*\)\?$'
  33. return shiftwidth()
  34. elseif cline =~ '^\s*#'
  35. return indent(prevln)
  36. elseif cline =~ '^\s*$'
  37. return -1
  38. else
  39. return 0
  40. endif
  41. endfunction
  42. let &cpo = s:cpo_save
  43. unlet s:cpo_save