robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Barrett Ruthfix(ftplugin): source inherited Lua ftplugins0bb2f5cc08

master
2.6 KiB87 linesraw
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")
13  finish
14endif
15
16if exists('g:rmd_include_html') && g:rmd_include_html
17  runtime! 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()
30  if search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")
31    setlocal comments=:#',:###,:##,:#
32  else
33    setlocal comments=fb:*,fb:-,fb:+,n:>
34  endif
35  return 1
36endfunction
37
38let s:last_line = 0
39function SetRmdCommentStr()
40  if line('.') == s:last_line
41    return
42  endif
43  let s:last_line = line('.')
44
45  if (search("^[ \t]*```[ ]*{r", "bncW") > search("^[ \t]*```$", "bncW")) || ((search('^---$', 'Wn') || search('^\.\.\.$', 'Wn')) && search('^---$', 'bnW'))
46    set commentstring=#\ %s
47  else
48    set commentstring=<!--\ %s\ -->
49  endif
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)
55  setlocal formatexpr=FormatRmd()
56  augroup RmdCStr
57    autocmd!
58    autocmd CursorMoved <buffer> call SetRmdCommentStr()
59  augroup 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")
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  else
74    let b:browsefilter .= "All Files (*)\t*\n"
75  endif
76endif
77
78if exists('b:undo_ftplugin')
79  let b:undo_ftplugin .= " | setl cms< com< fo< flp< isk< fex< | unlet! b:browsefilter"
80else
81  let 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