rrst.vim 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. " Vim filetype plugin file
  2. " Language: reStructuredText documentation format with R code
  3. " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com>
  4. " Homepage: https://github.com/jalvesaq/R-Vim-runtime
  5. " Last Change: Wed Nov 01, 2017 10:47PM
  6. " Original work by Alex Zvoleff
  7. " Only do this when not yet done for this buffer
  8. if exists("b:did_ftplugin")
  9. finish
  10. endif
  11. " Don't load another plugin for this buffer
  12. let b:did_ftplugin = 1
  13. let s:cpo_save = &cpo
  14. set cpo&vim
  15. setlocal comments=fb:*,fb:-,fb:+,n:>
  16. setlocal commentstring=#\ %s
  17. setlocal formatoptions+=tcqln
  18. setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+
  19. setlocal iskeyword=@,48-57,_,.
  20. function! FormatRrst()
  21. if search('^\.\. {r', "bncW") > search('^\.\. \.\.$', "bncW")
  22. setlocal comments=:#',:###,:##,:#
  23. else
  24. setlocal comments=fb:*,fb:-,fb:+,n:>
  25. endif
  26. return 1
  27. endfunction
  28. " If you do not want 'comments' dynamically defined, put in your vimrc:
  29. " let g:rrst_dynamic_comments = 0
  30. if !exists("g:rrst_dynamic_comments") || (exists("g:rrst_dynamic_comments") && g:rrst_dynamic_comments == 1)
  31. setlocal formatexpr=FormatRrst()
  32. endif
  33. if has("gui_win32") && !exists("b:browsefilter")
  34. let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" .
  35. \ "All Files (*.*)\t*.*\n"
  36. endif
  37. if exists('b:undo_ftplugin')
  38. let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
  39. else
  40. let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
  41. endif
  42. let &cpo = s:cpo_save
  43. unlet s:cpo_save
  44. " vim: sw=2