Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
rmd.vim88 linesDownload Raw Back to ftplugin
1" Vim filetype plugin file2" Language:		R Markdown file3" 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-runtime6" Last Change:7"  2024 Feb 28 by Vim Project8"  2024 Sep 23 by Vim Project: properly restore fex option9" 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 buffer12if exists("b:did_ftplugin")13  finish14endif15 16if exists('g:rmd_include_html') && g:rmd_include_html17  runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim18endif19 20setlocal comments=fb:*,fb:-,fb:+,n:>21setlocal commentstring=#\ %s22setlocal formatoptions+=tcqln23setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+24setlocal iskeyword=@,48-57,_,.25 26let s:cpo_save = &cpo27set cpo&vim28 29function FormatRmd()30  if search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")31    setlocal comments=:#',:###,:##,:#32  else33    setlocal comments=fb:*,fb:-,fb:+,n:>34  endif35  return 136endfunction37 38let s:last_line = 039function SetRmdCommentStr()40  if line('.') == s:last_line41    return42  endif43  let s:last_line = line('.')44 45  if (search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")) || ((search('^---$', 'Wn') || search('^\.\.\.$', 'Wn')) && search('^---$', 'bnW'))46    set commentstring=#\ %s47  else48    set commentstring=<!--\ %s\ -->49  endif50endfunction51 52" If you do not want both 'comments' and 'commentstring' dynamically defined,53" put in your vimrc: let g:rmd_dynamic_comments = 054if !exists("g:rmd_dynamic_comments") || (exists("g:rmd_dynamic_comments") && g:rmd_dynamic_comments == 1)55  setlocal formatexpr=FormatRmd()56  augroup RmdCStr57    autocmd!58    autocmd CursorMoved <buffer> call SetRmdCommentStr()59  augroup END60endif61 62" Enables pandoc if it is installed63unlet! b:did_ftplugin64runtime ftplugin/pandoc.vim65 66" Don't load another plugin for this buffer67let b:did_ftplugin = 168 69if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")70  let b:browsefilter = "R Source Files (*.R, *.Rnw, *.Rd, *.Rmd, *.Rrst, *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n"71  if has("win32")72    let b:browsefilter .= "All Files (*.*)\t*\n"73  else74    let b:browsefilter .= "All Files (*)\t*\n"75  endif76endif77 78if exists('b:undo_ftplugin')79  let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< fex< | unlet! b:browsefilter"80else81  let b:undo_ftplugin = "setl cms< com< fo< flp< isk< fex< | unlet! b:browsefilter"82endif83 84let &cpo = s:cpo_save85unlet s:cpo_save86 87" vim: sw=288 
codekingpro/portable-devtools · Team Ai