qlow.vim 774 B

123456789101112131415161718192021222324252627282930313233343536
  1. " indent/qlow.vim
  2. if exists("b:did_indent")
  3. finish
  4. endif
  5. let b:did_indent = 1
  6. setlocal indentexpr=QlowIndent()
  7. setlocal nolisp
  8. setlocal nosmartindent
  9. setlocal nocindent
  10. setlocal autoindent
  11. setlocal comments=:--
  12. setlocal indentkeys+==end,=do,=class
  13. let b:undo_indent = "setl smartindent< indentkeys< indentexpr< autoindent< comments< "
  14. function! QlowIndent()
  15. let line = getline(v:lnum)
  16. let previousNum = prevnonblank(v:lnum - 1)
  17. let previous = getline(previousNum)
  18. let ind = indent(previousNum)
  19. "if previous =~ "{" && previous !~ "}" && line !~ "}" && line !~ ":$"
  20. if previous =~ "class" || previous =~ "do"
  21. let ind = ind + &shiftwidth
  22. endif
  23. if getline(v:lnum) =~ '^\s*end'
  24. let ind = ind - &shiftwidth
  25. endif
  26. return ind
  27. endfunction