rrst.vim 1.8 KB

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