robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
0bb2f5cc08
master
1" Vim filetype plugin file 2" Language: R Markdown file 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 (adjusted from R help for rmd by Michel Kuhlmann) 10 11" Only do this when not yet done for this buffer 12if exists ( "b:did_ftplugin" ) 13finish 14endif 15 16if exists ( 'g:rmd_include_html' ) && g: rmd_include_html 17runtime ! ftplugin/html[.]{vim,lua} ftplugin/html_*.{vim,lua} ftplugin/html/*.{vim,lua} 18endif 19 20setlocal comments = fb:*,fb:-,fb:+,n:> 21setlocal commentstring = #\ %s 22setlocal formatoptions += tcqln 23setlocal formatlistpat = ^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+ 24setlocal iskeyword = @,48-57,_,. 25 26let s: cpo_save = & cpo 27set cpo & vim 28 29function FormatRmd () 30if search ( "^[ \t]*```[ ]*{r" , "bncW" ) > search ( "^[ \t]*```$" , "bncW" ) 31setlocal comments = :#',:###,:##,:# 32else 33setlocal comments = fb:*,fb:-,fb:+,n:> 34endif 35return 1 36endfunction 37 38let s: last_line = 0 39function SetRmdCommentStr () 40if line ( '.' ) == s: last_line 41return 42endif 43let s: last_line = line ( '.' ) 44 45if ( search ( "^[ \t]*```[ ]*{r" , "bncW" ) > search ( "^[ \t]*```$" , "bncW" )) || (( search ( '^---$' , 'Wn' ) || search ( '^\.\.\.$' , 'Wn' )) && search ( '^---$' , 'bnW' )) 46set commentstring = #\ %s 47else 48set commentstring = <!--\ %s\ --> 49endif 50endfunction 51 52" If you do not want both 'comments' and 'commentstring' dynamically defined, 53" put in your vimrc: let g:rmd_dynamic_comments = 0 54if ! exists ( "g:rmd_dynamic_comments" ) || ( exists ( "g:rmd_dynamic_comments" ) && g: rmd_dynamic_comments == 1 ) 55setlocal formatexpr = FormatRmd () 56augroup RmdCStr 57autocmd ! 58autocmd CursorMoved <buffer> call SetRmdCommentStr () 59augroup END 60endif 61 62" Enables pandoc if it is installed 63unlet ! b: did_ftplugin 64runtime ftplugin/pandoc.vim 65 66" Don't load another plugin for this buffer 67let b: did_ftplugin = 1 68 69if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 70let b: browsefilter = "R Source Files (*.R, *.Rnw, *.Rd, *.Rmd, *.Rrst, *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n" 71if has ( "win32" ) 72let b: browsefilter .= "All Files (*.*)\t*\n" 73else 74let b: browsefilter .= "All Files (*)\t*\n" 75endif 76endif 77 78if exists ( 'b:undo_ftplugin' ) 79let b: undo_ftplugin .= " | setl cms< com< fo< flp< isk< fex< | unlet! b:browsefilter" 80else 81let b: undo_ftplugin = "setl cms< com< fo< flp< isk< fex< | unlet! b:browsefilter" 82endif 83 84let & cpo = s: cpo_save 85unlet s: cpo_save 86 87" vim: sw=2