1" Vim filetype plugin file 2" Language: R Markdown file 3" Maintainer: Jakson Alves de Aquino <[email protected]> 4" Homepage: https://github.com/jalvesaq/R-Vim-runtime 5" Last Change: Sat Aug 15, 2020 12:03PM 6" Original work by Alex Zvoleff (adjusted from R help for rmd by Michel Kuhlmann) 7 8" Only do this when not yet done for this buffer 9if exists("b:did_ftplugin") 10 finish 11endif 12 13if exists('g:rmd_include_html') && g:rmd_include_html 14 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim 15endif 16 17setlocal comments=fb:*,fb:-,fb:+,n:> 18setlocal commentstring=#\ %s 19setlocal formatoptions+=tcqln 20setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+ 21setlocal iskeyword=@,48-57,_,. 22 23let s:cpo_save = &cpo 24set cpo&vim 25 26function! FormatRmd() 27 if search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW") 28 setlocal comments=:#',:###,:##,:# 29 else 30 setlocal comments=fb:*,fb:-,fb:+,n:> 31 endif 32 return 1 33endfunction 34 35" If you do not want 'comments' dynamically defined, put in your vimrc: 36" let g:rmd_dynamic_comments = 0 37if !exists("g:rmd_dynamic_comments") || (exists("g:rmd_dynamic_comments") && g:rmd_dynamic_comments == 1) 38 setlocal formatexpr=FormatRmd() 39endif 40 41 42" Enables pandoc if it is installed 43unlet! b:did_ftplugin 44runtime ftplugin/pandoc.vim 45 46" Don't load another plugin for this buffer 47let b:did_ftplugin = 1 48 49if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") 50 let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . 51 \ "All Files (*.*)\t*.*\n" 52endif 53 54if exists('b:undo_ftplugin') 55 let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< | unlet! b:browsefilter" 56else 57 let b:undo_ftplugin = "setl cms< com< fo< flp< isk< | unlet! b:browsefilter" 58endif 59 60let &cpo = s:cpo_save 61unlet s:cpo_save 62 63" vim: sw=2 64