diff runtime/ftplugin/rmd.vim @ 33368:033f22d4a52a

runtime(rmd) Update ftplugin and syntax files (#13193) Commit: https://github.com/vim/vim/commit/34745942390383ec626b168e9837d284622c7bbe Author: Jakson Alves de Aquino <jalvesaq@gmail.com> Date: Wed Sep 27 13:56:02 2023 -0300 runtime(rmd) Update ftplugin and syntax files (https://github.com/vim/vim/issues/13193) ftplugin/rmd.vim: - Set 'commentstring' dynamically according to code region. syntax/rmd.vim: - Include syntax highlighting of fenced languages dynamically. - Add conceal char for line break. Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 27 Sep 2023 19:00:12 +0200
parents b2e8663e6dcc
children 8ae680be2a51
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:	Mon Feb 27, 2023  07:15PM
+" Last Change:	Mon May 29, 2023  06:31AM
 " 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,12 +32,18 @@ function FormatRmd()
   return 1
 endfunction
 
+let s:last_line = 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
+  if line('.') == s:last_line
+    return
+  endif
+  let s:last_line = line('.')
+
+  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,