diff runtime/ftplugin/rmd.vim @ 32061:b2412874362f

Update runtime files Commit: https://github.com/vim/vim/commit/dd60c365cd2630794be84d63c4fe287124a30b97 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 27 15:49:53 2023 +0000 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Mon, 27 Feb 2023 17:00:08 +0100
parents 5bda4653aced
children b2e8663e6dcc
line wrap: on
line diff
--- a/runtime/ftplugin/rmd.vim
+++ b/runtime/ftplugin/rmd.vim
@@ -2,7 +2,7 @@
 " Language: R Markdown file
 " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com>
 " Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change:	Sat Aug 15, 2020  12:03PM
+" Last Change:	Sun Apr 24, 2022  09:12AM
 " Original work by Alex Zvoleff (adjusted from R help for rmd by Michel Kuhlmann)
 
 " Only do this when not yet done for this buffer
@@ -32,13 +32,24 @@ function! FormatRmd()
   return 1
 endfunction
 
-" If you do not want 'comments' dynamically defined, put in your vimrc:
-" let g:rmd_dynamic_comments = 0
+function! SetRmdCommentStr()
+    if (search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")) || ((search('^---$', 'Wn') || search('^\.\.\.$', 'Wn')) && search('^---$', 'bnW'))
+        set commentstring=#\ %s
+    else
+        set commentstring=<!--\ %s\ -->
+    endif
+endfunction
+
+" If you do not want both 'comments' and 'commentstring' dynamically defined,
+" put in your vimrc: let g:rmd_dynamic_comments = 0
 if !exists("g:rmd_dynamic_comments") || (exists("g:rmd_dynamic_comments") && g:rmd_dynamic_comments == 1)
   setlocal formatexpr=FormatRmd()
+  augroup RmdCStr
+    autocmd!
+    autocmd CursorMoved <buffer> call SetRmdCommentStr()
+  augroup END
 endif
 
-
 " Enables pandoc if it is installed
 unlet! b:did_ftplugin
 runtime ftplugin/pandoc.vim
@@ -47,7 +58,7 @@ runtime ftplugin/pandoc.vim
 let b:did_ftplugin = 1
 
 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
-  let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" .
+  let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst *.qmd)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst;*.qmd\n" .
         \ "All Files (*.*)\t*.*\n"
 endif