From 555f492ec66ed51aaeddd54eb8a476a95a4d90b3 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 27 Sep 2023 19:29:05 +0200 Subject: vim-patch:347459423903 runtime(rmd) Update ftplugin and syntax files (vim/vim#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. https://github.com/vim/vim/commit/34745942390383ec626b168e9837d284622c7bbe Co-authored-by: Jakson Alves de Aquino --- runtime/ftplugin/rmd.vim | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'runtime/ftplugin') diff --git a/runtime/ftplugin/rmd.vim b/runtime/ftplugin/rmd.vim index be6ab7335b..a407c236dd 100644 --- a/runtime/ftplugin/rmd.vim +++ b/runtime/ftplugin/rmd.vim @@ -2,7 +2,7 @@ " Language: R Markdown file " Maintainer: Jakson Alves de Aquino " 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= - 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= + endif endfunction " If you do not want both 'comments' and 'commentstring' dynamically defined, -- cgit