rrst.vim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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: 2024 Feb 28 by Vim Project
  7. " Original work by Alex Zvoleff
  8. " Only do this when not yet done for this buffer
  9. if exists("b:did_ftplugin")
  10. finish
  11. endif
  12. " Don't load another plugin for this buffer
  13. let b:did_ftplugin = 1
  14. let s:cpo_save = &cpo
  15. set cpo&vim
  16. setlocal comments=fb:*,fb:-,fb:+,n:>
  17. setlocal commentstring=#\ %s
  18. setlocal formatoptions+=tcqln
  19. setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+
  20. setlocal iskeyword=@,48-57,_,.
  21. function FormatRrst()
  22. if search('^\.\. {r', "bncW") > search('^\.\. \.\.$', "bncW")
  23. setlocal comments=:#',:###,:##,:#
  24. else
  25. setlocal comments=fb:*,fb:-,fb:+,n:>
  26. endif
  27. return 1
  28. endfunction
  29. " If you do not want 'comments' dynamically defined, put in your vimrc:
  30. " let g:rrst_dynamic_comments = 0
  31. if !exists("g:rrst_dynamic_comments") || (exists("g:rrst_dynamic_comments") && g:rrst_dynamic_comments == 1)
  32. setlocal formatexpr=FormatRrst()
  33. endif
  34. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  35. let b:browsefilter = "R Source Files (*.R, *.Rnw, *.Rd, *.Rmd, *.Rrst, *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n"
  36. if has("win32")
  37. let b:browsefilter .= "All Files (*.*)\t*\n"
  38. else
  39. let b:browsefilter .= "All Files (*)\t*\n"
  40. endif
  41. endif
  42. if exists('b:undo_ftplugin')
  43. let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
  44. else
  45. let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter"
  46. endif
  47. let &cpo = s:cpo_save
  48. unlet s:cpo_save
  49. " vim: sw=2