rnoweb.vim 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. " Vim indent file
  2. " Language: Rnoweb
  3. " Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
  4. " Homepage: https://github.com/jalvesaq/R-Vim-runtime
  5. " Last Change: Fri Apr 15, 2016 10:58PM
  6. " Only load this indent file when no other was loaded.
  7. if exists("b:did_indent")
  8. finish
  9. endif
  10. runtime indent/tex.vim
  11. function! s:NoTeXIndent()
  12. return indent(line("."))
  13. endfunction
  14. if &indentexpr == "" || &indentexpr == "GetRnowebIndent()"
  15. let s:TeXIndent = function("s:NoTeXIndent")
  16. else
  17. let s:TeXIndent = function(substitute(&indentexpr, "()", "", ""))
  18. endif
  19. unlet! b:did_indent
  20. runtime indent/r.vim
  21. let s:RIndent = function(substitute(&indentexpr, "()", "", ""))
  22. let b:did_indent = 1
  23. setlocal indentkeys=0{,0},!^F,o,O,e,},=\bibitem,=\item
  24. setlocal indentexpr=GetRnowebIndent()
  25. if exists("*GetRnowebIndent")
  26. finish
  27. endif
  28. function GetRnowebIndent()
  29. let curline = getline(".")
  30. if curline =~ '^<<.*>>=$' || curline =~ '^\s*@$'
  31. return 0
  32. endif
  33. if search("^<<", "bncW") > search("^@", "bncW")
  34. return s:RIndent()
  35. endif
  36. return s:TeXIndent()
  37. endfunction
  38. " vim: sw=2